Skip to content

Instantly share code, notes, and snippets.

@cristianobecker
Created March 6, 2015 17:03
Show Gist options
  • Save cristianobecker/9ce80d3e8fc83a1d43fc to your computer and use it in GitHub Desktop.
Save cristianobecker/9ce80d3e8fc83a1d43fc to your computer and use it in GitHub Desktop.
Edit multiple images with imagemagik (resize, optimize and thumbnail)
# RESIZE AND OPTIMIZE (based in height)
HEIGHT=500
mkdir -p result
for f in *.jpg; do
convert "$f" -resize "x${HEIGHT}" -strip -quality 90% "result/$f"
done
# THUMB
WIDTH=200
HEIGHT=225
mkdir -p thumb
for f in *.jpg; do
convert "$f" -strip -quality 90% -resize "${WIDTH}x${HEIGHT}^" -gravity center -crop "${WIDTH}x${HEIGHT}+0+0" "thumb/$f"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment