Find code and diagrams at: https://www.EliTheComputerGuy.com
Jpegoptim allows you to compress/optimize image files from the command line in linux.
WARNING: by default Jpegoptim modifies the source file
JpegOptim: https://www.mankier.com/1/jpegoptim
Install Jpegoptim on Ubuntu
sudo apt-get install jpegoptim
Resize Image (overwrites source)
jpegoptim –size=50k image.jpg
Saves Converted Image into Different Folder
jpegoptim –size=50k –dest=outputFolder image.jpg
Overwrites Files on Output Folder
jpegoptim –size=100k –dest=outputFolder -o image.jpg
Resize Multiple Images at Once
jpegoptim –size=50k image1.jpg image2.jpg image3.jpg