First of all, don't forget to install the JPEG manipulating programs package:
# apt-get install libjpeg-progs
$ jpegtran -copy none -progressive input.jpg > output.jpg
- yes, it produces a progressive JPEG output image; if you don't like it (or it's unsupported in the target environment), use
-optimizeswitch instead of-progressive(but the output image size will be bigger); - there's also a non-recommended option (an
-arithmeticswitch) to enable arithmetic coding; it allows a more efficient compression than traditional Huffman coding does, but (unfortunately) it's not widely supported in JPEG decoders due to some historical patent restrictions; -copy noneoption removes all extra markers (comments, tags, thumbnails and other metadata) from the output; if you need to save them, use-copy comments(or even-copy all) option instead;- you can add a
-grayscaleoption, and it will omit color data from the output image without re-encoding (very useful for grayscale / black & white / monochrome images); - more reading:
jpegtran -helpandman jpegtran- JPEG - Wikipedia
- libjpeg - Wikipedia