i have a problem
when i build a gif , i get the error message
Cannot access a disposed object Object name: 'ImageMagick.MagickImage'
Code: Select all
using (MagickImageCollection collection = new MagickImageCollection())
{
//combine image to MagickImage type
for (var i = 1; i <= 6; i++)
{
//combine three image to single image
using (MagickImageCollection images = new MagickImageCollection())
{
MagickImage image1 = new MagickImage(context.Server.MapPath("./template/background.png")); //background image
images.Add(image1);
MagickImage image2 = new MagickImage(UserBitmapData); //user image
images.Add(image2);
MagickImage image3 = new MagickImage(context.Server.MapPath("./template/front.png")); //front image
images.Add(image3);
using (MagickImage result = images.Mosaic())
{
//add combine result to gif collection
collection.Add(result);
collection[i-1].AnimationDelay = 0;
}
}
}
// Optionally reduce colors
QuantizeSettings settings = new QuantizeSettings();
settings.Colors = 256;
collection.Quantize(settings);
collection.Optimize();
// Save gif
collection.Write(context.Server.MapPath("done.gif"));
}