Hi I have to do the same thing so here is how I solved this:
I think you can also do this:
public static void stackImages(string firstImagePath, string secondImagePath, string multiPagedImagePath)
{
using (MagickImageCollection multiPagedImage = new MagickImageCollection(firstImagePath))
{
multiPagedImage.Add(secondImagePath);
multiPagedImage.write(multiPagedImagePath);
}
}
You need only one collection which in this case represents one multi paged image.I think you can also do this:
public static void stackImages(string[] imagePathsToInsert, string multiPagedImagePath)
{
using (MagickImageCollection multiPagedImage = new MagickImageCollection())
{
foreach ( string imagePath in imagePathsToInsert)
{
multiPagedImage.Add(imagePath);
}
multiPagedImage.write(multiPagedImagePath);
}
}
Make sure that the multiPagedImagePath extension is ".tif" because not every image format supports multi layer/page.