Magick++ - create gif from images

626 views Asked by At

I'm trying to create and save a gif with magick++, but every time I try, the result I have is a gif with the first image and no animations. Nothing work.

It seems that writeImages only write the first image into the gif.

I've tried:

Code

int width = 300;
int height = 200;
vector<Image> frames;

for (int i=0;i<20;i++) {
    Geometry newSize(width, height);
    Image img(newSize, Color("black"));
    img.draw({
        DrawableFont("Helvetica"),
        DrawablePointSize(30),
        DrawableText(width / 2 + i*2, height / 2, to_string(i)),
        DrawableStrokeColor(Color("white")),
        DrawableFillColor(Color("blue"))
    });
    img.animationDelay(500);
    frames.push_back(img);
}

writeImages(frames.begin(), frames.end(), "test.gif");
// Same lines according to this doc: https://www.imagemagick.org/Magick++/STL.html
Image appended;
appendImages( &appended, frames.begin(), frames.end() );
appended.write("append.gif");

Test gif

Append gif

1

There are 1 answers

1
ipStack On
DrawableText(width / 2, height / 2, to_string(i)),

... width and height are constant : try to change it for each loop