Open up the terminal and type following command to install Jpegoptim:
sudo apt-get install jpegoptim
Its very simple. you can optimize / compress single JPEG / JFIF file or all the JPEG / JFIF files within the folder. Copy all your images or photos into one folder and type the below command by changing into that folder
jpegoptim *.JPG –max=50For more options on jpegoptim check the man pages.