Page 1 of 1
sprite sheets to animated .gif files
Posted: 2015-12-30T10:42:42-07:00
by Voyager
Good day everyone! It's my first time trying to do something like this. I tried many things but finally gave up
I have over 200 sprite sheet .png files that I want to convert to animated .gif files (then if possible change extension to .png, not format)
Windows 8.1 and ImageMagick-6.9.2-10-Q16-x64
here is an example
https://dl.dropboxusercontent.com/u/609 ... xample.png
this works for one file
Code: Select all
convert -dispose 3 -delay 4 -loop 0 *.png -crop 80x80 +repage result.gif
https://dl.dropboxusercontent.com/u/609 ... result.gif
for all the files I tried mogrify but "mogrify.exe: unable to open image '*.gif'"
Code: Select all
mogrify -dispose 3 -delay 4 -loop 0 *.png -crop 80x80 +repage *.gif
so I tried this but mogrify seems to ignore +repage
Code: Select all
mogrify -format gif *.png
mogrify -dispose 3 -delay 4 -loop 0 *.gif -crop 80x80 +repage *.gif
https://dl.dropboxusercontent.com/u/609 ... ck/bad.gif
Re: sprite sheets to animated .gif files
Posted: 2015-12-30T10:48:30-07:00
by fmw42
mogrify does not specify the input image. It takes all images of -format specified in a folder and makes them into the suffix specified at the end. Basically, one output for each input, only. So you cannot make multiple outputs for each input with mogrify. You will have to write a script loop over each image in the folder and use convert to generate the multiple gif files. see
http://www.imagemagick.org/Usage/basics/#mogrify
Also note that PNG does not support animation, so if you convert to png, you will get individual images for each frame.
Re: sprite sheets to animated .gif files
Posted: 2015-12-30T13:05:25-07:00
by Voyager
did some research. came up to this and for some reason it works
Code: Select all
mogrify -format gif *.png
FOR %%? IN (*.gif) DO mogrify -dispose 3 -delay 4 -loop 0 *.gif -crop 80x80 +repage *.gif %%?
then if I use this it creates .gif with all the previous .png
Code: Select all
mogrify -format gif *.png
FOR %%? IN (*.gif) DO convert -dispose 3 -delay 4 -loop 0 *.gif -crop 80x80 +repage *.gif %%?
as for changing extention to .png I don't want to change the format, only the extension
from this
https://dl.dropboxusercontent.com/u/609 ... result.gif
to this
https://dl.dropboxusercontent.com/u/609 ... result.png
they are both animated
Re: sprite sheets to animated .gif files
Posted: 2015-12-30T13:14:07-07:00
by fmw42
I do not see a difference between your two sets of command?
I advise against just editing the file suffix from gif to png. Image readers may be confused by the png suffix on gif file. In any case it is "bad form" to do so.
Re: sprite sheets to animated .gif files
Posted: 2015-12-30T15:23:45-07:00
by snibgo
Voyager wrote:as for changing extention to .png I don't want to change the format, only the extension
Why do you want to do this? The ordinary Windows command can do that ...
... but I can't see why you would want to. It seems like a bad idea.
Re: sprite sheets to animated .gif files
Posted: 2015-12-30T17:53:44-07:00
by Voyager
fmw42, the difference is in the second line, one using mogrify and the other convert
thanks for that command snibgo!
just personal stuff
in discord, a voice and text chatting program, a .gif file is overlayed with the text "GIF" while .png not
and btw
found out this converts all sprite sheets to animated .gif files in seconds
Code: Select all
mogrify -format gif *.png
mogrify -dispose 3 -delay 4 -loop 0 *.gif -crop 80x80 *.gif
mogrify *.gif +repage *.gif
thank you
Re: sprite sheets to animated .gif files
Posted: 2015-12-30T20:07:14-07:00
by fmw42
You have to run 3 mogrify commands. You should be able to write a simple loop over each image in the directory and create an animated gif in one convert command.
loop over each image
get filename (without suffix)
convert filename.png -dispose previous -delay 10 -crop 80x80 +repage -loop 0 filename.gif
end loop
I do not use windows, but this would be trivial in unix.
Code: Select all
cd directory
list=`ls *.png`
for img in $list; do
filename=$(convert $img -format "%t" info:)
convert $img -dispose previous -delay 10 -crop 80x80 +repage -loop 0 $filename.gif
done