Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

read.image failing for very large images #7

Open
rossholmberg opened this issue Nov 16, 2016 · 6 comments
Open

read.image failing for very large images #7

rossholmberg opened this issue Nov 16, 2016 · 6 comments

Comments

@rossholmberg
Copy link

For images with large pixel counts (eg: 8E8 pixels), read.image returns an error, even when trying to return a small subset of the image area.

img <- RBioFormats::read.image(filename, subset = list(X=10000:10200, Y=20000:20100))

Error in .jcall(reader, "I", "getSeriesCount") :
java.lang.IllegalArgumentException: Array size > Integer.MAX_VALUE!

Seems to be a limitation of the integer class itself, which maxes out at less than 3E8. Changing "I" classes to "J" throughout read.image.R doesn't help though.

@aoles
Copy link
Owner

aoles commented Nov 16, 2016

Thanks for reporting this and for looking into it! I'm not entirely sure though whether the problem lies in the code of my package. In principle, for a single JPEG file the getSeriesCount Java method should just return 1L, therefore I'm a bit puzzled by the error. There might be something funny about this particular image file itself.

@aoles
Copy link
Owner

aoles commented Nov 16, 2016

It seems that indeed there is a problem with the original .jpeg file. After converting it to TIFF with the ImageMagick convert tool I was able to successfully run the example posted at Stack Overflow.

@rossholmberg
Copy link
Author

rossholmberg commented Nov 16, 2016

Interesting, you're right. That jpg was created with ImageMagick though, so I was curious. I converted it to tif as suggested, and it works. Convert it back to jpg again as a new file, and we get the same error again. Could it be a problem only with jpg format?

@aoles
Copy link
Owner

aoles commented Nov 16, 2016

Not with JPEG in general, as for example, the following works just fine.

filename <- system.file("img", "Rlogo.jpg", package="jpeg")

coreMetadata(read.metadata(filename))$series
## [1] 1

@rossholmberg
Copy link
Author

Sorry, I still mean for very large pixel sizes, but perhaps only when that (very large) image is jpg?

@sbesson
Copy link

sbesson commented May 8, 2017

Hi, chiming in late but I would to cross-reference this issue with the one reported upstream. Shortly, there is a known limitation/bug during the initialization of very large JPEG files. Although the description does not include the full stack trace, it sounds like a similar issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants