ImageMagick Cheatsheet

Subscribe to my newsletter and never miss my upcoming articles

An ImageMagick cheatsheet with some helpful commands for working with ImageMagick on the command line. This is a work in progress that will be periodically updated and is by no means a complete list.

Resizing images

Resize a single image:

convert input.png -resize 20x20 -quality 100 output.png

Batch resize some images:

mogrify -resize 600 *.png

Replacing the background colour of a transparent PNG

For transparent PNG, you can add a background colour.

convert source.png -background '#ff3399' -flatten destination.png

Or overwrite all images in a directory:

mogrify -background 'dodgerblue' -flatten *.png

Rounded corners

You can round the corners of an image with the following script:

convert input.png -alpha set -virtual-pixel transparent -channel A -blur 0x8  -threshold 50% +channel output.png

And you can batch round the corners of images using the following:

mogrify -alpha set -virtual-pixel transparent -channel A -blur 0x8  -threshold 50% +channel *.png

No Comments Yet