[Issue] aspose-image got error when convert some tiff files to any formats

Hi Aspose Support Team,
We use java aspose-imaging (version 20.4 / 21.2 / 21.4) to convert tiff file to tiff or jpg format, and got below error on some tiff image:

class com.aspose.imaging.coreexceptions.ImageSaveException: Image export failed. —> java.lang.ArrayIndexOutOfBoundsException: 1208
— End of inner exception stack trace —
com.aspose.imaging.Image.a(Unknown Source)
com.aspose.imaging.RasterImage.a(Unknown Source)
com.aspose.imaging.p.a(Unknown Source)
com.aspose.imaging.internal.ol.b.a(Unknown Source)
com.aspose.imaging.internal.ol.c.a(Unknown Source)
com.aspose.imaging.Image.save(Unknown Source)
image.demo.AsposeImageConverterUtils.convertImageToImage(AsposeImageConverterUtils.java:113)
image.demo.AsposeImageConverterUtilsTest.convertTifToTifCoruppted(AsposeImageConverterUtilsTest.java:177)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:498)
org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
org.junit.runners.ParentRunner.run(ParentRunner.java:363)
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:89)
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:41)
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:541)
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:763)
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:463)
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:209)
at com.aspose.imaging.Image.a(Unknown Source)
at com.aspose.imaging.RasterImage.a(Unknown Source)
at com.aspose.imaging.p.a(Unknown Source)
at com.aspose.imaging.internal.ol.b.a(Unknown Source)
at com.aspose.imaging.internal.ol.c.a(Unknown Source)
at com.aspose.imaging.Image.save(Unknown Source)
at image.demo.AsposeImageConverterUtils.convertImageToImage(AsposeImageConverterUtils.java:113)
at image.demo.AsposeImageConverterUtilsTest.convertTifToTifCoruppted(AsposeImageConverterUtilsTest.java:177)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:89)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:41)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:541)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:763)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:463)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:209)
Caused by: java.lang.ArrayIndexOutOfBoundsException: 1208
at com.aspose.imaging.internal.ja.c.a(Unknown Source)
at com.aspose.imaging.internal.at.c.b(Unknown Source)
at com.aspose.imaging.internal.at.c.a(Unknown Source)
at com.aspose.imaging.internal.at.x.b(Unknown Source)
at com.aspose.imaging.internal.at.x.a(Unknown Source)
at com.aspose.imaging.internal.fy.b.a(Unknown Source)
at com.aspose.imaging.internal.fy.g.a(Unknown Source)
at com.aspose.imaging.internal.ad.a.a(Unknown Source)
at com.aspose.imaging.internal.an.bg.a(Unknown Source)
at com.aspose.imaging.internal.an.bg.a(Unknown Source)
at com.aspose.imaging.internal.an.bg.a(Unknown Source)
at com.aspose.imaging.internal.fy.g.a(Unknown Source)
at com.aspose.imaging.internal.fq.f.loadPartialArgb32Pixels(Unknown Source)
at com.aspose.imaging.internal.an.be.a(Unknown Source)
at com.aspose.imaging.internal.an.bg.a(Unknown Source)
at com.aspose.imaging.internal.an.bg.a(Unknown Source)
at com.aspose.imaging.internal.an.bg.a(Unknown Source)
at com.aspose.imaging.internal.an.aE.a(Unknown Source)
at com.aspose.imaging.RasterImage.a(Unknown Source)
at com.aspose.imaging.RasterImage.loadPartialArgb32Pixels(Unknown Source)
at com.aspose.imaging.fileformats.tiff.TiffFrame.a(Unknown Source)
at com.aspose.imaging.internal.aG.L.a(Unknown Source)
at com.aspose.imaging.internal.aG.G.a(Unknown Source)
at com.aspose.imaging.internal.aG.t.a(Unknown Source)
at com.aspose.imaging.internal.aG.t.b(Unknown Source)
at com.aspose.imaging.internal.aG.t.export(Unknown Source)
… 31 more

These tiff images are production files & they are confident. So we could send you the code that we run only. Please find attached file for sample code & support us for this case.

P/S: we run convertTifToTifCoruppted method on image-converter-demo\src\test\java\image\demo\AsposeImageConverterUtilsTest.java for this case. And you need to add Aspose.Total.Java.lic file to image-converter-demo\src\main\resources to run.

We also try to save image inputstream to RandomAccessFile. After that we load this RandomAccessFile as a RasterImage, but still got below error:

com.aspose.imaging.coreexceptions.imageformats.TiffImageException: The strip 0 has corrupt data and cannot be decoded. Error: There is no more data to read.
image-converter-demo.zip (595.9 KB)

Thanks.

@slmspsvietnamvn

We have created a ticket with ID IMAGINGJAVA-7789 in our issue tracking system to further investigate and resolve the issue. This thread has been linked with the issue so that you may be notified once the issue will be fixed.

Hi mudassir.fayyaz,

Do you have any update for ticket with ID IMAGINGJAVA-7789

Thanks.

@slmspsvietnamvn

We have been unable to reproduce this issue with available files. Please note that corrupted_1.tif is not there in image-converter-demo.zip. This error could take a place if corrupted_1.tif is really corrupted. In order to process corrupted files the you should use followed snippet.

// Create an instance of LoadOptions
LoadOptions loadOptions = new LoadOptions();

// Specify the DataRecoveryMode for the object of LoadOptions
loadOptions.setDataRecoveryMode(DataRecoveryMode.ConsistentRecover);

// Specify the DataBackgroundColor for the object of LoadOptions
loadOptions.setDataBackgroundColor(Color.getRed());

// Create an instance of Image and load a damaged image by passing the
// instance of LoadOptions
Image image = Image.load(dataDir + "DataRecovery_out.tif", 

@mudassir.fayyaz

Thanks for your reply.
I tried with your suggestion but the error still the same. Process could load image, cast image to RasterImage. We could get any information from image / rasterImage like: bitDepth, width, height,… But the error happen when call rasterImage.save(bos, tiffOptions);
The image file - from our client & it’s confident. We could open and view with Window Photo Viewer app.

Could you help to take more deep into save image process? The error is Image export failed, not import failed.

Thanks

@slmspsvietnamvn

Thank you for your feedback. I have associated the information in our issue tracking system and will share feedback with you as soon as it will be shared.