Save as animated gif?

BlitzMax Forums/BlitzMax Programming/Save as animated gif?

Retimer(Posted 2009) [#1]
Is there a library around that will let me save a collection of frames as an animated gif by any chance?

Or can someone point me in the right direction?


theHand(Posted 2009) [#2]
Yes, FreeImage. Brucey in his boundless wisdom wrote a wrapper for it so that it can be utilized by us (BlitzMaxers) without having to get our hands dirty in C.
Download the documentation and search for "Multipage functions".


Retimer(Posted 2009) [#3]
Was taking a look at it, but saw no way to create an animated gif...i'll take another look I guess.

Thanks


ImaginaryHuman(Posted 2009) [#4]
Would be nice to have MNG support.


theHand(Posted 2009) [#5]
FreeImage says that they are working on that.


ImaginaryHuman(Posted 2009) [#6]
Be interesting to see how `SavePixmapMNG` works, when it would need multiple pixmaps to save an animation. ?


markcw(Posted 2009) [#7]
This question was asked recently in this topic. It's been a while since I worked with Freeimage but from memory I don't think I ever managed to create an animated gif (only single frame gif) so either you can't or it is really difficult to figure out. I do wonder why anyone actually needs this feature but I would suggest you look at Brucey's other image modules. If all else fails you could make your own module from some C++ code such as this.


theHand(Posted 2009) [#8]
Sorry, all I could find was this.
Will find more (I hope) later.
Dredging up research:
number 0.5
number 2
Wow, spent well over an hour looking for problems people have had with FreeImage, specifically its GIF capabilities.
You just spoil us, don't you BRL? (make it easy; not a bad thing, ha)
Anyway, Retimer, I don't think that the FreeImage library really abstracts the specific details all that much, so you will probably have to become knowledgeable of the GIF specification.

From FreeImage changelog:
May 7th, 2005 - 3.7.0
! FreeImage now uses libTIFF 3.7.2
! [Ryan Rubley] improved FreeImage_OpenMultiBitmap
+ [Detlev Vendt] added FreeImage_ZLibGUnzip
+ [Herve Drolon] added new image data types FIT_RGB16, FIT_RGBA16, FIT_RGBF, FIT_RGBAF
+ [Herve Drolon] FreeImage_FlipHorizontal & FreeImage_FlipVertical now work with any bitmap type
+ [Herve Drolon] added conversions to float and double in FreeImage_ConvertToType
+ [Herve Drolon] added FreeImage_ConvertToRGBF
+ [Herve Drolon] added support for 16-, 48- and 96-bit images to FreeImage_Rescale
+ [Ryan Rubley] added FreeImage_ColorQuantizeEx
+ [Ryan Rubley] added FIMD_ANIMATION and FIDT_PALETTE
+ [Ryan Rubley] added brand new PluginGIF with full animation multipage and metadata support
+ [Herve Drolon] added support for FIC_MINISWHITE 8-bit images to FreeImage_Rescale
+ [Herve Drolon] added HDR (High Dynamic Range) format (loader & writer)
+ [Herve Drolon] added support for 48-bit images in TIFF plugin
+ [Herve Drolon] added support for 48-bit images in PNG plugin
+ [Herve Drolon] added tone mapping operators (see below)
+ added FreeImage_ToneMapping
+ added FreeImage_TmoDrago03
+ added FreeImage_TmoReinhard05
+ [Petr Pytelka] added FreeImage_JPEGTransform
* [Herve Drolon] allowed loading of corrupted JPEG with a premature end of file
* [Herve Drolon] fixed a memory leak with loading of exif JPEG images
* [Detlev Vendt] changed some 'pointer-to-int' casts to 'pointer-to-long' for 64bit machines
* [Ryan Rubley] fixed a memory leak in the multipage API
* [Ryan Rubley] updated VB6 wrapper generation for new functions
* [Herve Drolon] fixed incorrect behavior when reading JPEG comments containing special characters
* [Herve Drolon] fixed incorrect behavior when reading JPEG ICC profiles with a size greater than 64 KB
* [Herve Drolon] fixed a bug in TIFF plugin when loading malformed multipage TIFF
* [Herve Drolon] fixed PluginTIFF not being thread safe




Retimer(Posted 2009) [#9]
Anyway, Retimer, I don't think that the FreeImage library really abstracts the specific details all that much, so you will probably have to become knowledgeable of the GIF specification.


Yeah...I was afraid of that...

I've been using php to generate gifs from multiple pngs for now, but I suppose i'll give this a try sometime.

Thanks for looking deeply into it heh :)


theHand(Posted 2009) [#10]
If you know about Warner's contribution in the code archive then disregard this post.

It was (sort of) here all along: read the comments too


markcw(Posted 2009) [#11]
No that only loads gifs, he wanted to save them.


Retimer(Posted 2009) [#12]
Yeah, it requires a good amount of play with the gif specification. I managed to write my own binary write up to match the specs and save an image as a gif, but the animated gif specification gave me a lot of trouble - I haven't had the time to play with it more yet.

I'de love to get it finished and throw it up on code archives, or as a module release sometime, although I haven't studied the licensing scheme for the gif patent (I think I remember controversy within it?). I guess that would be up to the person using it.


markcw(Posted 2009) [#13]
No controversy now, the LZW patent was dropped.
http://en.wikipedia.org/wiki/Graphics_Interchange_Format#Unisys_and_LZW_patent_enforcement


Retimer(Posted 2009) [#14]
Oh, nice! Thanks...


skidracer(Posted 2009) [#15]
Retimer, if you want to contribute to this module it would be much appreciated!

http://max-edit.googlecode.com/svn/trunk/mod/axe.mod/gif.mod

example encoder, needs palette conversion and animation support:

http://max-edit.googlecode.com/svn/trunk/mod/axe.mod/gif.mod/gif/writegif.bmx