Lessons

Minification of images without loss of quality

Images in JPEG, PNG, GIF, SVG format have the potential to optimize size without losing quality. This is due to the fact that graphic editors and cameras do not care about reducing the size of files. They also add background information (metadata) that increases the file size, but is not used by users’ browsers.

Use the following programs to optimize images:

  • jpegoptim with the parameters jpegoptim --strip-all --all-progressive [file path] for JPEG.
  • [pngquant](https://pngquant.org /) with the parameters pngquant --force 256 [file path] and [optipng](https://sourceforge.net/projects/optipng /) with the parameters optipng -i0 -o2 --strip all [file path] for PNG. To achieve maximum results, use both programs in this sequence.
  • gifsicle with the parameters gifsicle -b -O3 [file path] for GIF.
  • svgo for SVG.

There are also free online services for image optimization. [Visual service for fine SVG optimization](https://jakearchibald .github.io/svgomg/).

Using these programs, you can set up automatic optimization of all images of your site once a day. The script code is presented below:

Demonstration
Bash script
#!/bin/bash

# Сначала установите программы optipng, pngquant, jpegoptim, gifsicle, svgo.
# Для убунту это делается с помощью команды:
# apt install -y optipng pngquant jpegoptim gifsicle; npm install -g svgo

# Замените ./ на путь до нужной директории
find ./ -type f -iname "*.png" -exec optipng --strip all {} \;
find ./ -type f -iname "*.png" -exec pngquant --ext .png --force 256 {} \;
find ./ -type f -iname "*.jpg" -exec jpegoptim --strip-all --all-progressive {} \;
find ./ -type f -iname "*.jpeg" -exec jpegoptim --strip-all --all-progressive {} \;
find ./ -type f -iname "*.gif" -exec gifsicle -b -O3 --no-warnings {} \;
find ./ -type f -iname "*.svg" -exec svgo {} \;



PRO subscription for working with the service

Promo
Checking 50 pages in the tool "Checking the page"
190 ₽
The subscription is activated for 10 days and is linked to a specific site.
PRO subscription
3,500 pages per week in tools "Checking the page" and "Full site scan".
1 580 ₽
The subscription is activated for 30 days and you can scan any site.
Wallet
Additional pages that are credited to a separate balance. For checking large sites.
200 ₽
Number of pages
An active PRO subscription is required.
We use cookies. By continuing to use the site, you agree to the processing of personal data in accordance with privacy policy. I agree