Batch JPEG compression without quality loss


I'm sure many wondered how quickly and easily compress all images at once. For example, to free up space or website optimization.
Even Google Pagespeed recommends to compress them such advice:
If you compress lossless image ..., this will reduce the size 909 Б (3 %).


This fact will help us utility from libjpeg - jpegtran.

Install jpegtran for example Ubuntu:

apt-get install libjpeg-progs

Console script to compress the entire contents of a directory without loss

for i in *.jpg; do jpegtran -optimize -progressive -outfile "$i" "$i"; echo "$i"; done