« Back to article list

Creating animation with pencil2d and Image Magick

Table of Contents

Creating an animated gif

It is possible, without too much difficulty, to make a nice looking, traditional animation styled gif (ideally looping) with a combination of pencil2d, your drawing skills, and ImageMagick.

Getting the Software

To begin with, install pencil2d (you can find it at: http://www.pencil2d.org/).

Also, make sure you have ImageMagick installed on your system.

About the keybinds referred to in this article

For key bindings, I'll refer to them in an emacs style, so those line up as follows:

C-n = Control + n
M-x = Alt + x
RET = Enter

Lets get started…

Start off by opening the pencil2d program and start a new drawing via:

C-n

You can draw your initial image here. I recommend starting with something simple.

Creating a new keyframe

After you've placed your first drawing, you can use:

F6

To duplicate the "key frame" and have an identical copy of the image.

Change a small amount at a time

At this point, you will want to click the Eraser (E) and erase a small part of the image you just drew.

Now, click the Pencil (N) to go back to drawing.

Repeat until you've got the drawing you like.

Previewing your animation

At some point, you'll want to see what your animation looks like, simply press:

RET

to watch a preview animation.

To make the preview of the animation simpler (and the looping), I normally finish the animation, and then in reverse order (step through each keyframe from end to start, one at a time) I duplicate the keyframes (F6).

This creates a perfectly looped gif when we get to converting it into a gif.

Save it as the pclx filetype

Make sure to save your new pclx (Pencil Animation File PCL) filetype incase you want to go back and work on it later.

Now, you will want to go to:

File > Export > Image Sequence

Or use the shortcut:

C-r

This will save each keyframe as a standalone png into your target directory.

Putting it together with a little magic (ImageMagick)

Now, change into that directory (I hope you're using GNU/Linux at this point, or you may have to modify the command slightly for the lesser OSes).

Check the name here, you WILL need to modify the command slightly!

Make sure to change the name to match your own saved/exported name (I used "turtle-throwing-bird").

convert -delay 5 -loop 0 -alpha set -dispose previous ./turtle-throwing-bird000{1..9}.png ./turtle-throwing-bird00{10..23}.png ./turtle-throwing-bird.gif

Wrapping up

After ImageMagik wraps up, you will now have a nice new animated gif to show off to your friends!