Skip to content

Instantly share code, notes, and snippets.

@jtebert
Last active September 22, 2017 17:25
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 jtebert/3f3273e73b0f911b20165995acbd7be1 to your computer and use it in GitHub Desktop.
Save jtebert/3f3273e73b0f911b20165995acbd7be1 to your computer and use it in GitHub Desktop.
A simple imagemagick script to compress images for the world wide web
#!/bin/bash
# A simple image resizer/compressor from here:
# https://www.smashingmagazine.com/2015/06/efficient-image-resizing-with-imagemagick/
#
# Note: You will likely have to set this file to be executable by running: chmod +x resizer.sh
#
# INPUTS: input_files width output/path
# EXAMPLE: ./resizer.sh "photos/*.jpg" 1920 "photos/compressed"
mkdir -p $3
mogrify -path $3 -filter Triangle -define filter:support=2 -resize $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 $1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment