Last active
December 24, 2015 10:48
-
-
Save klmr/6786339 to your computer and use it in GitHub Desktop.
Resize input files – but only if they exceed 800px width
This file contains 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
#!/usr/bin/env bash | |
maxwidth=800 | |
resize () { | |
convert "$1" -resize $maxwidth "$2" | |
} | |
for image in large/*; do | |
width=$(identify -format '%w' "$image") | |
if [[ $width -gt $maxwidth ]]; then | |
cmd=resize | |
else | |
cmd=cp | |
fi | |
$cmd "$image" "$(basename "$image")" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment