Free Support Forum - aspose.com

Tiff images not compliant with baseline 6.0 standard

Hello


I have been converting documents to Tiff format successfully but now it is required that they conform to the TIFF Baseline 6.0 standard. The testing programme that I use to check for conformity (DPF Manager - http://www.preforma-project.eu/dpfmanager-download.html) complains that LZW compression is invalid for RGB images. I could use Packbits but Aspose doesn’t seem to have that option available.

So I tried to see if Aspose.Imaging would help with this and see if I could create a non-RGB Tiff image but I have not been successful yet. Is there a way to do that?

See my attempt attached in the zip-file. Command: ‘convf word’, function: private static byte[] convertFromWord(MemoryStream instream)

Best regards
Robert Badi


Hi Robert,


Thank you for contacting support. Aspose.Imaging API allows to change the compression of tiff files to Packbits. Please refer to these help topics: Compressing TIFF Images and TiffCompressions Enumeration

Please download and use the latest version 16.12 of Aspose.Imaging for .NET API and let us know how that goes on your side.

Hi


I managed to convert a one page Word document with the following code in the using statement:

Aspose.Imaging.ImageOptions.TiffOptions optionsImg = new Aspose.Imaging.ImageOptions.TiffOptions(Aspose.Imaging.FileFormats.Tiff.Enums.TiffExpectedFormat.Default);
optionsImg.Photometric = Aspose.Imaging.FileFormats.Tiff.Enums.TiffPhotometrics.Palette;
optionsImg.Compression = Aspose.Imaging.FileFormats.Tiff.Enums.TiffCompressions.Packbits;
optionsImg.BitsPerSample = new ushort[] { 8 };
optionsImg.Palette = Aspose.Imaging.ColorPaletteHelper.Create8Bit();

However when I run the file through DPF Manager it complains that the Image IFD must have a tag X Resolution and Y Resolution. Can I add these tags myself? I have found the Tags property on the TiffOptions object but I can’t find any documentation on how to use it.

When I convert a multipage Word document I get the following error while saving the document:

{Aspose.Imaging.CoreExceptions.ImageFormats.TiffImageException: The strip 0 has corrupt data and cannot be decoded. Error: Failed to decode. The first compression code should be . Table is not ready.
at .. (Rectangle )
at .( , IList1 )</div><div> at .(Rectangle , , , Int32 , Int32 )</div><div> at . (TiffStreamReader , Rectangle , IPartialArgb32PixelLoader )</div><div> at .LoadPartialArgb32Pixels(Rectangle , IPartialArgb32PixelLoader )</div><div> at Aspose.Imaging.RasterImage.. (Rectangle )</div><div> at .( , IList1 )
at .(Rectangle , , , Int32 , Int32 )
at Aspose.Imaging.RasterImage.(Rectangle , Int32[] , Boolean , IPartialArgb32PixelLoader )
at Aspose.Imaging.RasterImage.(Rectangle , Boolean , IPartialArgb32PixelLoader )
at Aspose.Imaging.RasterImage.LoadPartialArgb32Pixels(Rectangle desiredRectangle, IPartialArgb32PixelLoader pixelLoader)
at Aspose.Imaging.FileFormats.Tiff.TiffFrame.(RasterImage , TiffStreamWriter , Boolean , TiffOptions , ExifData , XmpPacketWrapper , Rectangle )
at .Export(Image , Stream , ImageOptionsBase , Rectangle )
at Aspose.Imaging.Image.Save(Stream stream, ImageOptionsBase optionsBase, Rectangle boundsRectangle)}

Hi Robert,


Thank you for the details. Please provide us your source Word document and complete code (Aspose API related part) for the testing purposes. It’ll help us to replicate the error on our side. We’ll investigate and reply you appropriately. Your response is awaited.

Hi


Thank you for the help. Here attached is the testing program and the Word files are in App_Data\InFiles

Please change line 46 in Program.cs if you want to try the one page document.

Best regards
Robert Badi

Hi Robert,


Thank you for posting the details. We managed to replicate the said error. We’re further working over your query and will get back to you soon.

Hi Robert,

This is to update you that the issue while saving modified stream of TIFF image has been logged into our system with ID IMAGINGNET-2209. Our product team will further look into it and provide feedback. We will update you with the feedback via this forum thread.

Furthermore you can set X & Y resolution of the TIFF using following code snippet. For details please go through the link TiffOptions Class. For details on tags please visit the link TiffOptions.Tags Property.

Hope the above information helps. Feel free to contact us in case of any query or comments.

CODE:

Aspose.Imaging.ImageOptions.TiffOptions options = new Aspose.Imaging.ImageOptions.TiffOptions(Aspose.Imaging.FileFormats.Tiff.Enums.TiffExpectedFormat.Default);
options.Xresolution = new TiffRational(72);
options.Yresolution = new TiffRational(72);
//options.ResolutionSettings = new ResolutionSetting(72, 72);

Hi Robert,

We have investigated the issue in detail. It was found that there is no issue with the API. But the code snippet needs some modifications. Please use the follow lines of code instead of what you are using. We have used TiffLzwBw as TiffExpectedFormat because it will use LZW compression and bitsPerSample will automatically be set to 1 bit per pixel only format.

CODE:

using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(outstream))
{
//Aspose.Imaging.License licenceImaging = new Aspose.Imaging.License();
//licenceImaging.SetLicense("Aspose.Total.lic");
Aspose.Imaging.ImageOptions.TiffOptions optionsImg = new Aspose.Imaging.ImageOptions.TiffOptions(Aspose.Imaging.FileFormats.Tiff.Enums.TiffExpectedFormat.TiffLzwBw);
////optionsImg.Photometric = Aspose.Imaging.FileFormats.Tiff.Enums.TiffPhotometrics.Palette;
////optionsImg.Compression = Aspose.Imaging.FileFormats.Tiff.Enums.TiffCompressions.Lzw;
////optionsImg.BitsPerSample = new ushort[] { 1 };
optionsImg.Predictor = Aspose.Imaging.FileFormats.Tiff.Enums.TiffPredictor.None;
image.Save(outstream, optionsImg);
}

Dear Ikram


Thank you for your suggestion. I have made the changes but unfortunately I have two problems now.

1. I would like the document to be in color like the original. Now it is black and white.

2. Neither of my conformance checkers can open and validate the resultant tiff files. KOST-Val gives the error: “E) BitsPerSample - The validation (module E) failed because Exiftool could not read the tag.”. DPF Manager can not even open the files and gives an error that makes less sense: “IO Exception: The system can not find the path specified”. The Tiff image does open fine in Windows Photo Viewer however but is black and white as mentioned before.

See the resulting file which is attached.

Best regards
Robert Badi

Hi Robert,

This is to update you that the information shared by you has been forward to product team. They will further look into it and provide feedback. We will update you with the feedback once available via this forum thread.

Thank you. We look forward to your response as this is very important to us.


Best regards
Robert Badi

Hello again


I would like to inform you that we have found out that the original request to have TIFF images conform to Baseline 6.0 AND allow for LZW compression is invalid and is based on the misleading wording of the current regulations of the Icelandic National Archives.

Baseline 6.0 only allows for no compression or packbits for color images. TIFF extended allows for LZW.

It has been confirmed by the National Archives that acceptable TIFF documents should conform to baseline 6.0 and LZW is allowed. So this matter is no longer an issue for us.

Best regards
Robert Badi


Hi Robert,

Thank you very much for sharing updates and confirmation. The information has also been shared with the product team for future reference.

The issues you have found earlier (filed as IMAGINGNET-2209) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.