Skip to content

Instantly share code, notes, and snippets.

@Blumed
Created January 8, 2016 02:30
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 Blumed/4d84959d6b4ba9923685 to your computer and use it in GitHub Desktop.
Save Blumed/4d84959d6b4ba9923685 to your computer and use it in GitHub Desktop.
Imagemagick: resize / convert to png or jpg / change png background color / send it somewhere
# resize / convert to png / send it somewhere
#
# function file size quality whereTo
# resizepng \*\.\* 300 82 img-full/
#
resizepng() {
mogrify -format png -path $4 -filter Triangle -define filter:support=2 -thumbnail $2 -dither None -quality $3 -unsharp 0.25x0.08+8.3+0.045 -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
}
# resize / convert to png / fill transparency with a color / send it somewhere
#
# function file size quality whereTo
#
# resizepngbg \*\.\* 300 82 "#000000" img-full/
#
resizepngbg() {
mogrify -format png -path $5 -filter Triangle -define filter:support=2 -thumbnail $2 -dither None -quality $3 -unsharp 0.25x0.08+8.3+0.045 -define png:compression-filter=5 -define png:compression-level=9 -define png:compression-strategy=1 -define png:exclude-chunk=all -interlace none -colorspace sRGB -background $4 -alpha remove $1
}
# resize / convert to jpg / send it somewhere
#
# function file size quality whereTo
# resizejpg \*\.\* 300 82 img-full/
#
resizejpg() {
mogrify -format jpg -path $4 -filter Triangle -define filter:support=2 -thumbnail $2 -quality $3 -unsharp 0.25x0.08+8.3+0.045 -dither None -define jpeg:fancy-upsampling=off -interlace none -colorspace sRGB $1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment