Skip to content

Array too large Exception when using reader.read() #164

@nishantshakya

Description

@nishantshakya

I have an RGB tif image of size of 107375 x 85902 x 1. There are other images as well in around 100K X 100K. For these images, I am getting this following exception:

 File "/lib/python3.8/site-packages/bioformats/formatreader.py", line 846, in read
    planes = [
  File "/lib/python3.8/site-packages/bioformats/formatreader.py", line 848, in <listcomp>
    (rdr.openBytes(rdr.getIndex(z,i,t)) if XYWH is None else
  File "/lib/python3.8/site-packages/javabridge/jutil.py", line 961, in method
    result = call(self.o, name, sig, *args)
  File "/lib/python3.8/site-packages/javabridge/jutil.py", line 892, in call
    result = fn(*nice_args)
  File "/lib/python3.8/site-packages/javabridge/jutil.py", line 859, in fn
    raise JavaException(x)
javabridge.jutil.JavaException: Array size too large: 107375 x 85902 x 1

Is there any limit on the size of the file that the library can load? Looks like its trying to load the image into an int byte array which can only support the images up to (w*h <= Integer.MAX_SIZE). I understand there's a way to get small boxes that can fit into memory and then join them for the export. I wanted to check if there's such support from the library itself.

 with bioformats.ImageReader(image) as reader:
        out[:, :, 0] = reader.read(c=0, z=0, t=0, rescale=False)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions