How to Convert PNG to JPG on Linux with ImageMagick

To convert PNG to JPG on Linux, the most flexible option is ImageMagick. With ImageMagick 7, a single file can be converted with magick input.png output.jpg, while an entire folder can be handled with magick mogrify -format jpg *.png. If the PNG has transparency, flatten it onto a solid background first because JPEG does not support an alpha channel.

Install ImageMagick on Linux

ImageMagick is available in the standard repositories of the major Linux distributions. Its current documentation recommends the magick program as the main command-line entry point. Package versions vary by distribution and release, so older systems may still provide ImageMagick 6 commands such as convert and mogrify without the magick prefix.

DistributionInstall command
Ubuntu / Debiansudo apt update && sudo apt install imagemagick
Fedorasudo dnf install ImageMagick
Arch Linuxsudo pacman -S imagemagick
openSUSEsudo zypper install ImageMagick
Ubuntu Terminal showing the command sudo apt install imagemagick
Install ImageMagick with your distribution’s package manager before starting the conversion.

After installation, check the version with magick -version. If that command is unavailable but ImageMagick is installed, try convert -version or mogrify -version. ImageMagick’s official command-line tools documentation explains the ImageMagick 7 command structure. Ubuntu also publishes the official imagemagick package listings, and Fedora maintains its ImageMagick package page.

Convert one PNG file to JPG

Open a terminal and move to the folder containing the image. For example:

cd ~/Pictures

Then convert the file by giving the output a .jpg extension:

magick photo.png photo.jpg
Linux terminal converting photo.png to photo.jpg with ImageMagick beside a file manager showing both files
A basic ImageMagick conversion keeps the original PNG and writes a new JPG file.

The original photo.png remains in place because the command writes to a different output filename. To choose JPEG compression quality explicitly, add -quality before the output file:

magick photo.png -quality 90 photo.jpg

ImageMagick accepts JPEG quality values from 1 to 100. Higher values generally preserve more detail but produce larger files. See the official -quality option reference for the format-specific behavior.

Convert a transparent PNG without getting an unwanted background

PNG can store transparent pixels; JPEG cannot. If the source contains transparency, flatten it onto the background color you want before saving as JPG. For a white background, run:

magick logo.png -background white -alpha remove -alpha off logo.jpg
Linux terminal showing ImageMagick removing PNG transparency before saving logo.jpg on a white background
Flatten transparent PNG pixels onto white before converting to JPEG, which has no alpha channel.

The -alpha remove operation composites the image over the selected background, while -alpha off disables the alpha channel for the output. ImageMagick documents these behaviors in its official alpha-channel options.

Convert multiple PNG files to JPG at once

To convert every lowercase .png file in the current directory, use mogrify:

magick mogrify -format jpg *.png
Linux terminal running magick mogrify -format jpg on multiple PNG files with matching JPG files visible in a file manager
The mogrify -format jpg command creates matching JPG files for all PNGs in the current folder.

According to ImageMagick’s official mogrify documentation, using -format jpg leaves the PNG files untouched and creates corresponding JPG files. If your PNGs may contain transparency, combine the options:

magick mogrify -background white -alpha remove -alpha off -quality 90 -format jpg *.png

Be careful if the folder already contains JPG files with the same base names, because the new outputs can replace those files. For a safer workflow, write the conversions into a separate directory:

mkdir -p jpg
for f in *.png; do
  magick "$f" -background white -alpha remove -alpha off -quality 90 "jpg/${f%.png}.jpg"
done

Small filename details that can trip up a batch

Linux filenames are usually case-sensitive, so the wildcard *.png does not normally match a file ending in .PNG. Run the batch again with *.PNG if needed. For a single filename containing spaces, quote it, for example magick "Summer Photo.png" "Summer Photo.jpg". These details prevent the shell from passing the wrong path to ImageMagick.

What if magick is not found?

Some older Linux releases still package ImageMagick 6. In that case, use convert photo.png photo.jpg for a single image and mogrify -format jpg *.png for a batch. If neither command exists, confirm that the ImageMagick package installed successfully and that its binaries are on your shell’s PATH.

For most users, the practical rule is simple: use magick on ImageMagick 7, flatten transparency before creating JPEGs, and use magick mogrify -format jpg when you need to process a whole folder quickly.

Leave a Comment

How to Record Speaker Output on Linux with Audacity

How to Record Speaker Output on Linux with Audacity

Capture Linux desktop audio in Audacity by routing its recording stream to your output device’s monitor source. Follow PulseAudio and PipeWire steps, export tips, and fixes for silent tracks.

How to Use Dropbox on Linux: Install and Sync Your Files

How to Use Dropbox on Linux: Install and Sync Your Files

Install Dropbox on Linux from the official package, sign in, sync a local folder, manage selective sync, and check status from the command line.

How to Install Inkscape on Linux: Ubuntu, Fedora, Arch, and More

How to Install Inkscape on Linux: Ubuntu, Fedora, Arch, and More

Install Inkscape from your Linux distribution’s repositories, the Ubuntu stable PPA, Snap, or Flathub, with current commands and notes for choosing a package source.

How to Find and Remove Duplicate Files on Linux With FSlint

How to Find and Remove Duplicate Files on Linux With FSlint

Use FSlint to scan selected Linux folders, review duplicate groups, and safely delete redundant files or learn when hard-link merging is appropriate.

How to Install SABnzbd on Linux and Configure It

How to Install SABnzbd on Linux and Configure It

Install SABnzbd on Ubuntu or Debian, or run it in Docker on another Linux host. Then open the web interface and configure your provider and download folders.

How to Install the Paper GTK Theme on Linux

How to Install the Paper GTK Theme on Linux

Install the Paper GTK theme from supported Linux repositories, enable it for GTK apps in GNOME Tweaks, and see what the legacy theme can and cannot change.

How to Install and Set Up Plex on OpenMediaVault with Compose

How to Install and Set Up Plex on OpenMediaVault with Compose

The old OpenMediaVault Plex plugin is archived. Set up Plex on OMV 8 with OMV-Extras, the Compose plugin, persistent storage, and Plex’s official container.

How to Clean and Speed Up Ubuntu Safely

How to Clean and Speed Up Ubuntu Safely

Clean and speed up Ubuntu with safe APT cleanup, storage checks, and startup controls that help free space and troubleshoot a sluggish desktop.

How to Install the Hiri Email Client on Linux

How to Install the Hiri Email Client on Linux

Install Hiri on Linux with its Snap package or official tarball, add a desktop launcher, and check supported accounts plus a warning about Hiri’s old Snap release.

How to Get System Specifications for a Linux PC

How to Get System Specifications for a Linux PC

Use Fastfetch and built-in Linux commands to check your distro, kernel, CPU, memory, graphics, storage, and connected devices, then save a clear report.