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!
resize of Gif file using magick++
Re: resize of Gif file using magick++
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!
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!