1. Home
  2. Linux

How to compress PNG files on Linux

Are you looking to compress some PNG images on your Linux PC? Can’t figure out how to compress PNGs? We can help! In this guide, we’ll go over two great ways you can compress your PNG image files on Linux.

compress PNG files on Linux

Need to compress other image types? Check out Curtail for Linux.

Method 1 – PNG Quant

If you need to compress PNG files on Linux, the quickest way to do it is with PNG Quant. It’s a tool dedicated to only compressing PNG files and no other file types. It works through the terminal and is supported on a wide variety of Linux operating systems.

To start the installation of PNG Quant on your Linux PC, you’ll need to open up a terminal window. You can open up a terminal window on the Linux desktop by pressing Ctrl + Alt + T  on the keyboard. You can also open up a terminal window by searching for “Terminal” in the app menu.

With the terminal window open, follow the command-line installation instructions below that correspond to the Linux operating system you use on your computer.

Ubuntu

The PNG Quant program can be installed on Ubuntu Linux using the following apt install command below.

sudo apt install pngquant

Debian

If you’re using Debian 9, 10, or 11, you’ll be able to install PNG Quant on your system using the following apt-get install command below.

sudo apt-get install pngquant

Arch Linux

Those on Arch Linux can get the PNG Quant application up and running from the “Community” software repository using the pacman command below.

sudo pacman -S pngquant

Fedora

Those on Fedora Linux can get the latest PNG Quant (provided you’re using Fedora 33 or newer) up and running on your system using the following dnf install command below.

sudo dnf install pngquant

OpenSUSE

The PNG Quant application is up and available for all OpenSUSE Linux users. You can install it on your system with the following zypper install command below.

sudo zypper install pngquant

Generic Linux

You should be able to find PNG Quant on your Linux PC, even if we didn’t cover it in the installation instructions here. To get it working, search “pngquant” in the terminal using the program you use to install software on your system. Alternatively, head over to the official PNG Quant website and follow the installation instructions.

Using PNG Quant to compress one image

To compress a single image using PNG Quant, open up a terminal window. From there, CD into the directory that the image file is at. For example, to compress a PNG image in the “Pictures” folder, you’d do:

cd ~/Pictures/

Once in the directory with the image file, you can compress your single PNG file using the pngquant command. 

pngquant my-png-file.png

When the conversion is complete, you’ll see a second PNG file with the “Fs8” in the file name.

Using PNG Quant to compress multiple images

It is possible to compress more than one PNG file at a time with the PNG Quant tool. To do it, start by accessing the directory that the image files are in. For example, if your files are in “Pictures,” enter the command below.

cd ~/Pictures/

From here, convert multiple PNG files by specifying the filename with * in the command.

pngquant *.png

All converted PNGs in the directory will have the “Fs8” tag in the filename.

Method 2 – Trimage image compressor

Another great way to compress PNG Image files on Linux is the Trimage compressor. This program works well on most Linux PCs and has a friendly GUI. To get the app installed, open up a terminal window on the Linux desktop. 

To open up a terminal window, press Ctrl + Alt + T  on the keyboard. Or, alternatively, search for “Terminal” in the app menu and launch it that way. When the terminal window is open, follow the command-line installation instructions below that correspond to the Linux OS you use.

Ubuntu

On Ubuntu, install it with apt install.

sudo apt install trimage

Debian

On Debian, get the app working with apt-get install.

sudo apt-get install trimage

Arch Linux

On Arch Linux, install the app with pacman.

wget https://userrepository.eu/trimage-1.0.6-2-any.pkg.tar.zst
sudo pacman -U trimage-1.0.6-2-any.pkg.tar.zst

Fedora

On Fedora Linux, install the app with dnf install.

sudo dnf install https://raw.githubusercontent.com/rpmsphere/noarch/master/t/trimage-1.0.6-2.noarch.rpm

With the Trimage app installed, launch it on the desktop by searching for it in the app menu. When the app is open, click on the “Add and compress” button. Then, browse for the PNG files you wish you compress.

After adding the PNG files to Trimage, it will automatically start compressing. This should only take a few seconds but could take longer depending on how many files you add. When the compression is done, Trimage will overwrite the old file.

 

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.