ImageMagick convert: Change Image Formats
convert input.png output.jpg converts between image formats; ImageMagick infers both from the file extensions.
ImageMagick's convert (called magick on ImageMagick 7) is the workhorse for format conversion and batch edits in CI. The output format comes from the output extension.
What it does
convert reads one or more input images, applies any operations given between the input and output, and writes the result in the format implied by the output extension. Many formats (JPEG, PNG, WebP, PDF, TIFF) rely on external delegate libraries compiled into ImageMagick.
Common usage
# PNG to JPEG with quality
convert input.png -quality 85 output.jpg
# flatten transparency onto white (PNG -> JPG)
convert input.png -background white -flatten output.jpg
# ImageMagick 7 uses the magick wrapper
magick input.png output.webpOptions
| Flag | What it does |
|---|---|
| -quality <n> | JPEG/WebP quality 1-100 (PNG compression 0-9 in tens) |
| -flatten | Merge layers; composite transparency onto -background |
| -background <color> | Background used by -flatten / alpha removal |
| -strip | Remove profiles and metadata to shrink output |
| -density <dpi> | Rasterization DPI (matters for PDF/SVG inputs) |
| -colorspace <cs> | Convert colorspace, e.g. sRGB, Gray |
In CI
On ImageMagick 7 the legacy convert still works but prints a deprecation note; prefer magick. Add -strip to drop metadata and produce smaller, reproducible outputs across runners.
Common errors in CI
"convert: command not found" means ImageMagick is not installed; apt-get install -y imagemagick. "convert: no decode delegate for this image format WEBP'" or "no encode delegate" means the WebP/HEIC/etc. library was not compiled in; install libwebp / the full ImageMagick and re-check convert -list format. "convert: unable to open image ...': No such file or directory" is a wrong input path. For PDF inputs see the policy.xml restriction page.