Code: Select all
MagickWandGenesis();
MagickCore::MagickWand *magick_wand = NewMagickWand();
MagickCore::MagickWand *magick_wand2 = NewMagickWand();
for(std::vector<string>::iterator it = gifs.begin(); it != gifs.end(); ++it)
{
inputFileName = "C:\\Projects\\gifs\\" + *it + ".gif";
outputFileName = "C:\\Projects\\gifs\\out\\" + *it + ".gif";
MagickReadImage(magick_wand, inputFileName.c_str());
int width = MagickGetImageWidth (magick_wand);
int height = MagickGetImageHeight (magick_wand);
magick_wand2 = MagickCoalesceImages(magick_wand);
ClearMagickWand(magick_wand);
if(width > THUMBNAIL_WIDTH)
{
height = static_cast<int>(height * THUMBNAIL_WIDTH / width);
width = 144;
}
if(height > THUMBNAIL_HEIGHT)
{
width = static_cast<int>(width * THUMBNAIL_HEIGHT / height);
height = 144;
}
MagickResetIterator(magick_wand2);
while (MagickNextImage(magick_wand2) != MagickFalse)
MagickResizeImage(magick_wand2, width, height, MitchellFilter, 1 );
magick_wand = MagickOptimizeImageLayers(magick_wand2);
ClearMagickWand(magick_wand2);
MagickWriteImages(magick_wand, outputFileName.c_str(), MagickTrue);
ClearMagickWand(magick_wand);
}
DestroyMagickWand(magick_wand);
DestroyMagickWand(magick_wand2);
MagickWandTerminus();
Thank you for any assistance.