$linuxjunkies
>

imagemagick(1)

ImageMagick is a suite of command-line tools for creating, editing, and converting images in batch or interactively.

UbuntuDebianFedoraArch

Synopsis

convert [options] input-file output-file
identify [options] image-file
mogrify [options] image-file
display [options] image-file
compose [options] image1 image2 output-file

Description

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

FlagWhat it does
-resize WIDTHxHEIGHTResize image to specified dimensions, preserving aspect ratio with >
-quality PERCENTSet JPEG/PNG quality (1-100, default 92)
-format FORMATOutput file format (jpg, png, gif, webp, pdf, etc.)
-rotate DEGREESRotate image by specified degrees (positive is clockwise)
-crop WIDTHxHEIGHT+X+YCrop image to specified size at offset position
-stripRemove all metadata and comments from image
-gravity DIRECTIONSet reference point for cropping/positioning (North, South, Center, etc.)
-background COLORSet background color for transparent areas or effects
-colorspace SPACEConvert between color spaces (RGB, Gray, CMYK, HSL, etc.)
-density DPISet resolution for PDF/vector input (default 72)
-flattenMerge all layers into single image with background
-verbosePrint detailed processing information

Examples

Resize JPEG to 800x600 pixels, maintaining aspect ratio

convert input.jpg -resize 800x600 output.jpg

Convert PNG to JPEG with 85% quality

convert input.png -quality 85 output.jpg

Display detailed information about image dimensions, color space, DPI, and metadata

identify -verbose photo.jpg

Rotate image 90 degrees clockwise, then crop to 1000x1000 starting at pixel (100,50)

convert input.jpg -rotate 90 -crop 1000x1000+100+50 output.jpg

Resize all JPEGs in current directory to 200x200 in-place with 80% quality

mogrify -resize 200x200 -quality 80 *.jpg

Extract first page of PDF at 150 DPI and convert to high-quality JPEG

convert input.pdf[0] -density 150 -quality 90 page1.jpg

Convert PNG with transparency to JPEG by flattening against white background

convert image.png -background white -flatten output.jpg

Convert to grayscale and enhance contrast by stretching to full range

convert input.jpg -colorspace Gray -contrast-stretch 0 output.jpg

Related commands