1
I’m trying to combine multiple TIFF files into a multipage. I am used Magick.NET but the end result is a TIFF with only the first page.
I tested with a 10-page file but only got one. I think there is a problem with the line "images.Combine()" but I’m not sure. So, what I have changes in the code so that I combine the files correctly?
Code:
public void JoinTiffJPEG(string[] imageFiles, string outFile)
{
using (MagickImageCollection images = new MagickImageCollection())
{
try
{
MagickReadSettings settings = new MagickReadSettings();
settings.Compression = CompressionMethod.JPEG;
for (int i = 0; i <= (imageFiles.Length - 1); i++)
{
MagickImage image = new MagickImage(File.ReadAllBytes(imageFiles[i]), settings);
image.Settings.Compression = CompressionMethod.JPEG;
// Add the image
images.Add(image);
}
images.Combine();
Stream output = new FileStream(outFile, FileMode.Create);
images.Write(output, MagickFormat.Tif);
//images.Dispose();
return;
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString(), "Erro", MessageBoxButtons.OK);
}
}
}
This is the content of Magickimagecollection after saving the 10 pages of the file:
Possible duplicate of Merge multiple TIFF files into one C#
– rnd_rss
@rnd_rss I published both and they are different issues. Read both ;) This is about the act of joining the Tiffs and the other era because it gave error in one line of code.
– Sofia Rodrigues
You debugged the code?
– Leandro Angelo
Yes @Leandroangelo and the
MagickImageCollection images
actually keeps the images there, but when I save and do "Write" it doesn’t keep all the pages.– Sofia Rodrigues
@Leandroangelo added a debug image.
– Sofia Rodrigues