Exception "class com.aspose.imaging.coreexceptions.ImageLoadException: Unable to read file. Exception: Cannot invoke "com.aspose.imaging.internal.mh.g.j()" because "<local4>" is null" while spliting TIFF into multiple chunks using Aspose.Imaging for Java

Hi Team,
We are trying to split tiff file into mutiple chunks using Aspose.Imaging.
But we are facing below error. Could you please asssist us on this.
class com.aspose.imaging.coreexceptions.ImageLoadException: Unable to read file. Exception: Cannot invoke “com.aspose.imaging.internal.mh.g.j()” because “” is null com.aspose.imaging.internal.jI.R.a(Unknown Source) com.aspose.imaging.internal.jI.R.load(Unknown Source) com.aspose.imaging.Image.a(Unknown Source) com.aspose.imaging.Image.load(Unknown Source)
R1_4840.zip (2.6 MB)

Hello, @ashokreddyd ,
Could you share the code example you are using to split a TIFF image?
I have successfully tested your sample using the code below:

var inputPath = @"R1_4840.tif";
using var image = Image.Load(inputPath);
if (image is IMultipageImage multipage)
{
    var pages = multipage.Pages;
    for (int i = 0; i < pages.Length; i++)
    {
        var page = pages[i];
        page.Save($"{inputPath}-{i}.png");
    }
}

Hi Denis,
Thanks for your timely response.
Please find the below code snippet.
TiffImage tiffImage = (TiffImage) Image.load(imagePath);
TiffImage output = null;
int counter = 1;
for(TiffFrame tiffFrame : tiffImage.getFrames()) {
tiffImage.setActiveFrame(tiffFrame);
if(output == null){
output = new TiffImage(TiffFrame.copyFrame(tiffImage.getActiveFrame()));
} else {
output.addFrame(TiffFrame.copyFrame(tiffImage.getActiveFrame()));
}
if(counter % ocrBatchSize == 0){
output.save(fileName.toString(), options);
fileName = Paths.get(getUUIDFileName(outputDirectory.toString(), “.tif”));
filePaths.add(fileName.toString());
output.close();
output = null;
}
counter++;
}

Hello, @ashokreddyd ,
I see a similar topic to ours one. Has my colleague resolved your request?

Hi Denis,
Thanks for quick response. We are working on it.
Will come back to you if there any issues.