Skip to content

Instantly share code, notes, and snippets.

@drewsberry
Last active September 30, 2015 10:41
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drewsberry/6c9ccdc24819b370b91c to your computer and use it in GitHub Desktop.
Save drewsberry/6c9ccdc24819b370b91c to your computer and use it in GitHub Desktop.
Batch resize png images with bash and ImageMagick
#!/bin/sh
convert_path="C:/Program Files/ImageMagick/convert.exe"
target_path="."
target_ext="png"
echo "Warning, this will overwrite the current images."
read -r -p "Do you want to continue? [y/N] " response
response=${response,,} # tolower
if [[ $response =~ ^(yes|y)$ ]]
then
for f in ${target_path}/*.${target_ext};
do
echo "Resizing ${f}..."
"$convert_path" "$f" -resize 20% "$f"
done
else
echo "Exiting..."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment