How to optimize jpeg image sizes


Install the package (on Debian-based)

apt install jpegoptim

We can now remove the metadata

# optimize image without lossing quality
jpegoptim -f -p AFILE.JPG # lossless
 
# optimize to a fixed bytes size
jpegoptim -f -p -S [OPTIMIZE_TO_BYTES] *.JPG
 
# optimize to a percentage threshold
jpegoptim -f -p -S '80%' *.JPG