Some ImageMagick Commands

File type conversion

magick logo.png favicon.ico

# Get first frame of a video
magick video.mp4[2] frame_2.jpg

Can also be used as magick convert x.png y.png. More info here.

Resize an image

magick old.png -resize x400 new.png      # height 400px, preserves aspect ratio
magick old.png -resize 1000 new.png      # width 1000px, preserves aspect ratio

Several more options on the image “geometry” (the x400 arg) are listed in the documentation. More info here.

Some other analysis tools

identify outputs an image’s format and characteristics, e.g. its dimensions.

magick identify image.png
magick identify -verbose image.png

compare compares two images and outputs a difference analysis to a third image. The red areas of the output image highlights pixels that are different. Whitened areas are similar.

magick compare a.jpg b.jpg diff-output.png

Use the -metric option to print a numeric measure of the two images’ similarity.

magick compare -metric SSIM a.jpg b.jpg diff-output.png
# 0.215678

The output of SSIM ranges from 0 (completely different) to 1 (identical). Other metrics available include AE and DSSIM.

Filters

Inversion:

magick input.png output.png
# if an alpha channel is present (i.e. has transparency)
magick input.png -channel RGB -negate output.png


other magick options and tools