ImageMagick is an open-source suite of command line tools for manipulating digital images. It is useful for batch processing numerous images, or to quickly perform precise image modification tasks.
ImageMagick can be downloaded from its official website, ImageMagick.org.
History
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.
- History.
- Features and tools.
- Example commands.
- Documentation and additional information.
Features and tools
ImageMagick’s features are divided into individual tools, each with a command.
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.
Example commands
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
identify *.jpg
Display file data for all jpg images in the current directory.
input.jpg[1] JPEG 200x200 200x200+0+0 8-bit sRGB 17.5KB 0.000u 0:00.000
montage.jpg[3] JPEG 268x296 268x296+0+0 8-bit sRGB 26.1KB 0.000u 0:00.000
output1.jpg[4] JPEG 50x50 50x50+0+0 8-bit sRGB 2.99KB 0.000u 0:00.000
output2.jpg[5] JPEG 200x200 100x100+0+0 8-bit sRGB 10.4KB 0.000u 0:00.000
output3.jpg[6] JPEG 240x240 240x240+0+0 8-bit sRGB 37.1KB 0.000u 0:00.000
Documentation and additional information
ImageMagick documentation, including extensive examples, is on their official website.
2016 Vulnerability
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.
A complete list of CVEs for ImageMagic is located at CVEDetails.com.
Command line, Digital image, Script, Software terms