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
To prepare a commercial offer.
190 ₽
50 pages for 10 days
  • 1 page gives 1 tool launch Checking the page.
  • Purchased for a specific site
  • Restrictions on other tools remain the same
PRO subscription
For regular work on a site or a group of sites.
1 580 ₽
3,500 pages per week. The subscription period is 1 month.
Wallet
A separate page balance that complements the PRO subscription balance.
190 ₽
Number of pages
  • An active PRO subscription is required to use the wallet balance
We use cookies. By continuing to use the site, you agree to the processing of personal data in accordance with privacy policy. I agree