2

I have a problem like mentioned above when extracting metadata from tif file. It has size over 450 MB. I was extracting using http://commons.apache.org/sanselan/ library in newest version(0.97). When I execute code:


String xmpMeta = null;
try {
    xmpMeta = Sanselan.getXmpXml(file);
} catch ...

, I get following stack trace:


Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
        at org.apache.sanselan.common.byteSources.ByteSourceInputStream.readBlock(ByteSourceInputStream.java:65)
        at org.apache.sanselan.common.byteSources.ByteSourceInputStream.access$000(ByteSourceInputStream.java:24)
        at org.apache.sanselan.common.byteSources.ByteSourceInputStream$CacheBlock.getNext(ByteSourceInputStream.java:54)
        at org.apache.sanselan.common.byteSources.ByteSourceInputStream$CacheReadingInputStream.read(ByteSourceInputStream.java:147)
...

I have to admit that I was increasing Xms and Xmx properties of my vm and it also failed, but at the end I am not interested in increasing this properties becouse I can get heavier pictures to parse. I would be grateful for help in this issue or referencing another library to parse xmp metadata from JPEG / Tif files.

JohnyB
  • 21
  • 1
  • do you just want to extrude the metadata? Or will you need to parse the whole file? If the second, you will have to increase your memory and can't circumvent it. In the earlier case there is a solution, I'll search for it later and post it as an answer then. – Angelo Fuchs Oct 24 '11 at 10:31
  • Did you solve this issue? I'm working on a little pet project and I'm worried about the same thing given the Sanselan getXmpXml just returns the Xmp XML as a big string. at MINIMUM it'll end up using the same amount of space the Xmp XML takes up within the image. I'd much prefer Sanselan spit me back a Stream I could parse... – Randyaa Mar 23 '12 at 03:44

1 Answers1

0

Well you could call java with more heap space by calling

java -Xmx512M FooProgramm

This will run java with 512M Heap space. I know that this is not a good solution.

Maybe you could try something out of this examples:

http://www.example-code.com/java/java-xmp-extract.asp

Jonny Schubert
  • 1,393
  • 2
  • 18
  • 39