Free Support Forum - aspose.com

When binarizing certain images, the engine throws an error

Executing code as simple as

var image = (RasterImage) Image.load(is);
image.binarizeFixed(175);

on the attached image throws an error:

Can't binarize image.
class com.aspose.imaging.coreexceptions.ImageException: Can't binarize image. ---> class com.aspose.imaging.coreexceptions.ImageException: Can't binarize image. ---> class com.aspose.imaging.internal.Exceptions.ArgumentException: The rectangle has no common processing area. Cannot proceed.
...

Attaching an image and the full stack trace:
example.zip (4.0 MB)

error stack trace.zip (3.4 KB)

@astafev

I have opened a ticket with ID IMAGINGJAVA-1806 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.

@astafev

Can you please consider using latest Aspose.Imaging for Java 20.12 and also increasing heapsi size to give to java 6 gigabytes of memory this way:

java -Xms6G -Xmx6G TestClass

We cannot consider it to be ab issue and its necessary to give Java at least 6Gb (six) RAM.
This is because during binarization all pages (170) of image will be loaded into memory, each page have resolution 2550x3300 pixels (4 bytes for 1 pixel), multiply it to 170 and you get 5 722 200 000 bytes for store.

To minimize this memory requirement you may use batch processing as below.

Image image = Image.load("example.tiff");
try
{
   ((IMultipageImage)image).setPageExportingAction(new PageExportingAction()
   {
       @Override
       public void invoke(int pageIndex, Image page)
       {
           ((RasterImage)page).binarizeFixed((byte)175);
       }
   });
   image.save("example-binarized.tiff");
}
finally
{
    image.close();
}

@astafev

Can you please share your feedback or we may close the issue on our end.

@astafev

Can you please share your feedback so that we can close the issue.

Hi, I don’t work on the project with aspose anymore, please close the issue.

@astafev

Thank you for sharing your feedback. We are going to close the ticket now on our end.