3 Commits
v3.3 ... v3.4

Author SHA1 Message Date
d66f887416 Bugfix
-correction pour le EF600mm f/4L IS III USM +1.4x III qui affichait Unknown (160) 840mm
2024-09-03 16:45:09 +02:00
38228e615c 05-08-2024 2024-08-05 23:28:29 +02:00
b58bf60fe5 shellcheck 2024-01-03 09:15:48 +01:00
2 changed files with 77 additions and 73 deletions

1
.gitignore vendored
View File

@@ -1 +1,2 @@
.DS_Store
.envrc

View File

@@ -25,8 +25,8 @@ flickr=true # "Bécasseau variable" "Le Teich" Bird
ccpx=true # Bécasseau variable, Le Teich, Bird
gps=0
opt_gps=true # insert gps data (false: gps data will be deleted in file)
opt_copyright=true # insert copyright, artist, creator (false: data will be deleted in file)
opt_gps=false # insert gps data (false: gps data will be deleted in file)
opt_copyright=false # insert copyright, artist, creator (false: data will be deleted in file)
# Default: all tags
opt_others=false
@@ -35,7 +35,7 @@ opt_model=false
opt_region=false
opt_nature=false
opt_wildlife=false
opt_all=true # default
opt_all=false # default
# Google maps static
zoom=10
@@ -46,24 +46,23 @@ map_size="450x450"
prefix=${map_size%%x*} # find x position in map_size string
x=${#prefix}
gm_width=${map_size:0:$x}
echo $gm_width
long_path=`pwd`"/"`basename "$0"` # /Users/bruno/Documents/Scripts/kymsu2/keywords2insta.sh
#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
dir=$(dirname "$0") # /Users/bruno/Documents/Scripts/keywords2insta
dotenv () {
set -a
[ -f .env ] && . .env || echo -e "${red}\nNo .env file found ! Googlemaps reverse geocode not working.${reset}"
# shellcheck disable=SC1091
[ -f "$HOME/.env" ] && . "$HOME/.env" || echo -e "${red}\nNo .env file found ! Googlemaps reverse geocode not working.${reset}"
set +a
}
dotenv
trim () {
read -rd '' $1 <<<"${!1}"
read -rd '' "$1" <<<"${!1}"
}
alpha_name=
@@ -73,7 +72,7 @@ alpha () {
#declare -A ilce=( ['ILCE-7M3']="Alpha 7 III" ['ILCE-7M4']="α7 IV" ['ILCE-7MRM5']="α7R V" ['ILCE-7SM3']="Alpha 7S III" ['ILCE-7RM4']="α7R IV" ['ILCE-7RM3']="α7R III" ['ILCE-7C']="Alpha 7C" )
declare -A ilce
if [ -f $dir/sony.csv ]; then
if [ -f "$dir"/sony.csv ]; then
#echo "Loading Sony APNs..."
@@ -82,7 +81,7 @@ alpha () {
key="${array[0]}"
value="${array[1]}"
ilce["$key"]="$value"
done < $dir/sony.csv
done < "$dir"/sony.csv
fi
@@ -114,6 +113,8 @@ showHelp() {
echo -e " ${green}-n${reset}, ${green}--nature${reset} Add nature related keywords"
echo -e " ${green}-r${reset}, ${green}--region${reset} Add region related keywords"
echo -e " ${green}-c${reset}, ${green}--copyright${reset} Delete artist and copyright in file"
echo -e " ${green}-c${reset}, ${green}--gps${reset} Delete gps infos in file"
echo -e " ${green}-c${reset}, ${green}--all${reset} All options are true"
echo -e " ${green}-t${reset} <keywords> Add some additionnals keywords"
echo -e " ${green}-w${reset}, ${green}--wildlife${reset} Add wildlife related keywords"
echo -e " ${green}-h${reset}, ${green}--help${reset} Display this help"
@@ -145,6 +146,7 @@ showHelp() {
echo -e " v3.1: display thumb"
echo -e " v3.2: suppress copyright and artist infos"
echo -e " v3.3: add a static Google maps for geoloc"
echo -e " v3.4: by default, no keywords are displayed. Add option --all to display all keywords"
}
# https://stackoverflow.com/questions/402377/using-getopts-to-process-long-and-short-command-line-options
@@ -170,6 +172,8 @@ do
;;
model) opt_model=true;;
lens) opt_lens=true;;
gps) opt_gps=true;;
all) opt_all=true;;
copyright) opt_copyright=false;;
*)
if [ "$OPTERR" = 1 ] && [ "${optspec:0:1}" = ":" ]; then
@@ -181,7 +185,7 @@ do
w) opt_wildlife=true;;
n) opt_nature=true;;
r) opt_region=true;;
c) opt_copyright=false;;
c) opt_copyright=true;;
f) file="${OPTARG}";;
t) tags=("$OPTARG")
until [[ $(eval "echo \${$OPTIND}") =~ ^-.* ]] || [ -z $(eval "echo \${$OPTIND}") ]; do
@@ -191,6 +195,8 @@ do
;;
m) opt_model=true;;
l) opt_lens=true;;
g) opt_gps=true;;
a) opt_all=true;;
h)
showHelp
exit 0
@@ -205,8 +211,17 @@ do
done
#shift $((OPTIND-1))
if [ $opt_lens = true ] || [ $opt_model = true ] || [ $opt_region = true ] || [ $opt_nature = true ] || [ $opt_wildlife = true ]; then
opt_all=false
#if [ $opt_lens = true ] || [ $opt_model = true ] || [ $opt_region = true ] || [ $opt_nature = true ] || [ $opt_wildlife = true ]; then
# opt_all=false
#fi
if [ $opt_all = true ]; then
opt_others=true
opt_lens=true
opt_model=true
opt_region=true
opt_nature=true
opt_wildlife=true
fi
# others: array from script
@@ -227,7 +242,8 @@ echo "opt_region: " $opt_region # r
echo "opt_nature: " $opt_nature # n
echo "opt_wildlife: " $opt_wildlife # w
echo "opt_others: " $opt_others
echo "opt_copyright: " $opt_copyright # c
echo "opt_copyright: " $opt_copyright
echo "opt_gps: " $opt_gps # l# c
echo "----"
END_COMMENT
@@ -251,7 +267,7 @@ en=()
array2=()
declare -A dico
if [ -f $dir/keywords.csv ]; then
if [ -f "$dir"/keywords.csv ]; then
echo "Loading keyword dictionary..."
@@ -259,7 +275,7 @@ if [ -f $dir/keywords.csv ]; then
do
fr+=("${array2[0]}")
en+=("${array2[1]}")
done < $dir/keywords.csv
done < "$dir"/keywords.csv
j=0
for i in "${fr[@]}"
@@ -331,16 +347,18 @@ fi
# Display thumb image
if [ "$(echo $__CFBundleIdentifier | grep iterm2)" ]; then
if [ "$(echo "$__CFBundleIdentifier" | grep iterm2)" ]; then
tmp_path=/tmp/k2i
[ -d $tmp_path ] && rm -rf $tmp_path
mkdir $tmp_path
tempfoo=`basename "$file"`
magick "$file" -quality 50 -resize 600x600\> $tmp_path/thumb_$tempfoo
#tempfoo=`basename "$file"`
tempfoo=$(basename "$file")
magick "$file" -quality 50 -resize 600x600\> $tmp_path/thumb_"$tempfoo"
if [ -f "$tmp_path/thumb_$tempfoo" ]; then
[ $width -gt $height ] && w_thumb=600 || w_thumb=$(echo "600/3*2" | bc)
printf "\n\t\033]1337;File=;width=$w_thumb px;inline=1:`cat $tmp_path/thumb_$tempfoo | base64`\a\n"
[ "$width" -gt "$height" ] && w_thumb=600 || w_thumb=$(echo "600/3*2" | bc)
#printf "\n\t\033]1337;File=;width=$w_thumb px;inline=1:`cat $tmp_path/thumb_$tempfoo | base64`\a\n"
printf "\n\t\033]1337;File=;width=$w_thumb px;inline=1:$(cat $tmp_path/thumb_$tempfoo | base64)\a\n"
fi
fi
@@ -407,18 +425,22 @@ if [[ -n $iso ]] && [[ -n $speed ]] && [[ -n $aperture ]]; then
# "Lens": "RF24-105mm F4-7.1 IS STM",
# "LensID": "Canon RF 24-105mm F4-7.1 IS STM"
# "LensInfo": "840mm f/?",
# "LensInfo": "840mm f/?",
# "LensModel": "EF600mm f/4L IS III USM +1.4x III",
# "Lens": "EF600mm f/4L IS III USM +1.4x III",
# "LensID": "Canon EF 600mm f/4L IS III USM + 1.4x"
# "LensInfo": "700mm f/?",
# "LensInfo": "700mm f/?",
# "LensModel": "EF500mm f/4L IS USM +1.4x III",
# "Lens": "EF500mm f/4L IS USM +1.4x III",
# "LensID": "Canon EF 500mm f/4L IS USM + 1.4x"
# "LensInfo": "840mm f/?",
# "LensModel": "EF600mm f/4L IS III USM +1.4x III",
# "Lens": "EF600mm f/4L IS III USM +1.4x III",
# "LensID": "Unknown (160) 840mm"
if [[ -n $lensID ]]; then
if [[ -n $lensID ]] && [[ ! "$lensID" =~ Unknown* ]]; then
printf " %-11s %-35s \n" "LensID:" "${lensID}"
l="$lensID"
elif [[ -n $lensModel ]]; then
@@ -429,16 +451,16 @@ if [[ -n $iso ]] && [[ -n $speed ]] && [[ -n $aperture ]]; then
l="$lens"
fi
# width > height && w=2400 || w=1600
if [ $width -gt $height ]; then
if [ "$width" -gt "$height" ]; then
wi=2400
he=1600
[ $width -ne $wi ] && printf " %-11s %-35b \n" "Width:" "${red}${width}${reset}" || printf " %-11s %-35s \n" "Width:" "${width}"
[ $height -ne $he ] && printf " %-11s %-35b \n" "Height:" "${red}${height}${reset}" || printf " %-11s %-35s \n" "Height:" "${height}"
elif [ $height -gt $width ]; then
[ "$width" -ne "$wi" ] && printf " %-11s %-35b \n" "Width:" "${red}${width}${reset}" || printf " %-11s %-35s \n" "Width:" "${width}"
[ "$height" -ne "$he" ] && printf " %-11s %-35b \n" "Height:" "${red}${height}${reset}" || printf " %-11s %-35s \n" "Height:" "${height}"
elif [ "$height" -gt "$width" ]; then
wi=1600
he=2400
[ $width -ne $wi ] && printf " %-11s %-35b \n" "Width:" "${red}${width}${reset}" || printf " %-11s %-35s \n" "Width:" "${width}"
[ $height -ne $he ] && printf " %-11s %-3b \n" "Height:" "${red}${height}${reset}" || printf " %-11s %-35s \n" "Height:" "${height}"
[ "$width" -ne "$wi" ] && printf " %-11s %-35b \n" "Width:" "${red}${width}${reset}" || printf " %-11s %-35s \n" "Width:" "${width}"
[ "$height" -ne "$he" ] && printf " %-11s %-3b \n" "Height:" "${red}${height}${reset}" || printf " %-11s %-35s \n" "Height:" "${height}"
fi
#printf " %-11s %-35s \n" "Width:" "${width}"
#printf " %-11s %-35s \n" "Height:" "${height}"
@@ -480,13 +502,15 @@ if [[ -n $iso ]] && [[ -n $speed ]] && [[ -n $aperture ]]; then
gm_path=/tmp/k2i/gm.png
curl -s "$url" --output $gm_path
if [ -f "$gm_path" ]; then
printf "\n\t\033]1337;File=;width=$((gm_width * 2)) px;inline=1:`cat $gm_path | base64`\a\n"
#printf "\n\t\033]1337;File=;width=$((gm_width * 2)) px;inline=1:`cat $gm_path | base64`\a\n"
printf "\n\t\033]1337;File=;width=$((gm_width * 2)) px;inline=1:$(cat $gm_path | base64)\a\n"
fi
fi
fi
fi
printf " %-11s %-35s \n" "Software:" "${software}"
printf " %-11s %-35s \n" "Comment:" "${comment}"
printf " %-11s %-35s \n" "Artist:" "${artist}"
printf " %-11s %-35s \n" "Copyright:" "${copyright}"
@@ -495,6 +519,20 @@ if [[ -n $iso ]] && [[ -n $speed ]] && [[ -n $aperture ]]; then
fi
: <<'END_COMMENT'
echo "----"
echo "others: " ${others[@]}
echo "tags: " ${tags[@]} # t
echo "opt_lens: " $opt_lens # l
echo "opt_model: " $opt_model # m
echo "opt_region: " $opt_region # r
echo "opt_nature: " $opt_nature # n
echo "opt_wildlife: " $opt_wildlife # w
echo "opt_others: " $opt_others
echo "opt_copyright: " $opt_copyright
echo "opt_gps: " $opt_gps # l# c
echo "----"
END_COMMENT
# gps
if [ $opt_gps = true ]; then
@@ -502,24 +540,20 @@ if [ $opt_gps = true ]; then
echo -e "${red}GPS data available !${reset}"
d=$(echo -e "Do you want to ${bold}erase GPS data${reset} ? (k)eep or (e)rase ")
read -p "$d" choice
read -r -p "$d" 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
# copyright
if [ $opt_copyright = false ]; then
if [ $opt_copyright = true ]; then
b=$(echo -e "Do you want to ${bold}erase Artist and Copyright data${reset} ? (k)eep or (e)rase ")
read -p "$b" choice
read -r -p "$b" choice
if [ "$choice" == "e" ] || [ "$choice" == "E" ]; then
echo "Erasing Artist and Copyright data..."
@@ -540,7 +574,7 @@ if [ -z "$k" ]; then
fi
IFS="," read -a key <<< "$k"
IFS="," read -r -a key <<< "$k"
for i in "${key[@]}"
@@ -697,6 +731,7 @@ done
# 1 LensID puis 2 LendModel
lens_flickr="\"${l}\" "
lens_insta="$(echo "$l" | sed 's/ //g' | sed -r 's/[^ ]+/#&/g') "
lens_ccpx+="${l},"
@@ -736,38 +771,6 @@ do
done
: <<'END_COMMENT'
echo "Model flickr: $model_flickr"
echo "Model insta: $model_insta"
echo
echo "Keywords flickr: $keyword_flickr"
echo "Keywords insta: $keyword_insta"
echo
echo "Lens flick: $lens_flickr"
echo "Lens_insta: $lens_insta"
echo
echo "Wildlife flickr: $wildlife_flickr"
echo "Wildlife insta: $wildlife_insta"
echo
echo "Nature flickr: $nature_flickr"
echo "Nature insta: $nature_insta"
echo
echo "Region flickr: $region_flickr"
echo "Region insta: $region_insta"
echo
echo "tags: ${tags[@]}"
echo "others: ${others[@]}"
echo "file: $file"
echo "wildlife: $opt_wildlife"
echo "nature: $opt_nature"
echo "region: $opt_region"
echo "model: $opt_model"
echo "lens: $opt_lens"
echo "all: $opt_all"
echo
END_COMMENT
if [ $opt_all = false ]; then
if [ $opt_wildlife = false ]; then
@@ -877,7 +880,7 @@ if [ "$insta" = true ]; then
echo -e "\n${bold}The Instagram's tags are available in your clipboard !${reset}"
echo "$keywords_insta"
[ "$flickr" = true ] || [ "$ccpx" = true ] && echo -e "\nPress <Enter> to get the Flickr's or the 500px's tags..." && read -p ""
[ "$flickr" = true ] || [ "$ccpx" = true ] && echo -e "\nPress <Enter> to get the Flickr's or the 500px's tags..." && read -r -p ""
fi
@@ -891,7 +894,7 @@ if [ "$flickr" = true ]; then
[ "$insta" = true ] && echo -e "\n${bold}Here the Flickr's tags too !${reset}" || echo -e "\n${bold}The Flickr's tags are available in your clipboard !${reset}"
echo "$keywords_flickr"
"$ccpx" = true ] && echo -e "\nPress <Enter> to get the 500px's tags..." && read -p ""
[ "$ccpx" = true ] && echo -e "\nPress <Enter> to get the 500px's tags..." && read -r -p ""
fi
if [ "$ccpx" = true ]; then