Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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