Skip to main content

"IOException: File too long" on JP2 ImageRead

1 reply [Last post]
scyudits
Offline
Joined: 2005-07-15
Points: 0

Hi,

I am getting a "File too long" exception when reading a JP2 image that I am told is 800MB when uncompressed. I am using -Xmx1024M. Why is this happening?

java.lang.RuntimeException: An uncaught runtime exception has occurred
at com.sun.media.imageioimpl.plugins.jpeg2000.J2KReadState.initializeRead(J2KReadState.java:604)
at com.sun.media.imageioimpl.plugins.jpeg2000.J2KReadState.(J2KReadState.java:173)
at com.sun.media.imageioimpl.plugins.jpeg2000.J2KImageReader.readHeader(J2KImageReader.java:287)
at com.sun.media.imageioimpl.plugins.jpeg2000.J2KImageReader.getHeight(J2KImageReader.java:248)
...
Caused by: java.io.IOException: File too long.
at jj2000.j2k.fileformat.reader.FileFormatReader.readFileFormat(FileFormatReader.java:204)
at com.sun.media.imageioimpl.plugins.jpeg2000.J2KReadState.initializeRead(J2KReadState.java:373)
... 8 more
Thanks,

Sophia

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Brian Burkhalter

The cause of this problem appears to be this block of code

box = in.readInt();
if (length == 0) {
lastBoxFound = true;
length = in.length()-in.getPos();
} else if(length == 1) {
longLength = in.readLong();
throw new IOException("File too long.");
} else longLength = (long) 0;

from the FileFormatReader class in JJ2000. The variable "in" is an instance of
RandomAccessIO

http://www.jpeg.org/jpeg2000guide/software/jj2000/jj2000-5.1-Doc/doc/jj2...

which unfortunately limits the return value of the length() method to a 32-bit
int unlike ImageInputStream which defines length() to return a 64-bit long.

I just filed jai-imageio-core issue #112 for this problem:

https://jai-imageio-core.dev.java.net/issues/show_bug.cgi?id=112

If this is of interest to you, please vote for this issue.

Thanks,

Brian

On Wed, 31 Jan 2007, jai-imageio@javadesktop.org wrote:

> Hi,
>
> I am getting a "File too long" exception when reading a JP2 image that I am told is 800MB when uncompressed. I am using -Xmx1024M. Why is this happening?
>
> java.lang.RuntimeException: An uncaught runtime exception has occurred
> at com.sun.media.imageioimpl.plugins.jpeg2000.J2KReadState.initializeRead(J2KReadState.java:604)
> at com.sun.media.imageioimpl.plugins.jpeg2000.J2KReadState.(J2KReadState.java:173)
> at com.sun.media.imageioimpl.plugins.jpeg2000.J2KImageReader.readHeader(J2KImageReader.java:287)
> at com.sun.media.imageioimpl.plugins.jpeg2000.J2KImageReader.getHeight(J2KImageReader.java:248)
> ...
> Caused by: java.io.IOException: File too long.
> at jj2000.j2k.fileformat.reader.FileFormatReader.readFileFormat(FileFormatReader.java:204)
> at com.sun.media.imageioimpl.plugins.jpeg2000.J2KReadState.initializeRead(J2KReadState.java:373)
> ... 8 more
> Thanks,
>
> Sophia
> [Message sent by forum member 'scyudits' (scyudits)]
>
> http://forums.java.net/jive/thread.jspa?messageID=200456
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
> For additional commands, e-mail: interest-help@jai-imageio.dev.java.net
>
>

----------------
Brian Burkhalter
Java Media, Imaging, and Graphics
Sun Microsystems, Inc.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This email message is for the sole use of the intended recipient(s)
and may contain confidential and privileged information. Any
unauthorized review, use, disclosure or distribution is prohibited.
If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
For additional commands, e-mail: interest-help@jai-imageio.dev.java.net