Linux work with images in CLI
Compress
JPG
apt-get install jpegoptim
we only remove unnecessary information, efficiency 5-10%
find /path/to/ -name *.jpg | xargs jpegoptim -s
reduction by 20-80%
find /path/to/ -name *.jpg | xargs jpegoptim -s -m50
PNG
find /path/to/ -name *.png | xargs optipng
overwrites the file - you need to change the owner
does not understand Cyrillic in file names!!!
chown -R www-data:www-data /path/to/
Best way - convert PNG to JPG
ls -1 *.png | xargs -n 1 bash -c 'convert "$0" "${0%.*}.jpg"'