ImageMagick converts images to JPG from the command line with precise control over output quality, transparency handling, and metadata stripping. The main search phrase convert image to jpg command line covers both single-file conversion and batch operations across whole folders. For developers and power users processing many images, it beats clicking through a GUI every time.

Understanding ImageMagick Versions

ImageMagick 7 uses the magick command for all operations. To convert a single file, run magick input.png output.jpg. Version 6 uses convert instead. On Windows, a built-in convert.exe disk utility can conflict with the older naming, which is one reason version 7 switched to magick. If you are on Windows and using version 6, call the executable by its full path or rename it. The commands below assume version 7; if you are on version 6, swap magick for convert.

Converting a Single Image to JPG

Basic Single File Conversion

Start with one file. If your source is a PNG, run:

magick input.png output.jpg

The toolkit reads the input format and writes the output as JPG based on the file extension. Add a quality setting to control the output. The -quality option sets JPEG quality on a 0-100 scale. A value of 85 balances file size and visual fidelity:

magick input.png -quality 85 output.jpg

Stripping Metadata

To remove EXIF data and comments from the output, add -strip:

magick input.png -strip output.jpg

Batch Converting a Folder of Images

Using the Batch Tool

For many files, use mogrify instead of looping magick. To batch convert all PNG files in the current folder to JPG:

magick mogrify -format jpg *.png

This writes a .jpg copy of every PNG and leaves the originals in place. The *.png wildcard matches every file with that extension. Swap in any other pattern, such as *.tif or *.bmp. The batch tool needs no output filename; it reuses the original name with the new extension.

Combining Quality and Metadata Flags

Add quality and strip flags to the batch command. To convert all PNGs to JPG with quality 85 and stripped metadata:

magick mogrify -format jpg -quality 85 -strip *.png

Handling Transparency in JPG Conversion

JPG does not support alpha channels. If your source image has transparent areas, fill them with a solid color before saving. Without this step, transparent pixels may turn black. Control the fill with -background white -flatten.

Single File Transparency Fix

For one file:

magick input.png -background white -flatten output.jpg

Batch Transparency Fix

For a folder:

magick mogrify -format jpg -background white -flatten *.png

Replace white with any color name or hex code, such as black or light gray. Do this whenever your source images have partial transparency or alpha masks you want rendered against a specific backdrop.

Adjusting JPEG Quality in Detail

The quality flag accepts a single number from 0 to 100. Lower numbers produce smaller files with more compression artifacts. Higher numbers retain more detail at the cost of larger file sizes. A value of 85 works well for most web and archive use.

Apply quality settings in both single-file and batch commands:

  • Single file: magick input.png -quality 85 output.jpg
  • Batch: magick mogrify -format jpg -quality 85 *.png

If you omit the flag, the toolkit uses its internal default, around the high end of the scale. Test different values on a representative sample of your images to find the right balance for your project.

Inspecting Image Properties Before Conversion

Before converting many files, check their current format, dimensions, and color space. Use the identify command:

magick identify file.jpg

The output prints the format, dimensions, and colour space:

file.jpg JPEG sRGB

Run identify on multiple files at once with magick identify *.png. This verifies that your source images share the same size or color mode before batch operations. To strip metadata after conversion, add -strip to the conversion command as shown earlier.

Common Workflow Examples

Ready To Run Commands

  1. Convert a single PNG to JPG with quality 85 and white background for transparency. magick input.png -background white -flatten -quality 85 output.jpg
  2. Batch convert all PNGs in a folder to JPG, quality 85, strip metadata. magick mogrify -format jpg -quality 85 -strip *.png
  3. Batch convert all TIFFs to JPG with white background. magick mogrify -format jpg -background white -flatten *.tif
  4. Check the details of a JPG file. magick identify file.jpg

Version 6 And Windows Notes

On ImageMagick 6, replace magick with convert for single-file conversions and keep mogrify for batch operations. On Windows, check that you are not accidentally running the system convert.exe when using version 6.

For a graphical interface instead of the command line, jpgconverter.co converts images to JPG online without installing software.