Page 1 of 1

filename.gif to filename_01.png, filename_02.png, etc.

Posted: 2015-11-28T07:28:14-07:00
by Edistra
Hello,

Despite some researches I can't manage to do what I want.

I have several .gif files which contain animations that I want to split into several frames, so I use :

Code: Select all

convert -coalesce walk.gif -set filename:f '%t' 'walk_%02d.png'
and get walk_01.png, walk_02.png, etc. perfect.

Now I would like to write a generic function and replace "walk" by the filename and be able to execute the command only one time for all the .gif files.
I tried many things like :

Code: Select all

convert -coalesce *.gif -set filename:f '%t_%02d' '%[filename:f].png'
or

Code: Select all

convert -coalesce *.gif -set filename:f '%t' '%[filename:f]_%02d.png'
but nothing works properly, it seems that the second expression with % is ignored.

Does anyone know how to do that ? :D

Re: filename.gif to filename_01.png, filename_02.png, etc.

Posted: 2015-11-28T10:44:44-07:00
by fmw42
This will do what you want, but it won't put leading zeros in there.

Code: Select all

convert *.gif -coalesce -set filename:f '%t_%s' '%[filename:f].png'
This does it for one image, so you would need to write a loop over each image.

Code: Select all

filename=`convert image.gif -format "%t\n" info: | head -n 1`
convert image.gif -coalesce  ${filename}_%02d.png
It almost works in the reverse order:

Code: Select all

convert image.gif  -coalesce -set filename:f '%t' %02d_%[filename:f].png