Skip to main content

Decoding large TIFF files throws exception on getNumImages

7 replies [Last post]
zoharat
Offline
Joined: 2009-01-20
Points: 0

We have a 256MB color tiff file, which we would like to decode and render page by page.

When we decode the file and try to obtain the number of images in it, it throws the following exception.

Caused by: javax.imageio.IIOException: Couldn't seek!
at com.sun.media.imageioimpl.plugins.tiff.TIFFImageReader.locateImage(TIFFImageReader.java:256)
at com.sun.media.imageioimpl.plugins.tiff.TIFFImageReader.getNumImages(TIFFImageReader.java:279)
at com.docfinity.rendering.TiffRenderer.doDecode(TiffRenderer.java:58)
... 74 more
Caused by: java.io.EOFException
at javax.imageio.stream.ImageInputStreamImpl.readShort(ImageInputStreamImpl.java:215)
at javax.imageio.stream.ImageInputStreamImpl.readUnsignedShort(ImageInputStreamImpl.java:228)
at com.sun.media.imageioimpl.plugins.tiff.TIFFImageReader.locateImage(TIFFImageReader.java:243)
... 76 more

Are there any size restrictions on the file which could be decode by the TiffReader?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
marcojacob
Offline
Joined: 2006-07-10
Points: 0

Switching over to either MemoryCacheImageInputStream or FileCacheImageInputStream
will solve the problem. You might also receive the stream, write it to a file and then
use the file instead.

It is just a matter of performance and memory. If you have enough memory for the
image file (undecoded) you should use the first. Because you might have a memory
problem with large images you might prefer the second.

The simple wraped ImageInputStream wrapped around an InputStream is not
able to scan forward and backward for TIFF.

zoharat
Offline
Joined: 2009-01-20
Points: 0

I tried using FileCacheImageInputStream and also MemoryCacheImageInputStream, both didn't help fix my issue.

I am using JDK 1.6 rev 14.

Any other way I can get this to work?

marcojacob
Offline
Joined: 2006-07-10
Points: 0

Can you please give some code.

marcojacob
Offline
Joined: 2006-07-10
Points: 0

What are you using as Input? For TIFF you will need a seekable image input
e.g. File, FileCacheImageInputStream, MemoryCacheImageInpuitStream.

zoharat
Offline
Joined: 2009-01-20
Points: 0

Using an InputStream we create an ImageInputStream.

Using the ImageInputStream we obtain the ImageReader.

Will switching over to these other input streams solve my issue?

Also the next question I had was, if I do use these other input streams, is there a max file size I can work with?

Thanks!

Simone Giannecchini

Question 1> why you start with an InputStream? Using a File is not an option?
Question 2> which exception are you getting?
Question 3> is your tiff correct? Did you try to open it up with
another software.

Simone.
-------------------------------------------------------
Ing. Simone Giannecchini
GeoSolutions S.A.S.
Owner - Software Engineer
Via Carignoni 51
55041 Camaiore (LU)
Italy

phone: +39 0584983027
fax: +39 0584983027
mob: +39 333 8128928

http://www.geo-solutions.it
http://geo-solutions.blogspot.com/
http://simboss.blogspot.com/
http://www.linkedin.com/in/simonegiannecchini

-------------------------------------------------------

On Thu, Jul 16, 2009 at 3:36 PM, wrote:
> Using an InputStream we create an ImageInputStream.
>
> Using the ImageInputStream we obtain the ImageReader.
>
> Will switching over to these other input streams solve my issue?
>
> Also the next question I had was, if I do use these other input streams, is there a max file size I can work with?
>
> Thanks!
> [Message sent by forum member 'zoharat' (zoharat)]
>
> http://forums.java.net/jive/thread.jspa?messageID=355988
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
> For additional commands, e-mail: interest-help@jai-imageio.dev.java.net
>
>

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

zoharat
Offline
Joined: 2009-01-20
Points: 0

1. The api is written to accept an InputStream, we could switch to a file but that will be the last resort.

2. Its listed in the first post.

3. Yes TIFF is correct it open up with Windows Picture and Fax Viewer.