Skip to content

Instantly share code, notes, and snippets.

@githubutilities
Last active August 29, 2015 14:17
Show Gist options
  • Select an option

  • Save githubutilities/c99487099b46aaeb00c9 to your computer and use it in GitHub Desktop.

Select an option

Save githubutilities/c99487099b46aaeb00c9 to your computer and use it in GitHub Desktop.
Image Hacks With ImageMagick

Generating Pure Image Background

convert -size 1366x768 canvas:yellow  yello_bg.gif

Changing image background

# `-flatten` must be specified
convert in.png -background white -flatten out.png
#or use
convert in.png -fill '#CCCCCC00' -opaque none out.png

Resizing Image

# ImageMagick will try to preserve the aspect ratio
convert -resize 128x128 icon.png icon-128.png
convert -adaptive-resize 128x128 icon.png icon-128.png

# Force the image to become a specific size – even if it messes up the aspect ratio, you can add an exclamation point to the dimensions
convert -resize 128x128! icon.png icon-128.png

Compressing Image

convert -strip -interlace Plane -gaussian-blur 0.05 -quality 85% source.jpg result.jpg

Open Source Image Resource on the Internet

Reference

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