Skip to content

Instantly share code, notes, and snippets.

@samcre
Created August 20, 2020 15:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samcre/ea936b99056e4b19537cf567f8d70eb3 to your computer and use it in GitHub Desktop.
Save samcre/ea936b99056e4b19537cf567f8d70eb3 to your computer and use it in GitHub Desktop.
Optimize images for web
# Optimize PNG files with pngcrush
find . -type f -iname "*.png" -exec pngcrush -ow {} \;
# Optimize JPG & JPEG files with ImageMagick following this recommendations: https://dev.to/feldroy/til-strategies-for-compressing-jpg-files-with-imagemagick-5fn9
find . -type f -iname "*.jpg" -exec convert {} -sampling-factor 4:2:0 -strip -quality 85 -interlace Plane -gaussian-blur 0.05 -colorspace RGB {} \;
find . -type f -iname "*.jpeg" -exec convert {} -sampling-factor 4:2:0 -strip -quality 85 -interlace Plane -gaussian-blur 0.05 -colorspace RGB {} \;
# Optimize SVG images using SVGO
find . -type f -iname "*.svg" -exec svgo -i {} \;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment