ImageMagick is an open-source suite of command line tools for manipulating digital images. It is useful for batch processing a large number of images, or to quickly perform precise image modification tasks.
ImageMagick can be downloaded from its official website, ImageMagick.org.
Development of ImageMagick began in 1987, authored by software engineer John Cristy. Today, ImageMagick is a default component of many Linux and BSD operating systems, and is freely available for Microsoft Windows, macOS, and iOS.
Features and tools
ImageMagick's features are divided into individual tools, each with their own command.
|animate||Display an image sequence as an animation.|
|compare||Analyze two images, and visualize mathematical differences between them.|
|composite||Compose one image over another with variable transparency to create a composite image.|
|conjure||Interpret and execute scripts written in MSL, the Magick Scripting Language.|
|convert||Convert images from one file format to another. This tool can also blur, crop, despeckle, dither, and otherwise modify the content of an image.|
|display||A simple image viewer.|
|identify||Display the image dimensions, quality, and other image metadata.|
|import||Capture the screen to an image file.|
|mogrify||Modify an image. Similar to convert, but overwrites the original image.|
|montage||Create an image composed of smaller images. This command can be used to create a single image containing thumbnails of many images.|
|stream||Process image data and store it to a file as it is being streamed from an input source. Useful for situations with slow data streams, or very large images whose data processing should begin before the entire image is stored.|
In version 7 of ImageMagick, these tools can be accessed with the magick command, for example magick compare. Also, the script interpreter can be accessed with magick-script.
The commands animate, display, and import require an X server (the X Window System) to function. If you're not using Linux or BSD, you can run these commands on macOS with XQuartz, or on Microsoft Windows with VcXsrv.
The following are sample commands you can use with ImageMagick.
Example 1: Resize image, specify image quality
convert myimage.jpg -resize 25% -quality 92 output1.jpg
Reduce the image size by 25%, and save it at 92% image quality, as the file output1.jpg.
Example 2: Scale and rotate image data
convert input.jpg -distort SRT .5,135 output2.jpg
Use the -distort SRT (scale, rotate, translate) distortion type to scale the image 50%, and rotate it 135 degrees clockwise. The dimensions of the final image remain the same, padded with the default color white.
Example 3: Add a swirl effect, resize
convert input.jpg -swirl 720 -resize 120% output3.jpg
Swirl the image 720 degrees and resize it to 120%.
Example 4: Create a montage of image thumbnails
montage -label '%f' input.jpg output*.jpg -frame 3 -background '#2B81EE' montage.jpg
Create an image with thumbnails of input.jpg and all output images (using the wildcard *). The options specify a file name label, a frame of 3 pixels, a blue background color, and the output file name montage.jpg. Each thumbnail is scaled differently.
Example 5: View file metadata
Display file data for all jpg images in the current directory.
input.jpg JPEG 200x200 200x200+0+0 8-bit sRGB 17.5KB 0.000u 0:00.000
montage.jpg JPEG 268x296 268x296+0+0 8-bit sRGB 26.1KB 0.000u 0:00.000
output1.jpg JPEG 50x50 50x50+0+0 8-bit sRGB 2.99KB 0.000u 0:00.000
output2.jpg JPEG 200x200 100x100+0+0 8-bit sRGB 10.4KB 0.000u 0:00.000
output3.jpg JPEG 240x240 240x240+0+0 8-bit sRGB 37.1KB 0.000u 0:00.000
Documentation and additional information
ImageMagick documentation, including extensive examples, can be found at http://www.imagemagick.org/Usage/.
In 2016, major security vulnerabilities were discovered in the way ImageMagick processes file names. Nicknamed "ImageTragick," these security holes potentially allowed RCE (remote code execution) by an attacker on the server. Thousands of websites were affected, but the vulnerabilities were quickly mitigated and patched.