Batch Reduce Image Size, in One Line Command

Having to batch reduce image sizes can be a pain, but below is the on line command to reduce JPEG image sizes:

find . -name '*.jpg' -exec mogrify -strip -quality 62 {} +

The above command searches recursively through directories for .jpg formatted files, using the find and mogrify commands. Adding -exec to the end of the find command passes and found item onto whatever command follows -exec via the {} + parameters. “mogrify -strip -quality 62” strips-out any meta data in the jpg and compresses the quality to 62% of the original compression. Executing -strip alone can greatly reduce file sizes, at there tends to be a lot of meta data stored in images.

Same can be done for PNG images, using pngquant.

find . -name '*.png' -exec pngquant -f -ext .png --skip-if-larger --speed 1 {} +