diff --git a/keywords2insta.sh b/keywords2insta.sh index 944bfda..1f1b82b 100755 --- a/keywords2insta.sh +++ b/keywords2insta.sh @@ -16,12 +16,13 @@ reset="\033[0m" wild=("wildlife" "wildlifephoto" "wildlifephotographer") nat=("naturelovers" "natureshot" "naturephotography") reg=("Bourgogne" "Burgundy" "Bourgogne Franche-Comté" "Côte d'or") -#others=("lanscape" "animal") -others=() +others=("lanscape" "animal" "beautiful nature") +#others=() # Display Instagram AND/OR Flickr tags -insta=true -flickr=true +insta=false # #Becasseauvariable #LeTeich #Bird +flickr=true # "Bécasseau variable" "Le Teich" Bird +ccpx=true # Bécasseau variable, Le Teich, Bird gps=0 opt_gps=true @@ -72,10 +73,10 @@ alpha () { } showHelp() { - echo -e "${greenbold}keywords2insta${reset} v2.1" + echo -e "${greenbold}keywords2insta${reset} v3.1" echo -e "Bruno " echo -e "Read exif and keywords from an image file, and copy them to the clipboard, " - echo -e " ready for Instagram and Flickr." + echo -e " ready for Instagram, Flickr and 500px." echo echo -e "${yellow}USAGE:${reset}" echo -e "${green}keyword2insta [-Options...] -f ${reset}" @@ -115,6 +116,10 @@ showHelp() { echo -e " 3: Unknown long option." echo -e " 4: Unknown short option." echo -e " 5: No Keywords found in image file." + echo + echo -e "${yellow}Changelog:${reset}" + echo -e " v3.0: support 500px" + echo -e " v3.1: display thumb" } # https://stackoverflow.com/questions/402377/using-getopts-to-process-long-and-short-command-line-options @@ -238,8 +243,6 @@ exif=$(exiftool -j "$file") # exif -#make=$(echo "$exif" | jq -e '.[] | has("Make") | .Make') - make=$(echo "$exif" | jq -j '.[] | .Make | select( . != null )') model=$(echo "$exif" | jq -j '.[] | .Model | select( . != null )') date_original=$(echo "$exif" | jq -j '.[] | .DateTimeOriginal | select( . != null )') @@ -257,6 +260,23 @@ width=$(echo "$exif" | jq -j '.[] | .ImageWidth | select( . != null )') height=$(echo "$exif" | jq -j '.[] | .ImageHeight | select( . != null )') size=$(echo "$exif" | jq -j '.[] | .FileSize | select( . != null )') +echo "$lensID" + +# Display thumb image + +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 + 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" + fi +fi + echo if [[ -n $iso ]] && [[ -n $speed ]] && [[ -n $aperture ]]; then printf " %-11s %-35s \n" "Speed:" "${speed}" @@ -272,6 +292,62 @@ if [[ -n $iso ]] && [[ -n $speed ]] && [[ -n $aperture ]]; then fi printf " %-11s %-35s \n" "Focal:" "${focal}" +# "LensInfo": "100-500mm f/?", +# "LensModel": "RF100-500mm F4.5-7.1 L IS USM", +# "Lens": "RF100-500mm F4.5-7.1 L IS USM", +# "LensID": "Canon RF 100-500mm F4.5-7.1L IS USM or Canon RF 100-500mm F4.5-7.1L IS USM + RF1.4x or Canon RF 100-500mm F4.5-7.1L IS USM + RF2x" + +# "LensInfo": "600mm f/?", +# "LensModel": "EF600mm f/4L IS III USM", +# "Lens": "EF600mm f/4L IS III USM", +# "LensID": "Canon EF 600mm f/4L IS III USM" + +# "LensInfo": "100mm f/?", +# "LensModel": "EF100mm f/2.8 Macro USM", +# "Lens": "EF100mm f/2.8 Macro USM", +# "LensID": "Canon EF 100mm f/2.8 Macro USM" + +# "LensInfo": "24-105mm f/?", +# "LensModel": "EF24-105mm f/4L IS USM", +# "Lens": "EF24-105mm f/4L IS USM", +# "LensID": "Canon EF 24-105mm f/4L IS USM" + +# "LensInfo": "17-40mm f/?", +# "LensModel": "EF17-40mm f/4L USM", +# "Lens": "EF17-40mm f/4L USM", +# "LensID": "Canon EF 17-40mm f/4L USM" + +# "LensInfo": "500mm f/?", +# "LensModel": "EF500mm f/4L IS USM", +# "Lens": "EF500mm f/4L IS USM", +# "LensID": "Canon EF 500mm f/4L IS USM" + +# "LensInfo": "70-200mm f/?", +# "LensModel": "EF70-200mm f/4L USM", +# "Lens": "EF70-200mm f/4L USM", +# "LensID": "Canon EF 70-200mm f/4L USM" + +# "LensInfo": "24mm f/?", +# "LensModel": "24mm F1.4 DG HSM | Art 015", +# "Lens": "24mm F1.4 DG HSM | Art 015", +# "LensID": "Sigma 24-105mm f/4 DG OS HSM | A" + +# "LensInfo": "24-105mm f/?", +# "LensModel": "RF24-105mm F4-7.1 IS STM", +# "Lens": "RF24-105mm F4-7.1 IS STM", +# "LensID": "Canon RF 24-105mm F4-7.1 IS STM" + +# "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/?", +# "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" + + if [[ -n $lensID ]]; then printf " %-11s %-35s \n" "LensID:" "${lensID}" l="$lensID" @@ -282,8 +358,20 @@ if [[ -n $iso ]] && [[ -n $speed ]] && [[ -n $aperture ]]; then printf " %-11s %-35s \n" "Lens:" "${lens}" l="$lens" fi - printf " %-11s %-35s \n" "Widht:" "${width}" - printf " %-11s %-35s \n" "Height:" "${height}" + # width > height && w=2400 || w=1600 + if [ $width -gt $height ]; then + wi=2400 + he=1600 + [ $width -ne $wi ] && printf " %-11s %-35s \n" "Width:" "${red}${width}${reset}" || printf " %-11s %-35s \n" "Width:" "${width}" + [ $height -ne $he ] && printf " %-11s %-35s \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 %-35s \n" "Width:" "${red}${width}${reset}" || printf " %-11s %-35s \n" "Width:" "${width}" + [ $height -ne $he ] && printf " %-11s %-35s \n" "Height:" "${red}${height}${reset}" || printf " %-11s %-35s \n" "Height:" "${height}" + fi + #printf " %-11s %-35s \n" "Width:" "${width}" + #printf " %-11s %-35s \n" "Height:" "${height}" printf " %-11s %-35s \n" "Size:" "${size}" if [[ -n $latitude ]] && [[ -n $longitude ]]; then @@ -311,6 +399,7 @@ if [[ -n $iso ]] && [[ -n $speed ]] && [[ -n $aperture ]]; then fi + # gps if [ $opt_gps = true ]; then if [ $gps -eq 1 ]; then @@ -362,14 +451,16 @@ do fi k_fr="$ii" - if [ -n "$k_en" ]; then [[ "$k_fr" = *" "* ]] && keyword_flickr+="\"${k_fr}\" " || keyword_flickr+="${k_fr} " [[ "$k_en" = *" "* ]] && keyword_flickr+="\"${k_en}\" " || keyword_flickr+="${k_en} " keyword_insta+="#${k_fr// /} #${k_en// /} " + [[ "$k_fr" = *" "* ]] && keyword_ccpx+="${k_fr}," || keyword_ccpx+="${k_fr}," + [[ "$k_en" = *" "* ]] && keyword_ccpx+="${k_en}," || keyword_ccpx+="${k_en}," else [[ "$k_fr" = *" "* ]] && keyword_flickr+="\"${k_fr}\" " || keyword_flickr+="${k_fr} " + [[ "$k_fr" = *" "* ]] && keyword_ccpx+="${k_fr}," || keyword_ccpx+="${k_fr}," keyword_insta+="#${k_fr// /} " fi @@ -443,6 +534,7 @@ do else model_flickr+="${i} " fi + model_ccpx+="${i}," model_insta+="#${i// /} " # supprime tous les espaces et ajoute le # done @@ -497,6 +589,7 @@ done lens_flickr="\"${l}\" " lens_insta="$(echo "$l" | sed 's/ //g' | sed -r 's/[^ ]+/#&/g') " +lens_ccpx+="${l}," for i in "${wild[@]}" @@ -506,7 +599,8 @@ 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_ccpx+="${i}," + wildlife_insta+="#$(echo "${i}" | iconv -s -f UTF-8-MAC -t ascii//translit | sed 's/[^a-zA-Z 0-9]//g' | sed 's/ //g') " done for i in "${nat[@]}" @@ -516,7 +610,8 @@ do else nature_flickr+="${i} " fi - nature_insta+="#$(echo "${i}" | iconv -f UTF-8-MAC -t ascii//translit | sed 's/[^a-zA-Z 0-9]//g' | sed 's/ //g') " + nature_ccpx+="${i}," + nature_insta+="#$(echo "${i}" | iconv -s -f UTF-8-MAC -t ascii//translit | sed 's/[^a-zA-Z 0-9]//g' | sed 's/ //g') " done for i in "${reg[@]}" @@ -526,7 +621,8 @@ do else region_flickr+="${i} " fi - region_insta+="#$(echo "${i}" | iconv -f UTF-8-MAC -t ascii//translit | sed 's/[^a-zA-Z 0-9]//g' | sed 's/ //g') " + region_ccpx+="${i}," + region_insta+="#$(echo "${i}" | iconv -s -f UTF-8-MAC -t ascii//translit | sed 's/[^a-zA-Z 0-9]//g' | sed 's/ //g') " done @@ -567,31 +663,37 @@ if [ $opt_all = false ]; then if [ $opt_wildlife = false ]; then wildlife_flickr="" wildlife_insta="" + wildlife_ccpx="" fi if [ $opt_nature = false ]; then nature_flickr="" nature_insta="" + nature_ccpx="" fi if [ $opt_region = false ]; then region_flickr="" region_insta="" + region_ccpx="" fi if [ $opt_lens = false ]; then lens_flickr="" lens_insta="" + lens_ccpx="" fi if [ $opt_model = false ]; then model_flickr="" model_insta="" + model_ccpx="" fi fi keywords_flickr="$keyword_flickr$model_flickr$lens_flickr$wildlife_flickr$nature_flickr$region_flickr" +keywords_ccpx="$keyword_ccpx$model_ccpx$lens_ccpx$wildlife_ccpx$nature_ccpx$region_ccpx" keywords_insta=$(echo "$keyword_insta$model_insta$lens_insta$wildlife_insta$nature_insta$region_insta" | awk '{print tolower($0)}') if [ $opt_others = true ]; then @@ -611,13 +713,17 @@ if [ $opt_others = true ]; then [[ "$i" = *" "* ]] && others_flickr+="\"${i}\" " || others_flickr+="${i} " [[ "$o_en" = *" "* ]] && others_flickr+="\"${o_en}\" " || others_flickr+="${o_en} " others_insta+="#${i// /} #${o_en// /} " + [[ "$i" = *" "* ]] && others_ccpx+="${i}," || others_ccpx+="${i}," + [[ "$o_en" = *" "* ]] && others_ccpx+="${o_en}," || others_ccpx+="${o_en}," else [[ "$i" = *" "* ]] && others_flickr+="\"${i}\" " || others_flickr+="${i} " + [[ "$i" = *" "* ]] && others_ccpx+="${i}," || others_ccpx+="${i}," others_insta+="#${i// /} " fi done keywords_flickr+="$others_flickr" keywords_insta+="$others_insta" + keywords_ccpx+="${others_ccpx:0:-1}" fi @@ -631,7 +737,8 @@ if ! command -v iconv &> /dev/null; then echo -e " - brew install iconv" echo -e "" else - keywords_insta=$(echo "$keywords_insta" | iconv -f UTF-8-MAC -t ascii//translit | sed 's/[^a-zA-Z 0-9 \#]//g') + ### + keywords_insta=$(echo "$keywords_insta" | iconv -s -f UTF-8-MAC -t ascii//translit | sed 's/[^a-zA-Z 0-9 \#]//g') fi @@ -660,8 +767,7 @@ if [ "$insta" = true ]; then echo -e "\n${bold}The Instagram's tags are available in your clipboard !${reset}" echo "$keywords_insta" - echo -e "\nPress to get the Flickr' tags..." - read -p "" + [ "$flickr" = true ] || [ "$ccpx" = true ] && echo -e "\nPress to get the Flickr's or the 500px's tags..." && read -p "" fi @@ -674,4 +780,19 @@ 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 to get the 500px's tags..." && read -p "" +fi + +if [ "$ccpx" = true ]; then + if [[ "$OSTYPE" == "linux-gnu" ]] && [ -x "$(command -v xsel)" ]; then + xsel -b <<< "$keywords_ccpx" + elif [[ "$OSTYPE" == "darwin"* ]] && [ -x "$(command -v pbcopy)" ]; then + pbcopy <<< "$keywords_ccpx" + fi + + #[ "$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}" + [ "$insta" = true ] || [ "$flickr" = true ] && echo -e "\n${bold}Here the 500px's tags too !${reset}" || echo -e "\n${bold}The 500px's tags are available in your clipboard !${reset}" + + echo "$keywords_ccpx" fi