Skip to content

Instantly share code, notes, and snippets.

@ddrscott
Created January 3, 2023 17:41
Show Gist options
  • Save ddrscott/ab954c0dbd38301fd7f54b6bc2973c57 to your computer and use it in GitHub Desktop.
Save ddrscott/ab954c0dbd38301fd7f54b6bc2973c57 to your computer and use it in GitHub Desktop.
Compile a bunch of pixel art frames into an animated gif.
frames=$(shell ls -tr bouncing-ball/*.png)
bouncing-ball.gif: $(frames)
convert -delay 12 -loop 0 -dispose previous -resize 256x -filter Point $(frames) $@
@ddrscott
Copy link
Author

ddrscott commented Jan 3, 2023

Overview

I used Pixelorama to create the frame and test the animation, but the GIF output had some odd artifacts between frames dues to blending or something. I couldn't figure it out in the settings in the application, so we whipped out ImageMagick to do the work.

Makefile Notes

  • shell ls -tr reverse time modified list of files. Pixelroma always saves in frame order, so we don't need to worry about file numbering messing us up.

Image Magick Notes

  • -delay 12 can be changed to whatever to speed up (decrease the delay) or slow down (increase delay) the animation.
  • -loop 0 loop forever like a good GIF should.
  • -dispose previous is important to remove ghosting of the previous frame during the animation. It might be cool to omit this option if we want to see the frames drawn on top of each other.
  • -resize 256x scale up the image so it looks nicely pixelated.
  • -filter Point keeps the edges of pixels nice and sharp by disabling any kind of blending during resize.

Source Images

frame_1
frame_2
frame_3
frame_4
frame_5
frame_6
frame_7
frame_8
frame_9
frame_10
frame_11
frame_12

Final Image

bouncing-ball

Reference

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