Last active
September 30, 2015 10:41
-
-
Save drewsberry/6c9ccdc24819b370b91c to your computer and use it in GitHub Desktop.
Batch resize png images with bash and ImageMagick
This file contains hidden or 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
#!/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