Ubuntu – How to convert a PNG strip to a GIF

convertimage processing

So, I made this animation in a program, however, it doesn't seem to support exporting as a PNG sequence so I could convert it to a GIF. The animation is over 100 frames so saving each image one-by-one will take ages. However, it supports exporting as a "strip", which is like a movie film. Each picture in the animation has the same dimensions. Here's how the program's "strip" feature works.

The images in the animation are stacked horizontally, the first frame being the far left while the last frame being the far right. There are no gaps between frames, and the file name usually is "name_stripX.png" if the animation has X frames. If each frame was 32 by 32 and the animation had 8 frames, this file would have a width of 256 and a height of 32.

Here is some example output, each color fills in one frame:

Example Output

Also, just to clear things up a little bit more, the program is called "Game Maker 8.0."

Best Answer

You can use ImageMagick to convert images in varying ways, and it should be able to this quite easily. First you can split up into to parts (original.png being the source image, and in this case 32x32pixels in size):

convert original.png -crop 32x32 parts-%02d.png

You can then convert it into a animation (use -loop 1 if you don't want it to loop):

convert -loop 0 -page +0+0 ./parts*.png output.gif

Resulting in:

The output PNGs of the first command have a offset included in them, so without the -page +0+0 option the animation ends up like:

There are varying other options you can include (mainly in the second command), such as -delay etc - you can also optimize the animation so it is smaller (and faster to load/render) - e.g. borrowed from here:

convert output.gif -fuzz 10% -layers Optimize optimised.gif

or using gifsicle

gifsicle -O output.gif -o optimised.gif

EDIT: If the frames are transparent, you can set the frames to replace by adding the
-dispose Background option, so when a frame is disposed of when the next one is loaded:


Example above done without the page option so it shows clearly

The problem with this is you probably can't optimize the resulting image much then - so another way may be to make the frames opaque so the next frame covers the previous.

Related Question