Although it is the ///
comment part internal code of the presentation code
I'm inserting the same image using the .Add ()
method of the ImageMagick.MagickImageCollection ();
class, but when I insert the second one I get the following exception,
but I insert the same image Need to reload again? I don't want to do that because it takes a lot of processing time.
Exception
System.InvalidOperationException: 'Not allowed to add the same image to the collection.'
Reference site
https://github.com/dlemstra/Magick.NET/blob/main/docs/ConvertPDF.md
Environment
OS: Windows10
IDE: Visual stuido 2022
Language: C#
API: .Net 6.0
Library: Magick , Ghostscript
using System;
public class Program
{
public static void Main()
{
ImageMagick.MagickImage img = new ImageMagick.MagickImage("input.HEIC");
ImageMagick.MagickImageCollection images = new ImageMagick.MagickImageCollection();
images.Add(img);
/////////////////////////////////////
images.Add(img);
/////////////////////////////////////
images.Add(img);
images.Add(img);
images.Add(img);
images.Write("output.pdf");
img.Dispose();
images.Dispose();
Console.WriteLine("終了");
Console.ReadKey();
}
}
CodePudding user response:
You can add the second image like this:
var img1 = new ImageMagick.MagickImage(img); ;
Then add img1
images.Add(img1);