ImageMagick is a magical command-line tool to manipulate graphics.


Create or modify an image and save to a new file.
Modify an image in place.



-resize 64
Resize to a width of 64 pixels.
-resize 64x64
Resize to fit into 64×64 (i.e. 64 on the larger dimension).
-resize 64x64^
Resize to fill 64×64 (i.e. 64 on the smaller dimension).
-resize '64x64!'
Resize to exactly 64×64, ignoring aspect ratio.
-resize '64x64>'
Shrink to fit 64×64, unless the original is smaller.
-resize '64x64<'
Enlarge to fit 64×64, unless the original is larger.
-resize 50%
Resize to approximately 50% of the original size.
-resize 4096@
Resize to contain no more than 4,096 pixels.

Double the size of an image with nearest-neighbour resizing:

convert 'in.png' -filter point -resize 200% 'out.png'

Unsharp before shrinking an image:

convert 'input.png' -unsharp 0x5 -resize 64x64 'output.png'

Add space around an image

You can directly adjust the size of an image using -extent. For example, to expand an image from 190×190 to 200×200 pixels (adding 5 pixels of transparency on each side):

convert input.png -background transparent \
    -gravity center -extent 200x200 output.png


Use a 1-bit colour palette:

convert input.png -colors 2 -depth 1 -type palette PNG8:output.png

Use an 8-bit colour palette with transparency:

convert input.png -depth 8 -type palettealpha PNG8:output.png

Generate a colour palette from an image:

convert input.png -unique-colors palette.png

Apply a palette to another image:

convert input.png -remap palette.png output.png


Ordered dither:

convert input.png -ordered-dither o4x4,5 output.png