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:
- https://legacy.imagemagick.org/discourse-server/viewtopic.php?t=33521
- https://legacy.imagemagick.org/discourse-server/viewtopic.php?t=15740
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


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