0

I have used this great answer to convert a .gif to its constituent frames:

convert foo.gif foo.png

My intention was to do some edits to the frames on the command line before combining them back as an output gif; unfortunately, the output file names from this first step aren't properly zero-padded, so we're left with:

foo-frame-0.png
foo-frame-1.png
# ...
foo-frame-10.png

which come up in the wrong order when attempting a clean loop:

for FILE in foo-frame-*.png; do echo $F; done
# foo-frame-0.png
# foo-frame-10.png
# foo-frame-1.png
# foo-frame-2.png
# ...
# foo-frame-9.png

And the workaround for this case of renaming the files ex-post where there's a postfix seems to be quite ugly.

One workaround for this case is the slightly-hacky but basically OK:

for FILE in foo-frame-[0-9].png foo-frame-[0-9][0-9]; do echo $F; done

(i.e. combine the one-digit, then the two-digit lists)

However, I can't help but wonder if there's any way to get this as the ouput directly from convert? I didn't see anything in the man page.

An acceptable alternative would be a way to "loop" over the frames of the gif, performing the same action to each. I tried a simple version of this with convert but it combined all of the frames into one massive single frame.

2

0

You must log in to answer this question.

Browse other questions tagged .