imagemagick(1)
ImageMagick is a suite of command-line tools for creating, editing, and converting images in batch or interactively.
Synopsis
convert [options] input-file output-file
identify [options] image-file
mogrify [options] image-file
display [options] image-file
compose [options] image1 image2 output-fileDescription
ImageMagick provides powerful command-line utilities to manipulate images: convert transforms images between formats and applies effects, identify reports image properties, mogrify modifies images in-place, display views images, and compose blends multiple images. It supports over 200 image formats including JPEG, PNG, GIF, PDF, and SVG.
Most operations are performed through the convert command, which applies transformations left-to-right and writes the result to a new file. ImageMagick excels at batch processing, format conversion, resizing, rotation, color manipulation, and complex image compositing.
Common options
| Flag | What it does |
|---|---|
-resize WIDTHxHEIGHT | Resize image to specified dimensions, preserving aspect ratio with > |
-quality PERCENT | Set JPEG/PNG quality (1-100, default 92) |
-format FORMAT | Output file format (jpg, png, gif, webp, pdf, etc.) |
-rotate DEGREES | Rotate image by specified degrees (positive is clockwise) |
-crop WIDTHxHEIGHT+X+Y | Crop image to specified size at offset position |
-strip | Remove all metadata and comments from image |
-gravity DIRECTION | Set reference point for cropping/positioning (North, South, Center, etc.) |
-background COLOR | Set background color for transparent areas or effects |
-colorspace SPACE | Convert between color spaces (RGB, Gray, CMYK, HSL, etc.) |
-density DPI | Set resolution for PDF/vector input (default 72) |
-flatten | Merge all layers into single image with background |
-verbose | Print detailed processing information |
Examples
Resize JPEG to 800x600 pixels, maintaining aspect ratio
convert input.jpg -resize 800x600 output.jpgConvert PNG to JPEG with 85% quality
convert input.png -quality 85 output.jpgDisplay detailed information about image dimensions, color space, DPI, and metadata
identify -verbose photo.jpgRotate image 90 degrees clockwise, then crop to 1000x1000 starting at pixel (100,50)
convert input.jpg -rotate 90 -crop 1000x1000+100+50 output.jpgResize all JPEGs in current directory to 200x200 in-place with 80% quality
mogrify -resize 200x200 -quality 80 *.jpgExtract first page of PDF at 150 DPI and convert to high-quality JPEG
convert input.pdf[0] -density 150 -quality 90 page1.jpgConvert PNG with transparency to JPEG by flattening against white background
convert image.png -background white -flatten output.jpgConvert to grayscale and enhance contrast by stretching to full range
convert input.jpg -colorspace Gray -contrast-stretch 0 output.jpg