Skip to content

Instantly share code, notes, and snippets.

@franckweb
Last active April 25, 2020 13:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save franckweb/576b8c98ba8e72a4b31e8a8921ba0fab to your computer and use it in GitHub Desktop.
Save franckweb/576b8c98ba8e72a4b31e8a8921ba0fab to your computer and use it in GitHub Desktop.
Convert optimize resize multiple images through bash script
# 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