Skip to main content

OutOfMemory while extracting tiff headers

2 replies [Last post]
aditya_mcadu
Offline
Joined: 2006-10-11

I am trying to extract tiff headers from images using the following code.
Iterator readers = ImageIO.getImageReadersByFormatName("tiff");
if (readers.hasNext()) {
ImageReader imageReader = (ImageReader) readers.next();
imgInputStream = ImageIO.createImageInputStream(new FileInputStream(inputFile));
imageReader.setInput(imgInputStream);
IIOMetadata metadata = imageReader.getImageMetadata(imagePageNo);
}

For image sizes > 5mb, I start getting outofmemory errors. Is there a way to avoid this. Also can I somehow specify the specific tags i want to extract (If that can reduce memory requirements). I tried the three argument imageReader.getImageMetadata() but it doesnt seem to be working either.

Reply viewing options

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

Hi aditya_mcadu.

I am extracting EXIF metadata from TIFF images the same way, too. And I also
had no problems with TIFF images larger than 17MB. I tested with valid and not
valid images, both were no problam (some had an "Value offset not
word-aligned" error).

My virtual machine heap space is set to 800MB (-Xmx800m) with an 1GB machine.

Best wishes.
Stefan.

jai-imageio@javadesktop.org schrieb am 11.10.2006 12:28:
> I am trying to extract tiff headers from images using the following code.
> Iterator readers = ImageIO.getImageReadersByFormatName("tiff");
> if (readers.hasNext()) {
> ImageReader imageReader = (ImageReader) readers.next();
> imgInputStream = ImageIO.createImageInputStream(new FileInputStream(inputFile));
> imageReader.setInput(imgInputStream);
> IIOMetadata metadata = imageReader.getImageMetadata(imagePageNo);
> }
>
> For image sizes > 5mb, I start getting outofmemory errors. Is there a way to avoid this. Also can I somehow specify the specific tags i want to extract (If that can reduce memory requirements). I tried the three argument imageReader.getImageMetadata() but it doesnt seem to be working either.
> [Message sent by forum member 'aditya_mcadu' (aditya_mcadu)]
>
> http://forums.java.net/jive/thread.jspa?messageID=161870

--
Stefan E. Funk
kopal - http://kopal.langzeitarchivierung.de
Goettingen State and University Library - The Historical Library Building
Papendiek 14
37073 Goettingen, Germany
phone : +49 551 397700
mailto: funk@sub.uni-goettingen.de

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

Fabrizio Giudici

On Oct 11, 2006, at 12:28 , jai-imageio@javadesktop.org wrote:

> I am trying to extract tiff headers from images using the following
> code.
> Iterator readers = ImageIO.getImageReadersByFormatName("tiff");
> if (readers.hasNext()) {
> ImageReader imageReader = (ImageReader) readers.next();
> imgInputStream = ImageIO.createImageInputStream(new FileInputStream
> (inputFile));
> imageReader.setInput(imgInputStream);
> IIOMetadata metadata = imageReader.getImageMetadata(imagePageNo);
> }
>
> For image sizes > 5mb, I start getting outofmemory errors. Is there
> a way to avoid this. Also can I somehow specify the specific tags i
> want to extract (If that can reduce memory requirements). I tried
> the three argument imageReader.getImageMetadata() but it doesnt
> seem to be working either.
> [Message sent by forum member 'aditya_mcadu' (aditya_mcadu)]

Can you check if the images are ok? The only time I've got an OOM
while reading metadata was with corrupted files.

--
Fabrizio Giudici, Ph.D. - Java Architect, Project Manager
Tidalwave s.a.s. - "We make Java work. Everywhere."
http://www.tidalwave.it/blog - Fabrizio.Giudici@tidalwave.it
mobile: +39 348.150.6941 - fax: +39 027.005.105.36

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