In the next article we are going to take a look at YOGA Image Optimizer. This is a tool to batch convert photos to JPEG, PNG and WEBP, and compress file sizes with equivalent quality. It is a free and open source tool, which is based on the YOGA command line tool.
The YOGA backend uses the Python Pillow library to convert images to PNG, JPEG or WebP. Use the library Biscuits Google to generate JPEG files, which are typically 20% to 30% smaller than using libjpeg. The libraries zopflipng y libwebp Google's are used to optimize the other two image formats. The command line tool also supports 3D model conversion and optimization using the library Asymp.
General characteristics of YOGA Image Optimizer
- The official front-end of YOGA provides a easy to use graphical interface to perform the image conversion and optimization process on Gnu / Linux and Windows.
- Will allow us open a batch of images, displaying their thumbnails, the name and size of the input file, as well as the output name and file format.
- YOGA Image Optimizer supports various formats as input, and can generate optimized JPEG, PNG and WebP files (both with loss and without loss).
- Before clicking on 'Optimize' we will allow you to choose the output format and set the compression level for each of the images.
- We will have multi-thread support. We will be able set how many CPU cores to use.
- Offers a dark mode.
- Output pattern personalized.
Install YOGA Image Optimizer on Ubuntu
For Gnu / Linux, this software can be installed through the Flatpak package or using pip3.
Via Flatpak package
If you are using Ubuntu 20.04 and you still do not have this technology installed on your computer, you can continue The Guide that a colleague wrote on this blog a while ago to enable it.
When you can install flatpak packages, you will only need to open a terminal (Ctrl + Alt + T) and use the following install command:
flatpak install flathub org.flozz.yoga-image-optimizer
After the installation, we can find the program launcher in the graphical environment.
uninstall
If this program does not convince you, can be easily removed running the following command in the terminal (Ctrl + Alt + T):
flatpak uninstall --delete-data org.flozz.yoga-image-optimizer
Using pip3
For those who do not like Flatpak packages, they have the possibility to use pip3. Even though this option, DO NOT create a shortcut to the application to start it from the desktop.
First, we are going to open a terminal (Ctrl + Alt + T) and in it we are going to execute the following command to install required libraries:
sudo apt install git build-essential python3 python3-dev python3-pip libgirepository1.0-dev libcairo2-dev pkg-config gir1.2-gtk-3.0
Then we can install the application package using the command:
sudo pip3 install yoga-image-optimizer
As I said above, the pip package does not have direct access to the application. For this reason you need to run the following command to start it from the terminal and create a .desktop file:
yoga-image-optimizer
uninstall
For remove package this app, we will only need to open a terminal (Ctrl + Alt + T) and use the command in it:
sudo pip3 uninstall yoga-image-optimizer
Basic use of YOGA from the terminal
In addition to using the graphical environment, which I think does not have much to explain, we can also use the terminal to optimize our images. The easiest way to optimize an image from the terminal is by using the following command:
yoga image imagen-entrada.png imagen-salida.webp
When the output format is not specified in the terminal, YOGA generates an image with the same format as the input image. Only PNG, JPEG, and WEBP 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=jpeg imagen-entrada.png imagen-salida.jpeg
The following formats are supported:
- orig: This is the default. The output format will be the same as the input image.
- auto: The output format is selected automatically. YOGA will generate a PNG if the input image uses transparency, otherwise it will generate a JPEG.
- png: generates a PNG image.
- jpeg: generates a JPEG image.
- web- Generates a lossy WEBP image.
- webpl: generate a lossless WEBP image
This program also allows resize images with –resize option:
yoga image --resize=512x512 imagen-entrada.png imagen-salida.png
In this case, if the width and height have the same value, we do not need to specify both.
YOGA will also allow us set the desired quality of JPEG and WebP files that can be generated with the options –Jpeg-quality y –Webp-quality. These options take an integer between 0 (lower quality files) and 100 (higher quality files) as parameter:
yoga image --output-format=jpeg --jpeg-quality=84 imagen-entrada.png imagen-salida.jpg
If you are a Gnu / Linux user, this is an interesting option to optimize your images, which is also free and open source. It can know more about this program in your web page or repository on GitHub of the project.