← Back

ofxGifEncoder

github.com/jesusgollonet/ofxGifEncoder · @jesusgollonet
OF 0.9 Archived GUI

openframeworks addon to export animated gifs

98 34 Last commit 8y ago Created 15y ago

Forks

Forks pushed to more recently than jesusgollonet/ofxGifEncoder itself, plus any admin-confirmed fork with commits of its own — worth checking if you're hitting issues with the original.

tangmingkai/ofxGifEncoder by @tangmingkai · ★ 0 · pushed 1y ago
danbz/ofxGifEncoder by @danbz · ★ 0 · pushed 4y ago

README

ofxGifEncoder



Export animated gifs from openframeworks.

Shameless plug

Tested with openframeworks 0.8.1 osx.

___

UNMAINTAINED : (



Unfortunately I am not using openframeworks these days and haven't had time to bring my addons up to date with recent versions. I don't have the time to review and test pull requests, so if you have an active fork that's up to date let me know and I'll include the link here.

USAGE:



There is a simple example included

create an instance of ofxGifEncoder

``C++ ofxGifEncoder gifEncoder;

call setup 
C++ gifEncoder.setup(frameW, frameH, frameDuration, nColors);

(frameDuration is a float in seconds and nColors is an int from 0 to 256.)

optionally  :) (see dithering patterns on the h file)
C++ gifEncoder.setDitherMode(OFX_GIF_DITHER_BAYER4x4);

then add frames, either as ofImages or unsigned char  
C++ gifEncoder.addFrame(foo.getPixels(), frameW, frameH);

when you're ready to save
C++ gifEncoder.save("test.gif");

If you want to do something when saving is finished, you can subscribe to the event OFX_GIF_SAVE_FINISHED 
C++ ofAddListener(ofxGifEncoder::OFX_GIF_SAVE_FINISHED, this, &testApp::onGifSaved); ... onGifSaved(string & fileName)
`

THANKS!

threaded saving, events, error checking and frame managing adapted from Nick Hardeman.

TODO:



  • (x) Transaparent gifs (currently testing)
  • Provide option to choose palette
  • proper frame compression

NOTES:



Transparency:



Experimental transparency support has been added. However, I haven't found a nice way to gracefully convert from a 32bit alpha image to an 8bit alpha image with Freeimage (openframeworks image library).

The process I'm following is sort of a green screen (check
ofxGifEncoder::convertTo24BitsWithGreenScreen):

At the moment there are 2 flaws with transparency:

I'm thinking of fixes for both.

Gif size



one thing that it's not quite there yet is appropiate gif compression, so if your images are big or you have many frames you may end up with unnecesarily fat gifs.

If you use it, I'd love to see what for. Let me know: me@jesusgollonet.com Shameless plug

LICENSE



This addon is distributed under the MIT License which means you can use it in any context: commercial or non-commercial, public or private, open or closed source.

Get this addon

HTTPS
SSH