4 Commits
v2.0 ... 2.1

Author SHA1 Message Date
305c6bcd96 GPS data
-add option to erase GPS data
2023-11-14 13:28:21 +01:00
464ce8987c v 2.0 2023-11-14 12:47:45 +01:00
85668bb29f Clean code 2023-07-21 09:58:05 +02:00
07230ac0cd bugsfix 2023-07-20 20:38:47 +02:00

View File

@@ -23,6 +23,9 @@ others=()
insta=true
flickr=true
gps=0
opt_gps=true
opt_others=false
opt_lens=false
opt_model=false
@@ -32,13 +35,10 @@ opt_wildlife=false
opt_all=true
long_path=`pwd`"/"`basename "$0"` # /Users/bruno/Documents/Scripts/kymsu2/keywords2insta.sh
# long: /Users/bruno/Documents/GitHub/GooFuzz/keywords2insta.sh
#long_path=$(realpath "$0") # vide
echo "long: $long_path"
dir=$(dirname "$0")
#dir="$0"
echo "dir: $dir"
dir=$(dirname "$0") # /Users/bruno/Documents/Scripts/keywords2insta
trim () {
@@ -72,7 +72,7 @@ alpha () {
}
showHelp() {
echo -e "${greenbold}keywords2insta${reset} v1.1"
echo -e "${greenbold}keywords2insta${reset} v2.1"
echo -e "Bruno <bruno<clicclac.info>"
echo -e "Read exif and keywords from an image file, and copy them to the clipboard, "
echo -e " ready for Instagram and Flickr."
@@ -194,6 +194,8 @@ fi
[ ! -f "$file" ] && echo -e "${bold}${red}No input file !${reset}" && exit 2
echo -e "\n${greenbold}keywords2insta${reset} v2.0"
# dico français / anglais
fr=()
@@ -221,10 +223,8 @@ if [ -f $dir/keywords.csv ]; then
fi
echo -e "\n${greenbold}keywords2insta${reset} v2.0"
echo -e "\n${bold}Reading $file exif...${reset}"
#exif=$(exiftool -Canon -s -Keywords "$file")
# The exiftool application exits with a status of 0 on success, or 1 if an
# error occurred, or 2 if all files failed the -if condition (for any of
# the commands if -execute was used).
@@ -237,13 +237,6 @@ exif=$(exiftool -j "$file")
# the commands if -execute was used).
# exif
#echo "$exif"
#if (jq -e '.[] | has("Make")' <<< "$exif"); then
# make=$(echo "$exif" | jq -j '.[] | .Make')
#else
# make="z"
#fi
#make=$(echo "$exif" | jq -e '.[] | has("Make") | .Make')
@@ -257,6 +250,9 @@ lens=$(echo "$exif" | jq -j '.[] | .Lens | select( . != null )')
lensID=$(echo "$exif" | jq -j '.[] | .LensID | select( . != null )')
lensModel=$(echo "$exif" | jq -j '.[] | .LensModel | select( . != null )')
focal=$(echo "$exif" | jq -j '.[] | .FocalLength | select( . != null )')
latitude=$(echo "$exif" | jq -j '.[] | .GPSLatitude | select( . != null )')
longitude=$(echo "$exif" | jq -j '.[] | .GPSLongitude | select( . != null )')
altitude=$(echo "$exif" | jq -j '.[] | .GPSAltitude | select( . != null )')
echo
if [[ -n $iso ]] && [[ -n $speed ]] && [[ -n $aperture ]]; then
@@ -265,8 +261,12 @@ if [[ -n $iso ]] && [[ -n $speed ]] && [[ -n $aperture ]]; then
printf " %-10s %-35s \n" "ISO:" "${iso}"
printf " %-10s %-35s \n" "Date:" "${date_original}"
printf " %-10s %-35s \n" "Maker:" "${make}"
[[ "$make" =~ ^SONY ]] && alpha
printf " %-10s %-35s \n" "APN:" "$alpha_name (${model})"
if [[ "$make" =~ ^SONY ]]; then
alpha
printf " %-10s %-35s \n" "APN:" "$alpha_name (${model})"
else
printf " %-10s %-35s \n" "APN:" "${model}"
fi
printf " %-10s %-35s \n" "Focal:" "${focal}"
if [[ -n $lensID ]]; then
printf " %-10s %-35s \n" "LensID:" "${lensID}"
@@ -278,25 +278,48 @@ if [[ -n $iso ]] && [[ -n $speed ]] && [[ -n $aperture ]]; then
printf " %-10s %-35s \n" "Lens:" "${lens}"
l="$lens"
fi
if [[ -n $latitude ]] && [[ -n $longitude ]]; then
printf " %-10s %-35s \n" "Latitude:" "${latitude}"
printf " %-10s %-35s \n" "Longitude:" "${longitude}"
printf " %-10s %-35s \n" "Altitude:" "${altitude}"
gps=1
fi
echo
fi
# gps
if [ $opt_gps = true ]; then
if [ $gps -eq 1 ]; then
echo "GPS data available !"
a=$(echo -e "Do you want to ${bold}erase GPS data${reset} ? (k)eep or (e)rase ")
read -p "$a" choice
if [ "$choice" == "e" ] || [ "$choice" == "E" ]; then
echo "Erasing GPS data..."
exiftool -gps:all= "$file"
fi
fi
else
# erase GPS data
echo "Erasing GPS data..."
exiftool -gps:all= "$file"
fi
# keywords
k=$(echo "$exif" | jq --compact-output --raw-output '.[] | .Keywords[]?' | tr "\n" "," | sed 's/\,$//')
#k=$(echo "$exif" | sed -n '/^Keywords/p' | awk -F":" '{print $2}' | sed 's/^ *//g')
if [ -z "$k" ]; then
echo -e "\n${bold}${red}No Keywords found !${reset}"
echo "Quit."
#exit 5
echo
fi
IFS="," read -a key <<< "$k"
#echo "key:${key[@]}_"
#echo "dico:${dico[@]}_"
for i in "${key[@]}"
do
@@ -304,22 +327,11 @@ do
# @ bouton d'or@
# xargs: unterminated quote
#ii=$(echo "$i" | xargs -0) # trim $i
#ii=$(echo "$i" | sed 's/ *$//g')
ii="$i"
trim ii
#trim i
#echo "i:$i"
#echo "ii:$ii"
if [[ ! "$ii" =~ ^_ ]]; then
#echo "ii: $ii"
#echo ${dico["$ii"]}
if [[ ${dico["$ii"]} ]] ; then
k_en=${dico["$ii"]}
else
@@ -328,8 +340,6 @@ do
k_fr="$ii"
#echo "k_fr:$k_fr"
#echo "k_en:$k_en"
if [ -n "$k_en" ]; then
[[ "$k_fr" = *" "* ]] && keyword_flickr+="\"${k_fr}\" " || keyword_flickr+="${k_fr} "
@@ -340,8 +350,6 @@ do
keyword_insta+="#${k_fr// /} "
fi
#echo "keyword_insta:$keyword_insta"
#echo "keyword_flickr:$keyword_flickr"
fi
done
@@ -369,17 +377,19 @@ done
# "Make": "Canon",
# "Model": "Canon EOS R7",
#mod=("${model}")
#m=("${model}")
#echo "mod:${mod[@]}_"
#echo "m:${m[@]}_"
if [[ "$make" =~ ^Panasonic ]] || [[ "$make" =~ ^SONY ]] || [[ "$make" =~ ^FUJI ]]; then
if [[ "$make" =~ ^Panasonic ]] || [[ "$make" =~ ^FUJI ]]; then
mod=("${make} ${model}")
mod+=("${make}")
mod+=("${model}")
mod+=("${make,,}photography")
elif [[ "$make" =~ ^SONY ]]; then
mod=("${make} ${model}")
mod+=("${make}")
mod+=("${model}")
# convertir α en Alpha
q=$(echo "${alpha_name}" | sed 's/α/Alpha /')
mod+=("$q")
mod+=("${make,,}photography")
elif [[ "$make" =~ ^"OM Digital Solutions" ]]; then
mod=("${make} ${model}") # OM Digital Solutions OM-5
mod+=("Olympus") # Olympus
@@ -391,7 +401,6 @@ elif [[ "$model" =~ ^NIKON ]] || [[ "$model" =~ ^LEICA ]]; then
mod+=("${z}photography") # nikonphotography leicaphotography
mod+=("${y}") # NIKON LEICA
mod+=("${model}") # NIKON Z 9 LEICA Q3
# awk -F"|" '{$1=$2=$3=""; print $0}' PURCHASE_testing.csv > testing.csv
w=$(echo "${model}" | awk '{$1=""; print $0}' | xargs)
mod+=("${w}")
elif [[ "$model" =~ ^Canon ]]; then
@@ -404,11 +413,8 @@ elif [[ "$model" =~ ^Canon ]]; then
mod+=("${y}") # Canon R6
fi
#echo "mod:${mod[@]}_"
for i in "${mod[@]}"
do
#model+="${i} "
if [[ "$i" = *" "* ]]; then
model_flickr+="\"${i}\" "
else
@@ -417,8 +423,6 @@ do
model_insta+="#${i// /} " # supprime tous les espaces et ajoute le #
done
#echo "model_flickr: $model_flickr"
#echo "model_insta: $model_insta"
#lens
@@ -471,9 +475,6 @@ done
lens_flickr="\"${l}\" "
lens_insta="$(echo "$l" | sed 's/ //g' | sed -r 's/[^ ]+/#&/g') "
#echo "lens_flickr: $lens_flickr"
#echo "lens_insta: $lens_insta"
for i in "${wild[@]}"
do
@@ -482,7 +483,6 @@ do
else
wildlife_flickr+="${i} "
fi
#wildlife_insta+="#"$(echo "${i}" | iconv -f UTF-8-MAC -t ascii//translit | sed 's/[^a-zA-Z 0-9]//g' | sed 's/ //g')" "
wildlife_insta+="#$(echo "${i}" | iconv -f UTF-8-MAC -t ascii//translit | sed 's/[^a-zA-Z 0-9]//g' | sed 's/ //g') "
done
@@ -620,7 +620,6 @@ if ! command -v gawk &> /dev/null; then
echo -e " - brew install gawk"
echo -e ""
else
#keywords_flickr=$(echo "$keywords_flickr" | gawk -v RS="[ \n]" -v ORS=" " '!($0 in a){print;a[$0]}')
keywords_insta=$(echo "$keywords_insta" | gawk -v RS="[ \n]" -v ORS=" " '!($0 in a){print;a[$0]}')
fi