Creating Animated Gif

Hi,

I am trying to create an animated gif from a set of surfaces on Windows. Would you recommend any libraries for this purpose? I am considering running the ImageMagick tools as an external program to do the same.

Thanks,
Bala.

I just spent some time recently evaluating animated gif libraries, and there wasn’t much that was easy to use. I was concentrating on reading instead of writing, so maybe there are some good options out there. This one maybe?

If I were to do it today, I’d probably try to bundle ImageMagick or ffmpeg for pure ease of use. Let us know if you find anything worth using!

What gave the best results in the past wast to install ffmpeg and then call a shell script from within the Cinder app. That was on Mac, though. I can post something later today if you think you might go down that route.

@sharkbox, @navadria: Thank you for your input. For now, I settled for the ImageMagick binary. It is not popping up a command line window as I feared, so things are functionally okay for me. After the project, I might try pulling it in as a library.

Hey,

Did some research as wel on this topic.
Also went for ImageMagick by building a static library (OSX).
Had some issues with building the library because it uses some dynamic loading system for modules like png and jpgs
Luckily gif seems to builtin.

Creating the gif was easy than.

   std::vector<Magick::Image> frames;
    
    for(auto& i: imageList){
        Magick::Image img;
        img.read(i);
        img.animationDelay(40);
        frames.push_back(img);
    }
    
    
    try{
        std::string path = mOutputFolder + "/composition.gif";
        CI_LOG_I(path);
        Magick::writeImages(frames.begin(), frames.end(),path);
    }
    catch ( Magick::WarningConfigure & error)
    {
        CI_LOG_E( error.what());
    }
3 Likes

Finally got around to doing this. I was able to compile ImageMagick as a static library and use it for creating gif on windows. The code is the same as what @lab101 has shared above. There was a symbol clash with QuickTime, which had to be resolved. I can share the libs (vc2013) if anyone is interested.

1 Like