Loading/Extracting GIF frames using Magick++


There're a couple posts regarding gifs... Here's a solution that I ended up using to extract gif frames using Magick++ http://www.imagemagick.org/Magick++/

The easiest way to do this is:

  1. Download Magick++ pre built binaries for your system.
  2. Add the neccesary linker flags and include dirs to your project.
    #include <Magick++.h>

    Magick::Blob blob (yourImage.getData(), yourImage.getSize());

    list <Magick::Image> imageList;
    Magick::readImages (&imageList, blob);

    for (auto image : imageList) {
    Magick::Blob blob;

    image.write (&amp;blob, "jpeg");
    // Now load up the data from the blob for each frame using JUCE ImageFileFormat...


That's pretty much it. As far as animating... You can roll a Component that accepts a list of images and do some sort of timer based redraw.