Skip to content

Instantly share code, notes, and snippets.

@klmr
Last active December 24, 2015 10:48
Show Gist options
  • Save klmr/6786339 to your computer and use it in GitHub Desktop.
Save klmr/6786339 to your computer and use it in GitHub Desktop.
Resize input files – but only if they exceed 800px width
#!/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