Image Magick Tricks

Image Magick is a command line tool for manipulating images. It let’s you do so many cool things to images but for the purpose of game dev, I use it to quickly clean up images. It’s a shame it’s not more widely used.

Reasons it’s awesome:

  • It’s free.
  • On all operating systems.
  • Can batch commands.
  • Commands can be easily saved and reused.

Install image magick on OSX with:

brew install imagemagick

Chop Extra Pixels

I use Animate CC for my art and it usually adds unnecessary whitespace around the image – expecially if a shadow filter is present. In the case of custom cursors, I can’t have that around the tip of the cursor.

So in one command I can clean up all the cursors.

mogrify -gravity NorthWest -chop 5x5 -trim CustomCursor*.png

Note: mogrify will overwrite the source image. If testing use convert.

Top left space is gone.

Resize Image To Power Of 2

On Windows, hardware cursors need to be sized 32x32, or else the image gets stretched – which you don’t want. I use image magick to resize it.

mogrify -background none -gravity NorthWest -extent 32x32 CustomCursor0001.png

Cursor is exactly 32x32

Create Shader Channeled Images

A good technique in shader dev is to combine your black and white images – up to 4 – into one by putting each image into it’s own channel on the single image.

This can easily be done in image magick without having to even bootup Photoshop.

convert r.jpg g.jpg -background black -channel RG -combine combined.jpg


That’s all. All these commands are saved somewhere in my project, so they can be ran whenever I need to regenerate the images. This makes development so much easier.

Related Posts

Failed Attempt at Creating a Video Search Engine

Test Your Chinese Using This Quiz

Using Sidekiq Iteration and Unique Jobs

Using Radicale with Gnome Calendar

Why I Regret Switching from Jekyll to Middleman for My Blog

Pick Random Item Based on Probability

Quickest Way to Incorporate in Ontario

Creating Chinese Study Decks

Generating Better Random Numbers

My Game Dev Process