resize of Gif file using magick++

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
luwenbin

resize of Gif file using magick++

Post by luwenbin »

Hi, magick
I met a problem when resize animated gif files. I read the image from a blob then try to resize it into a smaller one.The code are as follows
image.read(blob,"GIF");
image.zoom("100x100");
image.write("a.gif");

But the generated a.gif is not an animated image file. If I remove the code "image.zoom("100x100")", the generated a.gif is an animated file. I don't know how to resize the gif file into a smaller animated one, could you give me some help? Thanks very much!
luwenbin

Re: resize of Gif file using magick++

Post by luwenbin »

I find a way to resize gif files and make the generated file animated. The code are as follows
Blob blob((void*)data, len);
list<Image> imageList;
list<Image> coalescedList;
list<Image> resizeList;
readImages(&imageList, blob);
coalesceImages(&coalescedList, imageList.begin(), imageList.end());
list<Image>::iterator it = imageList.begin();
it = coalescedList.begin();
while(it != coalescedList.end()){
Image image = (*it);
image.zoom("100x100");
resizeList.push_back(image);
++it;
}
writeImages(resizeList.begin(), resizeList.end(), "smaller.gif");


Is this a right solution? Is there any other APIs to do the compressions?
Using this method means the compression speed rely on the number of frames in the gif file. Is there any method to optimize the solution?
Many thanks!
luwenbin

Re: resize of Gif file using magick++

Post by luwenbin »

No one knows?
Post Reply