Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@subelsky
Created August 20, 2012 14:45
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save subelsky/3404838 to your computer and use it in GitHub Desktop.
Save subelsky/3404838 to your computer and use it in GitHub Desktop.
Useful ImageMagick snippets
# Flatten a transparent image with a white background:
convert -flatten img1.png img1-white.png
# Make an image transparent
convert -transparent '#FFFFFF' nontransparent.gif transparent.png
# convert an image into tiles
convert -size 3200x3200 tile:single_tile.png final.png
# making a montage from a collection of images
montage -geometry +0+0 -background transparent *png montage.png
# inverting colors
convert before.png -negate after.png
# generating a favicon
convert large_image.png -resize 16x16! favicon.ico
# adding numbers to a tiled image
cmd = (0..324).to_a.inject([]) do |cmd,n|
y=(n/25*32)+15; x=((n%25)*32)+15
cmd << "-draw 'fill red text #{x},#{y} \"#{n}\"'"
end
`convert img.png #{cmd.join(' ')} annotated_img.png`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment