Optimise JPEG for web

After finding a solution for my png files (see here) I was also looking for jpeg and found mozjpeg which is available via brew – like imagemagick and convert.

For jpeg files I came up with the following command for optimisation:

convert in.jpg pnm:- | cjpeg -quality 70 >out.jpg

To use cjpeg from mozjpeg I changed my PATH variable so that mozjpeg comes first. Otherwise another program is used that uses the same name for the /usr/local/bin file.