Install Oxipng on Ubuntu 24.04

Install Oxipng on Ubuntu 24.04

Oxipng is a command line tool designed to optimize and compress PNG images. It aims to reduce the file size of PNG images without compromising their quality, making them more efficient for use on websites, in applications, or in any context where file size and loading times are a concern. This tutorial explains how to install Oxipng on Ubuntu 24.04.

Install Oxipng

Retrieve the latest Oxipng version from the GitHub repository and save it in a variable:

OXIPNG_VERSION=$(curl -s "https://api.github.com/repos/shssoichiro/oxipng/releases/latest" | grep -Po '"tag_name": "v\K[0-9.]+')

Download Oxipng using the earlier determined version:

wget -qO oxipng.tar.gz https://github.com/shssoichiro/oxipng/releases/latest/download/oxipng-$OXIPNG_VERSION-x86_64-unknown-linux-gnu.tar.gz

Create temporary directory and extract a tar.gz file:

mkdir oxipng-temp
tar xf oxipng.tar.gz --strip-components=1 -C oxipng-temp

Move executable to /usr/local/bin directory:

sudo mv oxipng-temp/oxipng /usr/local/bin

To find out the Oxipng version, use this command:

oxipng --version

Remove unneeded archive and directory:

rm -rf oxipng.tar.gz oxipng-temp

Testing Oxipng

Download image for testing:

wget -q https://raw.githubusercontent.com/kornelski/pngquant/master/test/img/test.png

Execute the oxipng command and pass the image name as an argument to compress the image:

oxipng -o max --strip safe --alpha test.png
  • -o max - sets the optimization level to the maximum, providing the highest compression at the cost of longer processing time.
  • --strip safe - removes unnecessary metadata from the image without affecting rendering of the image.
  • --alpha - improves compression of transparent images by adjusting the color values of fully transparent pixels.

Output:

Processing: test.png
16795 bytes (2.32% smaller): test.png

Uninstall Oxipng

To remove Oxipng, delete its corresponding file:

sudo rm -rf /usr/local/bin/oxipng

Leave a Comment

Cancel reply

Your email address will not be published.