JPEG is a lossy compression file format for digital images. It can greatly reduce the space used by a graphics file in comparison to the PNG format. This tutorial describes how to convert a PNG file to JPG on the shell. I will use the command line tool GraphicsMagick for this on my Ubuntu 18.04 system, the same steps will work on Debian and probably other Linux distributions as well. GraphicsMagick is an improved version of the well-known tool ImageMagick.

Install GraphicsMagick on Ubuntu

The first step is to install the Ubuntu GraphicsMagick package with apt:

sudo apt-get install graphicsmagick

Here the installation result:

Installing GrahicsMagick

Convert PNG file to JPG

Now we'll convert a PNG file to JPG, here I use a file named street.png and the new file will be saved as street.jpg. The photo is stored in the directory where I execute the command.

gm convert street.png street.jpg

Here is how the command is executed on the Linux shell:

Convert a image file from PNG to JPG

As you can see, the size has been reduced from 649KB to 71KB.  Here the result of our image file format conversion:

Converted example image

Convert JPG file to PNG

The file format conversion works in the other way as well, here I'll convert the file street.jpg to street.png.

gm convert street.jpg street.png

GraphicsMagick supports many more file formats, not just PNG and JPEG, a full list can be found here:

How to convert a PNG file to JPG on Linux
Tagged on:

One thought on “How to convert a PNG file to JPG on Linux

  • January 11, 2019 at 9:57 am

    With converseen it is much easier. It works with a grafical interface so everybody can do it.


Leave a Reply

Your email address will not be published. Required fields are marked *


Ad #native_company# — #native_desc# #native_cta#