2eme commit
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
.nova
|
||||||
@@ -4,6 +4,8 @@ italic="\033[3m"
|
|||||||
#underline="\033[4m"
|
#underline="\033[4m"
|
||||||
bgd="\033[1;4;31m"
|
bgd="\033[1;4;31m"
|
||||||
red="\033[1;31m"
|
red="\033[1;31m"
|
||||||
|
greenbold="\033[1;32m"
|
||||||
|
green="\033[0;32m"
|
||||||
bold="\033[1m"
|
bold="\033[1m"
|
||||||
bold_under="\033[1;4m"
|
bold_under="\033[1;4m"
|
||||||
reset="\033[0m"
|
reset="\033[0m"
|
||||||
@@ -74,6 +76,8 @@ fi
|
|||||||
: <<'END_COMMENT'
|
: <<'END_COMMENT'
|
||||||
END_COMMENT
|
END_COMMENT
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Main Menu
|
# Main Menu
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
@@ -112,7 +116,7 @@ main() {
|
|||||||
if [[ $main_menu == "1" ]] || [[ $main_menu == "a" ]] || [[ $main_menu == "A" ]]; then
|
if [[ $main_menu == "1" ]] || [[ $main_menu == "a" ]] || [[ $main_menu == "A" ]]; then
|
||||||
about
|
about
|
||||||
elif [[ $main_menu == "2" ]] || [[ $main_menu == "h" ]] || [[ $main_menu == "H" ]]; then
|
elif [[ $main_menu == "2" ]] || [[ $main_menu == "h" ]] || [[ $main_menu == "H" ]]; then
|
||||||
help
|
showHelp
|
||||||
elif [[ $main_menu == "3" ]] || [[ $main_menu == "m" ]] || [[ $main_menu == "M" ]]; then
|
elif [[ $main_menu == "3" ]] || [[ $main_menu == "m" ]] || [[ $main_menu == "M" ]]; then
|
||||||
_mozjpeg
|
_mozjpeg
|
||||||
elif [[ $main_menu == "4" ]] || [[ $main_menu == "v" ]] || [[ $main_menu == "V" ]]; then
|
elif [[ $main_menu == "4" ]] || [[ $main_menu == "v" ]] || [[ $main_menu == "V" ]]; then
|
||||||
@@ -148,21 +152,45 @@ about() {
|
|||||||
read -pr ""
|
read -pr ""
|
||||||
}
|
}
|
||||||
|
|
||||||
help() {
|
showHelp() {
|
||||||
clear
|
clear
|
||||||
echo ""
|
echo -e "${greenbold}Convertimage${reset} v0.5"
|
||||||
echo -e "${bold_under}Help:${reset}"
|
echo -e "Bruno <bruno<clicclac.info>"
|
||||||
|
echo -e "Convert image file to avif, webp or mozjpeg format."
|
||||||
|
echo
|
||||||
|
|
||||||
|
echo -e "${yellow}USAGE:${reset}"
|
||||||
|
echo -e "${green}convertimage [-Options...] -f <file>${reset}"
|
||||||
|
|
||||||
echo -e "\n${bold}Main Menu:${reset}"
|
echo -e "\n${bold}Main Menu:${reset}"
|
||||||
|
|
||||||
|
echo -e "${yellow}OPTIONS:${reset}"
|
||||||
|
echo -e " ${green}-f${reset}, ${green}--file <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<Press Enter to quit>"
|
echo -e "\n<Press Enter to quit>"
|
||||||
read -pr ""
|
read -p ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
_mozjpeg() {
|
_mozjpeg() {
|
||||||
clear
|
clear
|
||||||
|
|
||||||
|
echo "mozjpeg"
|
||||||
|
|
||||||
if [ "$mozjpeg_lossless" = true ]; then
|
if [ "$mozjpeg_lossless" = true ]; then
|
||||||
bin=$(command -v jpegtran || command -v mozjpegtran)
|
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;
|
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
|
# /usr/local/bin/mozcjpeg
|
||||||
|
|
||||||
|
|
||||||
echo -e "\n<Press Enter to quit>"
|
echo
|
||||||
read -pr ""
|
read -p "Press <Enter> to quit"
|
||||||
|
|
||||||
open "$dest_folder"
|
open "$dest_folder"
|
||||||
|
|
||||||
@@ -259,19 +287,20 @@ _avif() {
|
|||||||
|
|
||||||
if [ "$avif_lossless" = true ]; then
|
if [ "$avif_lossless" = true ]; then
|
||||||
|
|
||||||
for FILE in "${SRC}"/**/*.{mkv,avi,mp4,m4v}
|
for FILE in "${folder}"/**/*.{jpg,jpeg,png,tif,tiff}
|
||||||
do
|
do
|
||||||
echo "$FILE"
|
echo "$FILE"
|
||||||
done
|
done
|
||||||
else
|
else
|
||||||
for FILE in "${SRC}"/**/*.{mkv,avi,mp4,m4v}
|
echo $bin
|
||||||
|
for FILE in "${folder}"/**/*.{jpg,jpeg,png,tif,tiff}
|
||||||
do
|
do
|
||||||
echo "$FILE"
|
echo "$FILE"
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo -e "\n<Press Enter to quit>"
|
echo
|
||||||
read -pr ""
|
read -p "Press <Enter> to quit"
|
||||||
}
|
}
|
||||||
|
|
||||||
_webp() {
|
_webp() {
|
||||||
@@ -292,7 +321,7 @@ _webp() {
|
|||||||
#extension=${filename##*.}
|
#extension=${filename##*.}
|
||||||
filename=${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
|
if [ "$webp_lossless" = true ]; then
|
||||||
cwebp -lossless "$FILE" -mt -o "$dest_folder/$filename.webp"
|
cwebp -lossless "$FILE" -mt -o "$dest_folder/$filename.webp"
|
||||||
@@ -302,10 +331,10 @@ _webp() {
|
|||||||
((count++))
|
((count++))
|
||||||
done
|
done
|
||||||
|
|
||||||
echo -e "\n$count images were successfully converted !"
|
echo -e "\n${greenbold}$count images were successfully converted !${reset}"
|
||||||
|
|
||||||
echo -e "\n<Press Enter to quit>"
|
echo
|
||||||
read -pr ""
|
read -p "Press <Enter> to quit"
|
||||||
|
|
||||||
open "$dest_folder"
|
open "$dest_folder"
|
||||||
}
|
}
|
||||||
@@ -334,7 +363,7 @@ _heic() {
|
|||||||
echo -e "\n$count images were successfully converted !"
|
echo -e "\n$count images were successfully converted !"
|
||||||
|
|
||||||
echo -e "\n<Press Enter to quit>"
|
echo -e "\n<Press Enter to quit>"
|
||||||
read -pr ""
|
read -p ""
|
||||||
|
|
||||||
open "$dest_folder"
|
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
|
main
|
||||||
|
|||||||
Reference in New Issue
Block a user