diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b8912b0 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.nova diff --git a/convertimage.sh b/convertimage.sh index 42623ea..f05c262 100755 --- a/convertimage.sh +++ b/convertimage.sh @@ -4,6 +4,8 @@ italic="\033[3m" #underline="\033[4m" bgd="\033[1;4;31m" red="\033[1;31m" +greenbold="\033[1;32m" +green="\033[0;32m" bold="\033[1m" bold_under="\033[1;4m" reset="\033[0m" @@ -74,6 +76,8 @@ fi : <<'END_COMMENT' END_COMMENT + + # Main Menu main() { @@ -112,7 +116,7 @@ main() { if [[ $main_menu == "1" ]] || [[ $main_menu == "a" ]] || [[ $main_menu == "A" ]]; then about elif [[ $main_menu == "2" ]] || [[ $main_menu == "h" ]] || [[ $main_menu == "H" ]]; then - help + showHelp elif [[ $main_menu == "3" ]] || [[ $main_menu == "m" ]] || [[ $main_menu == "M" ]]; then _mozjpeg elif [[ $main_menu == "4" ]] || [[ $main_menu == "v" ]] || [[ $main_menu == "V" ]]; then @@ -148,21 +152,45 @@ about() { read -pr "" } -help() { +showHelp() { clear - echo "" - echo -e "${bold_under}Help:${reset}" + echo -e "${greenbold}Convertimage${reset} v0.5" + echo -e "Bruno " + echo -e "Convert image file to avif, webp or mozjpeg format." + echo + echo -e "${yellow}USAGE:${reset}" + echo -e "${green}convertimage [-Options...] -f ${reset}" + echo -e "\n${bold}Main Menu:${reset}" + echo -e "${yellow}OPTIONS:${reset}" + echo -e " ${green}-f${reset}, ${green}--file ${reset} Image file" + echo -e " ${green}-l${reset}, ${green}--lens${reset} Add lens exif" + + echo + echo -e "${yellow}REQUIEREMENTS:${reset}" + echo -e " -${underline}exiftool${reset} for extract exifs ${bold}(requis)${reset}" + echo -e " brew install exiftool" + + echo + echo -e "${yellow}EXAMPLES:${reset}" + echo -e " keyword2insta -f image.jpg" + + echo + echo -e "${yellow}EXIT CODES:${reset}" + echo -e " 0: Success !" + echo -e "\n" - read -pr "" + read -p "" } _mozjpeg() { clear + echo "mozjpeg" + if [ "$mozjpeg_lossless" = true ]; then bin=$(command -v jpegtran || command -v mozjpegtran) if [ "$bin" = "" ]; then echo -e "${bold}convertimage${reset} require ${bold}jpegtran${reset} from ${bold}mozjpeg${reset} but it's not installed.\nRun ${italic}(brew install mozjpeg)${reset}\nAborting..." >&2; exit 1; fi; @@ -204,8 +232,8 @@ _mozjpeg() { # /usr/local/bin/mozcjpeg - echo -e "\n" - read -pr "" + echo + read -p "Press to quit" open "$dest_folder" @@ -259,19 +287,20 @@ _avif() { if [ "$avif_lossless" = true ]; then - for FILE in "${SRC}"/**/*.{mkv,avi,mp4,m4v} + for FILE in "${folder}"/**/*.{jpg,jpeg,png,tif,tiff} do echo "$FILE" done else - for FILE in "${SRC}"/**/*.{mkv,avi,mp4,m4v} + echo $bin + for FILE in "${folder}"/**/*.{jpg,jpeg,png,tif,tiff} do echo "$FILE" done fi - echo -e "\n" - read -pr "" + echo + read -p "Press to quit" } _webp() { @@ -292,7 +321,7 @@ _webp() { #extension=${filename##*.} filename=${filename%.*} - echo -e "\n${italic}Convert $FILE${reset}\n" + echo -e "\n${green}${italic}Convert $FILE${reset}\n" if [ "$webp_lossless" = true ]; then cwebp -lossless "$FILE" -mt -o "$dest_folder/$filename.webp" @@ -302,10 +331,10 @@ _webp() { ((count++)) done - echo -e "\n$count images were successfully converted !" + echo -e "\n${greenbold}$count images were successfully converted !${reset}" - echo -e "\n" - read -pr "" + echo + read -p "Press to quit" open "$dest_folder" } @@ -334,7 +363,7 @@ _heic() { echo -e "\n$count images were successfully converted !" echo -e "\n" - read -pr "" + read -p "" open "$dest_folder" @@ -342,4 +371,17 @@ _heic() { + + +optspec="amwh" +while getopts "$optspec" opt +do + case $opt in + a) _avif;; + m) _mozjpeg; exit 0;; + w) _webp;; + h) showHelp;; + esac +done + main