**Install jpegoptim** \\
sudo apt-get install jpegoptim
**How to compress a file**\\
jpegoptim filename.jpeg
**To compress above the image from 5.6MB to around 500k.**\\
$ jpegoptim --size=500k filename.jpeg
**Compress all images at once.**\\
jpegoptim *.JPG
Optimize PNG
sudo apt install
To optimize a PNG file, run
$ optipng -o7 file.png
-o selects the optimization level. The higher the level, the more compression trials. OptiPNG optimizes the given file in-place.
To make the file further smaller, we can remove the metadata from the PNG file by specifying --strip all:
$ optipng --strip all -o7 file.png