Skip to content

Instantly share code, notes, and snippets.

@berarma
Last active January 10, 2020 10:59
Show Gist options
  • Save berarma/360ab2c4d979d2de811f3cc59313a15d to your computer and use it in GitHub Desktop.
Save berarma/360ab2c4d979d2de811f3cc59313a15d to your computer and use it in GitHub Desktop.

Optimize JPEG/PNG images for the web using ImageMagick

convert -filter Triangle -define filter:support=2 -thumbnail %target-width% -unsharp 0.25x0.08+8.3+0.045 -dither None -posterize 136 -quality %jpeg-quality% -define jpeg:fancy-upsampling=off -define png:compression-filter=5 -define png:compression-level=9 -define png:compression-strategy=1 -define png:exclude-chunk=all -interlace none -colorspace sRGB original-image.jpg optimized-image.jpg

%target-width%: Width of the final image in pixels. %jpeg-quality%: JPEG quality setting (0-100).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment