When dealing with images, we may have to do several format conversions. Depending on the situation, it can be a JPG to PNG conversion, PNG to SVG conversion or anything. ImageMagick is a tool that supports most of these image format conversions along with the other operations like resizing, reducing the size, changing color scheme ..etc. In this tutorial, we will see how to convert a PNG file to JPG file. Also, we’ll check how to perform this image conversion as a batch job.

Before jumping to the details, let’s get familiar with the terms used here, ie, JPG, PNG, and ImageMagick. If you are already familiar with these, you can directly skip to the conversion part.

PNG Image Format

PNG (Portable Network Graphics) a raster image format. Raster images use a lossless image compression algorithm. In PNG format, the image will be represented as a collection of interconnected points. The quality of the image will remain unaffected on resizing.

PNG format is good for simple images PNG format is best for simple icons & shapes

PNG format can be used for any image files. However, it is more suitable for icons, symbols or small shapes which does not require a lot of points to represent. It will consume more space for complex images like photographies. So, it is better to convert complex images into other formats like JPE when we are using it on the Web.

JPG Image Format

JPG or JPEG (Joint Photographic Experts Group) is a commonly used lossy compression approach for digital photographies. It allows adjusting the compression ratio with a tradeoff between compression and quality of the image.

JPG format is suitable for complex images JPG format is good for complex shapes

With JPG format, the quality of the image reduces with compression ratio. More compression implies, less quality and less storage space requirement. This format is used for embedding photographies or complex images on websites.


ImageMagick is an open-source tool that provides advanced image manipulation functionalities to create, edit and convert images. It supports more than 200 type of image formats. ImageMagick facilitates resize, flip, rotate, distort, shear and transform of images. It also helps to apply special effects.

Commonly, ImageMagick is used as a command-line tool, which makes it suitable for batch operations. There are many GUI clients which use ImageMagick underhood for performing image manipulation operations.

How to perform PNG to JPG conversion using ImageMagick?

Now, we are familiar with PNG, JPG and ImageMagick. So, it is time to talk about the actual topic. How to perform PNG to JPG conversion.

ImageMagick provides a set of command-line tools for performing image manipulation operations. convert is one such tool in ImageMagick tool suite, that facilitate the conversion of images between various formats. It also provides options to resize an image, blur, crop, despeckle, dither, draw on, flip, join, re-sample, and much more.

You can read the complete convert tool documentation using the man pages. The man page for convert can be read using the following commands:

$ convert --help
$ man convert

The image format conversion can be done using the following command:

$ convert [original image] [converted image name]

This command can be used to convert between any valid image formats.

If we want to convert multiple jobs at once, we may use a simple batch job as follows:

for image in *.png ; 
    convert "$image" "${image%.*}.jpg" ;

That’s all for now. This post is inspired by an answer given in superuser - an affiliate of StackExange.

In case of any issues, or clarification please let me know via the comment box below.