-
-
Save tsbega/c76e6b90438e3056114c2109a266c473 to your computer and use it in GitHub Desktop.
Recursively optimize PNG and JPEG images using convert command
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Recursively optimize PNG and JPEG images using convert command | |
# | |
# `convert` is part of ImageMagick (http://www.imagemagick.org/). You will need to install it first. | |
# | |
# Author: Rajendra Kumar Bhochalya (http://rkb.io) | |
# | |
# @see https://developers.google.com/speed/docs/insights/OptimizeImages | |
# Optimize all JPEG images in current directory and subdirectories | |
find . -name "*.jpg" -exec convert "{}" -sampling-factor 4:2:0 -strip -quality 85 -interlace JPEG -colorspace RGB "{}" \; -exec echo "{}" \; | |
# Optimize all PNG images in current directory and subdirectories | |
find . -name "*.png" -exec convert "{}" -strip "{}" \; -exec echo "{}" \; | |
#convert to webp | |
#find . -name "*.png" | parallel -eta cwebp {} -o {.}.webp && find . -name "*.jpg" | parallel -eta cwebp {} -o {.}.webp && find . -name "*.jpeg" | parallel -eta cwebp {} -o {.}.webp | |
#mogrify -format jpg -background white -alpha remove -alpha off *.png | |
#find . -type f -iname "*.png" -exec convert -verbose -quality 80 -resize 700\> {} {} \; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment