Image Optimizer for Free: Meet YOGA and Learn How to Use it

Do you want to compress your images before uploading them online? Meet YOGA.

Nowadays the majority of a websiteโ€™s data is typically comprised of images. Large images slow down your web pages which creates a less than optimal user experience.

In light of this, image optimization refers to the process of delivering high-quality images while keeping the smallest possible size. The result is significant load savings, an improved user experience and increased site visibility.

YOGA Image Optimizer

YOGA (Yummy Optimizer for Gorgeous Assets) is a free command-line tool and a library that can:

  • Convert and optimize images from various format to JPEG, PNG and WebP
  • Convert and optimize 3D models from various formats to glTF and GLB

YOGA Image Optimizer supports several formats as input and can generate optimized JPEG, PNG and WebP (both lossy and lossless). You will be able to save about 30% of space on JPEGs and 20% on PNGs.

Converting a JPEG to a lossy WebP can reduce image size to a half and converting a PNG to a lossy WebP can save you more than 50% on average.

How to Install YOGA Image Optimizer on Linux

The simplest way to install YOGA is from PyPI. Just run the following command as root on Linux:

pip3 install yoga

A package for Arch Linux (AUR) is already available. On Debian / Ubuntu, you can install everything you need using the following command:

sudo apt install build-essential cmake python3 python3-dev python3-pip python-setuptools 

Then clone the repository, go to the projectโ€™s directory and build it (as root):

git clone https://github.com/wanadev/yoga.git
cd yoga
sudo python3 setup.py installCode language: PHP (php)

YOGA Basic Usage

The simplest way to optimize an image is by using the following command:

yoga image input.png output.webpCode language: CSS (css)

When the output format is not specified, YOGA outputs an image using the same format as the input one. Only PNGs, JPEGs and WEBPs are supported as input when the output format is not explicitly specified.

The output format can be specified using the --output-format option:

yoga image --output-format=webp input.png output.webp

The following formats are supported:

  • orig: This is the default. The output format will be the same as the one of the input image.
  • auto: The output format is automatically selected. YOGA will generate a PNG if the input image is using transparency, else it will generate a JPEG.
  • png: Outputs a PNG image.
  • jpeg: Outputs a JPEG image.
  • webp: Outputs a lossy WEBP image.
  • webpl: Outputs a lossless WEBP image

YOGA Image Optimizer also allows you to resize images with the --resize option:

yoga image --resize=512 input.png  ouput.png
yoga image --resize=512x512 input.png  ouput.png

As you see in the example above, if the width and the height have the same value, you do not have to specify both.

YOGA allows you to tune the desired quality of the JPEG and WebP it outputs with the --jpeg-quality and --webp-quality options. These options takes an integer between 0 and 100 as parameter:

  • 0: Ugly images but smaller files.
  • 100: Best quality images but larger files.
yoga image --output-format=jpeg --jpeg-quality=84 input.png output.jpg
yoga image --output-format=webp --webp-quality=90 input.png output.webp 

The default WEBP quality is 90%.

Conclusion

If you are a Linux user you definitely need to try YOGA. It is free and open source image optimizer, which is a great choice for any site owner that cares about image optimization and performance. The image compression is very effective and optimized images being a lot smaller in size.

You can find more information about YOGA on the project’s website.

Bobby Borisov

Bobby Borisov

Bobby, an editor-in-chief at Linuxiac, is a Linux professional with over 20 years of experience. With a strong focus on Linux and open-source software, he has worked as a Senior Linux System Administrator, Software Developer, and DevOps Engineer for small and large multinational companies.

Think You're an Ubuntu Expert? Let's Find Out!

Put your knowledge to the test in our lightning-fast Ubuntu quiz!
Ten questions to challenge yourself to see if you're a Linux legend or just a penguin in the making.

1 / 10

Ubuntu is an ancient African word that means:

2 / 10

Who is the Ubuntu's founder?

3 / 10

What year was the first official Ubuntu release?

4 / 10

What does the Ubuntu logo symbolize?

5 / 10

What package format does Ubuntu use for installing software?

6 / 10

When are Ubuntu's LTS versions released?

7 / 10

What is Unity?

8 / 10

What are Ubuntu versions named after?

9 / 10

What's Ubuntu Core?

10 / 10

Which Ubuntu version is Snap introduced?

The average score is 68%