1. Home
  2. Linux
  3. Convert png to jpg linux

How to convert PNG to JPG on Linux

Got some PNG image files you need to convert to JPG lying around on your Linux PC? Don’t know the first thing about converting image formats? We can help! Follow along with this guide as we go over how to convert PNG image files to JPG on Linux!

convert PNG to JPG on Linux

Installing ImageMagick on Linux

There are many ways to convert PNG files to JPG files on Linux, but the fastest and best way is to use ImageMagick, a command-line utility that can convert images, including PNG ones.

ImageMagick finds its way on many Linux users’ PCs, as many of the apps that people use tend to rely on ImageMagick one way or the other. However, we still need to go over how to install this software on Linux before continuing. 

The ImageMagick program is supported on all Linux operating systems. To start the installation, open up a terminal window by pressing Ctrl + Alt + T on the keyboard. Or, search for “Terminal” in the app menu and launch it that way.

Once the terminal window is open, follow along with the installation instructions that correspond to the Linux operating system that you use on your PC.

Ubuntu

On Ubuntu Linux, you can install the ImageMagick application on your computer with the following apt install command below.

sudo apt install imagemagick

Debian

If you’re using Debian, you’ll be able to get a fairly recent version of ImageMagick up and running on your system with the apt-get install command below.

sudo apt-get install imagemagick

Arch Linux

Those using Arch Linux will be able to get the ImageMagick application up and running on their systems by entering the pacman command below.

sudo pacman -S imagemagick

Fedora

Are you using Fedora Linux? If so, you’ll be able to install ImageMagick on your computer with the use of the following dnf install command below.

sudo dnf install imagemagick

OpenSUSE

Are you running OpenSUSE Linux on your computer? If so, you’ll be able to get the ImageMagick program working on your system with the following zypper install command below.

sudo zypper install imagemagick

Generic Linux

If you’re using a Linux operating system that we haven’t covered in the installation, guide, do not worry. Chances are, you’ll still be able to get ImageMagick up and running just fine. Check your package manager (the terminal command you use to install software) for the “imagemagick” package and install it.

Alternatively, if you cannot find the “imagemagick” package on your system and need to install it,  follow along with the ImageMagick website’s official source code instructions. It walks you through everything you need to know to build it from scratch.

Using ImageMagick to convert PNGs to JPGs

ImageMagick can be used to convert images through the terminal. In this guide, we’ll show you how to use it to convert PNGs to JPG files. To start, launch a terminal window by pressing Ctrl + Alt + T, or by searching for “Terminal” in the app menu.

Once the terminal window is open, follow the instructions below depending on how many images you wish to convert at a time. 

Convert a single image

To convert a single image, start by using the CD command to move into the folder where your PNG image file is located. In this example, we’ll use “Pictures.”

cd ~/Pictures/

Once in the folder, use the mogrify command with the -format jpg command-line option.

mogrify -format jpg MY-PNG-FILE.png

After writing in the above mogrify command, ImageMagick will convert your file to a JPG, with the same file name, in the same folder as the PNG file. 

Convert multiple images

Along with converting single images in ImageMagick, it is also possible to convert multiple images at a time. To start, use the CD command to move into the folder in which your multiple PNG files are located. Once again, in this example, or PNG files will be located in the “Pictures” folder.

Using the CD command, move into the “Pictures” folder with the terminal. 

cd ~/Pictures

Once inside of the “Pictures” folder, use the mogrify command and the command-line option -format jpg, so that ImageMagick knows what format to use. Then, specify the files to convert. As we are converting multiple files, use the symbol.

The * symbol is a wildcard. Long story short, the wildcard allows you to tell a command to look for every single file with a particular file type. In this case, we can use it to convert every PNG file.

mogrify -format jpg *.png

When the conversion finishes, you’ll see various JPG files with the same names as your PNG files.

1 Comment

  1. jpg 16-27.png

    I have a picture named 16-27.png on my Desktop. I typed command mogrify -format jpg 16-27.png

    I get the error mogrify: unable to open image ‘jpg:’: No such file or directory @ error/blob.c/OpenBlob/3570.
    mogrify: unrecognized image format `jpg’ @ error/mogrify.c/MogrifyImageCommand/4910.

    I do have imagemagick installed. Proved with the command convert -version