convert — Convert and Edit Images (ImageMagick)

Practical guide to convert: transform images between formats, resize, crop, rotate, adjust colors and apply effects with ImageMagick (in v7: magick).

convert is the Swiss Army knife of ImageMagick: a single command that transforms images between dozens of formats, scales, crops, rotates, adjusts colors, applies effects and even renders PDF pages. In ImageMagick 7, convert is deprecated in favor of magickmagick input.png output.jpg is the modern form, and the classic convert calls it internally and stays compatible for now. This guide walks you through the invocations you actually reach for daily, from a quick format swap to web optimization.

Format Conversion

convert <input> <output> — Convert an image to another format (determined by extension).

convert photo.png photo.jpg

convert <input> -quality <n> <output> — Convert with specific quality (1-100, for JPEG/WebP).

convert photo.png -quality 85 photo.jpg

convert <input> -define webp:lossless=true <output> — Convert to lossless WebP.

convert photo.png -define webp:lossless=true photo.webp

convert <input> -define png:compression-level=9 <output> — Convert to PNG with maximum compression.

convert photo.bmp -define png:compression-level=9 photo.png

convert <input>[0] <output> — Extract first frame/page from multi-frame image or PDF.

convert animation.gif[0] first-frame.png

Resize & Scale

convert <input> -resize <width>x<height> <output> — Resize to fit within dimensions (maintains aspect ratio).

convert photo.jpg -resize 800x600 thumb.jpg

convert <input> -resize <width>x<height>! <output> — Force exact dimensions (ignores aspect ratio).

convert photo.jpg -resize 800x600! stretched.jpg

convert <input> -resize <width>x<height>^ <output> — Resize to fill dimensions (may exceed one dimension).

convert photo.jpg -resize 800x600^ -gravity center -extent 800x600 cover.jpg

convert <input> -resize 50% <output> — Resize by percentage.

convert photo.jpg -resize 50% half.jpg

convert <input> -resize <width> <output> — Resize to a specific width (auto height).

convert photo.jpg -resize 800 resized.jpg

convert <input> -resize x<height> <output> — Resize to a specific height (auto width).

convert photo.jpg -resize x600 resized.jpg

convert <input> -thumbnail <width>x<height> <output> — Create a thumbnail (strips metadata, faster than resize).

convert photo.jpg -thumbnail 150x150 thumb.jpg

Crop & Trim

convert <input> -crop <width>x<height>+<x>+<y> <output> — Crop a region at specific offset.

convert photo.jpg -crop 400x300+100+50 cropped.jpg

convert <input> -gravity center -crop <width>x<height>+0+0 <output> — Crop from the center of the image.

convert photo.jpg -gravity center -crop 400x300+0+0 center.jpg

convert <input> -trim <output> — Remove borders/whitespace around the image.

convert logo.png -trim trimmed.png

convert <input> -fuzz <n>% -trim <output> — Trim with color tolerance for near-matching borders.

convert logo.png -fuzz 10% -trim trimmed.png

convert <input> -shave <x>x<y> <output> — Remove pixels from all edges.

convert photo.jpg -shave 20x20 shaved.jpg

Rotate & Flip

convert <input> -rotate <degrees> <output> — Rotate the image by specified degrees.

convert photo.jpg -rotate 90 rotated.jpg

convert <input> -auto-orient <output> — Auto-rotate based on EXIF orientation data.

convert photo.jpg -auto-orient corrected.jpg

convert <input> -flip <output> — Flip vertically (top to bottom).

convert photo.jpg -flip flipped.jpg

convert <input> -flop <output> — Flip horizontally (left to right).

convert photo.jpg -flop flopped.jpg

convert <input> -transpose <output> — Mirror along top-left to bottom-right diagonal.

convert photo.jpg -transpose transposed.jpg

Color Adjustments

convert <input> -colorspace Gray <output> — Convert to grayscale.

convert photo.jpg -colorspace Gray grayscale.jpg

convert <input> -modulate <brightness>,<saturation>,<hue> <output> — Adjust brightness, saturation, and hue (100 = unchanged).

convert photo.jpg -modulate 120,130,100 vibrant.jpg

convert <input> -brightness-contrast <b>x<c> <output> — Adjust brightness and contrast (-100 to +100).

convert photo.jpg -brightness-contrast 10x20 adjusted.jpg

convert <input> -negate <output> — Invert all colors (create a negative).

convert photo.jpg -negate negative.jpg

convert <input> -level <black>%,<white>% <output> — Adjust levels (set black/white points).

convert photo.jpg -level 10%,90% adjusted.jpg

convert <input> -normalize <output> — Auto-stretch contrast to full range.

convert photo.jpg -normalize normalized.jpg

convert <input> -equalize <output> — Equalize histogram for better contrast.

convert photo.jpg -equalize equalized.jpg

convert <input> -colorspace CMYK <output> — Convert to CMYK colorspace (for print).

convert photo.jpg -colorspace CMYK print-ready.tiff

Effects & Filters

