Skip to content

Instantly share code, notes, and snippets.

@bignimbus
Last active April 24, 2020 21:03
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bignimbus/fe3288c406127b696eb5a35afef1680c to your computer and use it in GitHub Desktop.
Save bignimbus/fe3288c406127b696eb5a35afef1680c to your computer and use it in GitHub Desktop.
Here are some of my pet ImageMagick commands.
# converts a png image to jpeg
# all transparent regions will be converted to white
convert -flatten source.png destination.jpg
# optimize an image asset
# no visible quality loss with a vastly reduced file size
# tested with png and jpeg assets
mogrify -filter Triangle -define filter:support=2 -unsharp 0.25x0.08+8.3+0.045 -dither None -posterize 136 -quality 82 -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 ./path/to/img.jpg
# same as imagemagick-magic.sh but with no posterize filter
mogrify -filter Triangle -define filter:support=2 -unsharp 0.25x0.08+8.3+0.045 -dither None -quality 82 -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 ./path/to/img.jpg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment