Cannot save TIFF image


#1

I am currently evaluating the Aspose APIs for the purpose of converting documents from one format to another, including TIFF -> PDF and back. I originally ran into the issue of a multi-page TIFF not converting to a multi-page PDF using the standard conversion code, and found alternate examples of code that pull out the frames of a TIFF and manually build the PDF from those. I have been trying to implement those strategies using version 19.10.0 of the .NET imaging library.

However, I’m running into an issue just saving the image frame to a stream so that it can then be added to the PDF. Ultimately, no matter what I do, I keep getting the error, “TiffImageException : Color map entries must contain 2**(bits per sample) values.” I have found no examples that sets the ColorMap property of the TiffOptions when saving an image, so I have no idea what to do here. Below is a bare-bones example that demonstrates the issue I am having. This example simply loads a TIFF image from one stream and tries to write it back to another.

using (var image = (TiffImage)Image.Load(sourceStream))
{
image.Save(targetStream, new TiffOptions(TiffExpectedFormat.TiffNoCompressionRgb));
}

What is the proper way to set the ColorMap property of TiffOptions so that it can be saved? Or is there a better way to save off a particular frame of an image that I can then add it to an Aspose.Pdf.Document?


#2

@pnijeffk,

Can you please share source file so that we may further investigate to help you out.


#3

I provided a sample of code that demonstrates the error I am running in to in my original post. The following code reads a TIFF from a stream and tries to write it to another.

using (var image = (TiffImage)Image.Load(sourceStream))
{
image.Save(targetStream, new TiffOptions(TiffExpectedFormat.TiffNoCompressionRgb));
}


#4

@pnijeffk,

Can you please share source TIFF file so that we may further investigate to help you out.