Page 1 of 1

Create animated GIF from PNG with all frames in one file

Posted: 2019-06-04T12:14:18-07:00
by cybersaga
I have a PNG file that has all of the frames of an animation stacked on top of each other. It's a 40x40 image, so the first frame is at 0,0. The second frame is at 0,40... etc. I'd like to extract those frames into an animated GIF.

Now, I actually have 110 of such files, each with a different number of frames, so I'm hoping this can be done without specifying the number of frames.

Is there a way to do this?

I know it could be done easily if each frame was in its own file, so the next best solution is splitting them into multiple files, but I don't know how to do that either - but again, I'd have to split them without specifying the number of frames, so I can do a batch job on all of the files.

Re: Create animated GIF from PNG with all frames in one file

Posted: 2019-06-04T12:49:26-07:00
by snibgo
What version of IM, on what platform?

PNG files contain only one image. I think you mean that the file contains all the frames in a single image, with the frames appended vertically. Each frame is 40 pixels high.

Code: Select all

magick in.png -crop x40 +repage out.gif
This splits the input into frames, and makes a GIF from it.

Does that work?

Re: Create animated GIF from PNG with all frames in one file

Posted: 2019-06-04T13:07:56-07:00
by cybersaga
Yes! That works wonderfully. Thank you. I knew it must be easy.

Now the frames have a transparent background and each frame is being written over the last one. I tried using "-dispose previous" and "-dispose background" but neither have any effect.

Is there a way to clear the canvas between frames?

Re: Create animated GIF from PNG with all frames in one file

Posted: 2019-06-04T13:16:21-07:00
by cybersaga
I found this: http://www.imagemagick.org/discourse-se ... hp?t=33974

I just need to put "-dispose previous" before the input file.

Thanks again!

Re: Create animated GIF from PNG with all frames in one file

Posted: 2019-06-04T13:19:49-07:00
by cybersaga
And I'm using 7.0.8-48 Q16 x64 on Windows 10.