How do I compress and optimize JPEG images on my amazon cloud account so that I can save bandwidth on cloudfront cdn account? How do I use an image compressor to create lossless compression on JPEG files, with no effect on image quality in bulk using Linux?
JPG file format is recommended for high resolution photographic-style images. You need to use jpegoptim command. It is used to optimize/compress jpeg files. Program supports lossless optimization, which is based on optimizing the Huffman tables. And so called “lossy” optimization where in addition to optimizing Huffman tables user can specify upperlimit for image quality.
Any commands with a # at the start means “as root”.
Type the following command:
# apt-get install jpegoptim
The syntax is:
jpegoptim file.jpeg jpegoptim [options] file.jpeg
Type the following command to optimize
$ jpegoptim photo.jpeg
1 2 #!/bin/bash for i in one.jpeg two.jpeg foo.jpeg; do jpegoptim "$i"; done
1 2 3 4 #!/bin/bash ## process all *.jpeg in the current directory for i in *.jpeg; do jpegoptim "$i"; done