Exceptions while merging tiff files

Hi We are getting the following exceptions when trying to concatenate tiff files:


Exception Unable to read values for 32934 tag. Message Cannot read 48 bytes from stream.

Photometric =6 format not supported.

Compression 7 not supported.
Cannot decode srrip 0. There is no more data to read.

These are random exceptions. We have java imaging 2.1.
We did try to download the latest version however the performance of the new release is drastically slow to 2.1 when trying to run the process of merging the tiff files.
It takes over 90 sec compared to 15-20 seconds.

We are really disappointed with the product.

Are there any limitations to what kind of tiff files it can support.

Thanks
Amit

Hi Amit,


We are sorry to know of your feedback on Aspose.Imaging for Java API.

I have checked our issue database for the error Unable to read values for 32934 tag. Cannot read 48 bytes from stream. Unfortunately, I was unable to find any references so I believe the said problem could have been fixed due to the constant enhancements done to the Aspose.Imaging core. Anyway, as you have stated that you are unable to reproduce the issue with latest version of Aspose.Imaging for Java 2.6.0 so we would recommend you to upgrade the API.

Regarding the performance concerns with the latest revision of Aspose.Imaging for Java API, we require your code and sample TIFF files along with your environment details to properly investigate the scenario on our side. It is fairly possible that your code may not be optimized to accommodate the enhancements since your current version of the API. We can help you to optimize your code. In case you are still not satisfied with the performance, we will log appropriate ticket(s) to address such concerns with the future releases of Aspose.Imaging for Java API.

Please note, TiffPhotometric 6 corresponds to YCbCr color space that isn’t supported at the moment for loading or saving TIFF images. We will discuss this matter internally to provide you an estimated release schedule. TiffCompressions 7 corresponds to Jpeg compression method. We have already implemented this feature, and the implementation will be available with the next release of Aspose.Imaging for Java 2.7.0 that is scheduled for the upcoming week.

Please feel free to contact us back with your concerns.

Hi Babar


Attached is a sample tiff file for which we received Cannot decode strip 0: there is no more data to read.

We are getting this while merging two files.

Hi Amit,


We have tested both of your provided samples while using the latest version of Aspose.Imaging for Java 2.6.0, and we are able to observe ImageLoadException: Unable to read file. Exception: Cannot read 2 bytes from stream, at Image.load against the sample S150313142655977001.tif. We have logged this incident in our bug tracking system under the ticket IMAGING-34693 for further investigation & correction purposes. Please spare us little time to properly analyze the problem cause, and to provide the fix at earliest possible.

Regarding your mentioned error, could you please state if you are experiencing the Cannot decode strip 0: there is no more data to read with Aspose.Imaging for Java 2.1.0 or 2.6.0? If you are getting the said exception with latest version then please share your code along with your environment details to replicate the issue. Please also check if the samples are correct to reproduce the said problem.

This was using java 2.1.0.

The file S150313142655977001.tif is created using aspose.pdf java.

We are using the below code:

for public static byte[] convertPDFToTiff(byte[] pdfIn)


{




OutputStream baos = new ByteArrayOutputStream();




try


{


License lic= new License();


lic.setLicense(Utility.class.getClassLoader().getResourceAsStream(“Aspose.Pdf.lic”));




com.aspose.pdf.Document pdfDocument = new com.aspose.pdf.Document(new ByteArrayInputStream(pdfIn));


com.aspose.pdf.devices.Resolution resolution = new com.aspose.pdf.devices.Resolution(300);


com.aspose.pdf.devices.TiffDevice tiffDevice = new com.aspose.pdf.devices.TiffDevice(resolution);


tiffDevice.process(pdfDocument,1,1, baos);




baos.close();


}


catch(Exception e)


{


e.printStackTrace();


}




return ((ByteArrayOutputStream)baos).toByteArray();


}




public static void mergeTifs2(MergeTifResponse resp, List<byte[]> tifsIn)


{


byte[] x = new byte[1];


int pc = 0;




try


{




License lic= new License();


lic.setLicense(Utility.class.getClassLoader().getResourceAsStream(“Aspose.Pdf.lic”));




TiffImage result = new TiffImage();




for(byte[] tifData: tifsIn)


{


TiffImage source = (TiffImage)Image.load(new ByteArrayInputStream(tifData));




TiffFrame [] frames = source.getFrames();


for(int i = 0; i < frames.length; i++)


{


pc++;


result.addFrame(TiffFrame.copyFrame(frames[i]));


}//end for


}//end for




OutputStream out = new ByteArrayOutputStream();


result.save(out);




x = ((ByteArrayOutputStream)out).toByteArray();




resp.setPageCount(pc);


resp.setTifOut(x);


}


catch(Exception e)


{


e.printStackTrace();


}






}



Hi Amit,


Thank you for the details.

babar.raza:
We have tested both of your provided samples while using the latest version of Aspose.Imaging for Java 2.6.0, and we are able to observe ImageLoadException: Unable to read file. Exception: Cannot read 2 bytes from stream, at Image.load against the sample S150313142655977001.tif. We have logged this incident in our bug tracking system under the ticket IMAGING-34693 for further investigation & correction purposes. Please spare us little time to properly analyze the problem cause, and to provide the fix at earliest possible.

First of all, please discard my previous response as quoted above. The exception as stated above isn’t reproducible with latest Jars of Aspose.Imaging for Java 2.6.0. The ticket was mistakenly logged against a previous revision of the API, whereas the latest version can load and merge your samples without any issue. Please accept my apologies for the inconvenience.

I have looked for the error details (TiffImageException: Cannot decode strip 0. Details: There is no more data to read, at Image.Save) in our database and found one occurrence of it. Problem was caused due to the reason that the Aspose.Imaging’s Tiff decoder was not expecting the value of a specific Tiff tag (StripByteCount) as 0. Other decoders emit warning in such cases, and try to estimate the said value. We have used a similar approach to fix this issue with the release of Aspose.Imaging for Java 2.6.0. As the issue has already been fixed and does not reproduce anymore so there is nothing to do about this problem in the perspective of Aspose.Imaging APIs.

Regarding the performance degradation with recent revisions of Aspose.Imaging for Java API, we identified a few bottlenecks in the core component that first needs to be taken care of in the .NET version of the API. As soon as the enhancements are ported out, you will be able to observe better performance with Java API. Please also note that we have already started work to address the issues as discussed above, and the enhancements will be available for public use with the release of Aspose.Imaging for Java 2.9.0

The issues you have found earlier (filed as ) have been fixed in this Aspose.Words for JasperReports 18.3 update.