convert <input> -blur 0x<sigma> <output> — Apply Gaussian blur.

convert photo.jpg -blur 0x3 blurred.jpg

convert <input> -sharpen 0x<sigma> <output> — Sharpen the image.

convert photo.jpg -sharpen 0x1.5 sharp.jpg

convert <input> -unsharp <radius>x<sigma>+<amount>+<threshold> <output> — Apply unsharp mask for precise sharpening.

convert photo.jpg -unsharp 0x1+1+0.05 sharp.jpg

convert <input> -sepia-tone 80% <output> — Apply a sepia tone effect.

convert photo.jpg -sepia-tone 80% sepia.jpg

convert <input> -vignette 0x<sigma> <output> — Add a vignette (darkened edges).

convert photo.jpg -vignette 0x20 vignette.jpg

convert <input> -charcoal <radius> <output> — Apply a charcoal sketch effect.

convert photo.jpg -charcoal 2 sketch.jpg

convert <input> -edge <radius> <output> — Detect edges in the image.

convert photo.jpg -edge 1 edges.jpg

convert <input> -emboss <radius> <output> — Apply an emboss effect.

convert photo.jpg -emboss 2 embossed.jpg

Text & Annotations

convert <input> -gravity south -annotate +0+10 "<text>" <output> — Add text annotation at a position.

convert photo.jpg -gravity south -fill white -pointsize 24 -annotate +0+10 "© 2026" annotated.jpg

convert -size <w>x<h> xc:<color> -font <font> -pointsize <n> -fill <color> -annotate +<x>+<y> "<text>" <output> — Create an image from text.

convert -size 400x100 xc:white -font Arial -pointsize 36 -fill black -annotate +10+50 "Hello World" text.png

convert <input> -fill <color> -draw "rectangle <x1>,<y1> <x2>,<y2>" <output> — Draw a filled rectangle on the image.

convert photo.jpg -fill "rgba(0,0,0,0.5)" -draw "rectangle 0,400 800,500" overlay.jpg

Metadata & Optimization

convert <input> -strip <output> — Remove all metadata (EXIF, ICC profiles, comments).

convert photo.jpg -strip clean.jpg

convert <input> -interlace Plane <output> — Create a progressive/interlaced image.

convert photo.jpg -interlace Plane progressive.jpg

convert <input> -sampling-factor 4:2:0 -quality 85 -strip <output> — Optimize JPEG for web (smaller file size).

convert photo.jpg -sampling-factor 4:2:0 -quality 85 -interlace Plane -strip optimized.jpg

convert <input> -colors <n> <output> — Reduce the number of colors.

convert photo.png -colors 256 reduced.png

convert <input> -depth <bits> <output> — Set the bit depth (8, 16, etc.).

convert photo.png -depth 8 8bit.png

Create & Generate

convert -size <w>x<h> xc:<color> <output> — Create a solid color canvas.

convert -size 800x600 xc:#336699 canvas.png

convert -size <w>x<h> gradient:<from>-<to> <output> — Create a vertical gradient.

convert -size 800x600 gradient:blue-white gradient.png

convert -size <w>x<h> plasma: <output> — Create a random plasma fractal.

convert -size 800x600 plasma: plasma.jpg

convert -size <w>x<h> pattern:<name> <output> — Create a tiled pattern (checkerboard, hexagons, etc.).

convert -size 800x600 pattern:checkerboard checkers.png

convert <input> -alpha set -background none -channel A -evaluate set <n>% <output> — Set uniform transparency level.

convert logo.png -alpha set -background none -channel A -evaluate set 50% semi-transparent.png

Animation (GIF)

convert -delay <ticks> <frame1> <frame2> ... <output> — Create an animated GIF from frames (delay in 1/100s).

convert -delay 20 frame-*.png animation.gif

convert <input> -coalesce <output> — Reconstruct all frames to full images (undo optimizations).

convert animation.gif -coalesce frames.gif

convert <input> -layers Optimize <output> — Optimize GIF animation for smaller file size.

convert animation.gif -layers Optimize optimized.gif

convert <input> -loop <n> <output> — Set GIF loop count (0 = infinite).

convert -delay 50 frame-*.png -loop 0 animation.gif

Conclusion

convert covers nearly every image operation you need on the command line – batch conversion, resizing for the web or quick effects. Keep in mind that the classic convert is deprecated under ImageMagick 7: for new scripts, magick input.png output.jpg is the recommended form, and magick mogrify edits whole directories in place. convert overwrites the destination file silently, so never accidentally pass the same path as both input and output. Use -strip to remove metadata (EXIF, GPS, ICC) before publishing. Security note: processing PDF, PS and SVG files historically relied on Ghostscript and has repeatedly been an attack surface, which is why ImageMagick restricts risky formats via policy.xml. Handle untrusted image files with care and only loosen the policy deliberately.

Further Reading

  • mogrify – batch-edit and convert images in place
  • identify – read format, dimensions and metadata of images
  • composite – overlay and merge images into one