Skip to content

Instantly share code, notes, and snippets.

@benjaminblack
Last active March 15, 2018 19:19
Show Gist options
  • Save benjaminblack/4953a8f43e71d0e61a0e9287e928ac28 to your computer and use it in GitHub Desktop.
Save benjaminblack/4953a8f43e71d0e61a0e9287e928ac28 to your computer and use it in GitHub Desktop.
ImageMagick cheat sheet

Convert a directory of PNGs to JPEGs:

for file in `ls *.png`
do
    extension="${file##*.}"
    base="${file%.*}"
    convert "$file" -quality 60 "${base}.jpg"
done

Crop transparent border around edges:

convert image -trim +repage output

Crop border around edges with fuzziness:

convert image -fuzz 1% -trim +repage output

Crop to portrait (9:16) at the center and scale down to specific height, at medium (30%) quality:

for file in `ls *.jpg`; do convert "$file" -quality 30 -gravity center -crop 608x1080+0+0 -geometry x720 "portrait/$file"; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment