Last active
April 25, 2020 13:39
-
-
Save franckweb/576b8c98ba8e72a4b31e8a8921ba0fab to your computer and use it in GitHub Desktop.
Convert optimize resize multiple images through bash script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# USAGE | |
# bash bulk-image-process.sh [path/to/images] | |
# current exec folder is used as destination | |
destination_dir=$(pwd) | |
source_dir=$1 | |
for photo in $source_dir/*.jpg; | |
do | |
lowercase_path=${photo,,} | |
filename=$(basename $lowercase_path) | |
destinationpath="${destination_dir}/converted-${filename}" | |
convert \ | |
-verbose \ | |
"$photo" \ | |
-quality 75% \ | |
-resize 800x600 \ | |
-background white \ | |
-gravity center \ | |
-extent 800x600 \ | |
-transparent white \ | |
"${destinationpath}"; | |
done | |
## REQUIREMENT | |
# check if you have ImageMagick installed with | |
# convert --version |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment