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

YOGA Image Optimizer

YOGA Image Optimizer is a free command line tool to convert and optimize images from various format to JPEG, PNG and WEBP.

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. 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 install

YOGA Basic Usage

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

yoga image input.png output.webp

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.

Leave a Reply

Your email address will not be published.

Latest from Tutorials