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 magick – magick 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.jpgconvert <input> -quality <n> <output> — Convert with specific quality (1-100, for JPEG/WebP).
convert photo.png -quality 85 photo.jpgconvert <input> -define webp:lossless=true <output> — Convert to lossless WebP.
convert photo.png -define webp:lossless=true photo.webpconvert <input> -define png:compression-level=9 <output> — Convert to PNG with maximum compression.
convert photo.bmp -define png:compression-level=9 photo.pngconvert <input>[0] <output> — Extract first frame/page from multi-frame image or PDF.
convert animation.gif[0] first-frame.pngResize & Scale
convert <input> -resize <width>x<height> <output> — Resize to fit within dimensions (maintains aspect ratio).
convert photo.jpg -resize 800x600 thumb.jpgconvert <input> -resize <width>x<height>! <output> — Force exact dimensions (ignores aspect ratio).
convert photo.jpg -resize 800x600! stretched.jpgconvert <input> -resize <width>x<height>^ <output> — Resize to fill dimensions (may exceed one dimension).
convert photo.jpg -resize 800x600^ -gravity center -extent 800x600 cover.jpgconvert <input> -resize 50% <output> — Resize by percentage.
convert photo.jpg -resize 50% half.jpgconvert <input> -resize <width> <output> — Resize to a specific width (auto height).
convert photo.jpg -resize 800 resized.jpgconvert <input> -resize x<height> <output> — Resize to a specific height (auto width).
convert photo.jpg -resize x600 resized.jpgconvert <input> -thumbnail <width>x<height> <output> — Create a thumbnail (strips metadata, faster than resize).
convert photo.jpg -thumbnail 150x150 thumb.jpgCrop & Trim
convert <input> -crop <width>x<height>+<x>+<y> <output> — Crop a region at specific offset.
convert photo.jpg -crop 400x300+100+50 cropped.jpgconvert <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.jpgconvert <input> -trim <output> — Remove borders/whitespace around the image.
convert logo.png -trim trimmed.pngconvert <input> -fuzz <n>% -trim <output> — Trim with color tolerance for near-matching borders.
convert logo.png -fuzz 10% -trim trimmed.pngconvert <input> -shave <x>x<y> <output> — Remove pixels from all edges.
convert photo.jpg -shave 20x20 shaved.jpgRotate & Flip
convert <input> -rotate <degrees> <output> — Rotate the image by specified degrees.
convert photo.jpg -rotate 90 rotated.jpgconvert <input> -auto-orient <output> — Auto-rotate based on EXIF orientation data.
convert photo.jpg -auto-orient corrected.jpgconvert <input> -flip <output> — Flip vertically (top to bottom).
convert photo.jpg -flip flipped.jpgconvert <input> -flop <output> — Flip horizontally (left to right).
convert photo.jpg -flop flopped.jpgconvert <input> -transpose <output> — Mirror along top-left to bottom-right diagonal.
convert photo.jpg -transpose transposed.jpgColor Adjustments
convert <input> -colorspace Gray <output> — Convert to grayscale.
convert photo.jpg -colorspace Gray grayscale.jpgconvert <input> -modulate <brightness>,<saturation>,<hue> <output> — Adjust brightness, saturation, and hue (100 = unchanged).
convert photo.jpg -modulate 120,130,100 vibrant.jpgconvert <input> -brightness-contrast <b>x<c> <output> — Adjust brightness and contrast (-100 to +100).
convert photo.jpg -brightness-contrast 10x20 adjusted.jpgconvert <input> -negate <output> — Invert all colors (create a negative).
convert photo.jpg -negate negative.jpgconvert <input> -level <black>%,<white>% <output> — Adjust levels (set black/white points).
convert photo.jpg -level 10%,90% adjusted.jpgconvert <input> -normalize <output> — Auto-stretch contrast to full range.
convert photo.jpg -normalize normalized.jpgconvert <input> -equalize <output> — Equalize histogram for better contrast.
convert photo.jpg -equalize equalized.jpgconvert <input> -colorspace CMYK <output> — Convert to CMYK colorspace (for print).
convert photo.jpg -colorspace CMYK print-ready.tiffEffects & Filters
convert <input> -blur 0x<sigma> <output> — Apply Gaussian blur.
convert photo.jpg -blur 0x3 blurred.jpgconvert <input> -sharpen 0x<sigma> <output> — Sharpen the image.
convert photo.jpg -sharpen 0x1.5 sharp.jpgconvert <input> -unsharp <radius>x<sigma>+<amount>+<threshold> <output> — Apply unsharp mask for precise sharpening.
convert photo.jpg -unsharp 0x1+1+0.05 sharp.jpgconvert <input> -sepia-tone 80% <output> — Apply a sepia tone effect.
convert photo.jpg -sepia-tone 80% sepia.jpgconvert <input> -vignette 0x<sigma> <output> — Add a vignette (darkened edges).
convert photo.jpg -vignette 0x20 vignette.jpgconvert <input> -charcoal <radius> <output> — Apply a charcoal sketch effect.
convert photo.jpg -charcoal 2 sketch.jpgconvert <input> -edge <radius> <output> — Detect edges in the image.
convert photo.jpg -edge 1 edges.jpgconvert <input> -emboss <radius> <output> — Apply an emboss effect.
convert photo.jpg -emboss 2 embossed.jpgText & 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.jpgconvert -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.pngconvert <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.jpgMetadata & Optimization
convert <input> -strip <output> — Remove all metadata (EXIF, ICC profiles, comments).
convert photo.jpg -strip clean.jpgconvert <input> -interlace Plane <output> — Create a progressive/interlaced image.
convert photo.jpg -interlace Plane progressive.jpgconvert <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.jpgconvert <input> -colors <n> <output> — Reduce the number of colors.
convert photo.png -colors 256 reduced.pngconvert <input> -depth <bits> <output> — Set the bit depth (8, 16, etc.).
convert photo.png -depth 8 8bit.pngCreate & Generate
convert -size <w>x<h> xc:<color> <output> — Create a solid color canvas.
convert -size 800x600 xc:#336699 canvas.pngconvert -size <w>x<h> gradient:<from>-<to> <output> — Create a vertical gradient.
convert -size 800x600 gradient:blue-white gradient.pngconvert -size <w>x<h> plasma: <output> — Create a random plasma fractal.
convert -size 800x600 plasma: plasma.jpgconvert -size <w>x<h> pattern:<name> <output> — Create a tiled pattern (checkerboard, hexagons, etc.).
convert -size 800x600 pattern:checkerboard checkers.pngconvert <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.pngAnimation (GIF)
convert -delay <ticks> <frame1> <frame2> ... <output> — Create an animated GIF from frames (delay in 1/100s).
convert -delay 20 frame-*.png animation.gifconvert <input> -coalesce <output> — Reconstruct all frames to full images (undo optimizations).
convert animation.gif -coalesce frames.gifconvert <input> -layers Optimize <output> — Optimize GIF animation for smaller file size.
convert animation.gif -layers Optimize optimized.gifconvert <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
- ImageMagick: Command-line Tools – official reference for convert, magick and mogrify
- ImageMagick: Command-line Options – full list of options such as -resize, -quality and -strip
- Wikipedia: ImageMagick – overview of features, history and supported formats