Skip to content

Instantly share code, notes, and snippets.

@antonfisher
Created July 10, 2020 06:18
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 antonfisher/6a6c632fc805a6d6e7bf1fac25dea970 to your computer and use it in GitHub Desktop.
Save antonfisher/6a6c632fc805a6d6e7bf1fac25dea970 to your computer and use it in GitHub Desktop.
Resize all found images greater then some width
#!/usr/bin/env bash
MAX_WIDTH=800
echo "Looking for images..."
find . -name "*.png" -o -name "*.jpg" -o -name "*.jpeg" |
while read name; do
width=$(identify -format "%w" "$name")
if [ "$width" -gt "$MAX_WIDTH" ]; then
convert ${name} -verbose -resize $MAX_WIDTH ${name}
fi
done
echo "Done."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment