从图片中提取xmp元数据时出现内存不足异常
从 tif 文件中提取元数据时,我遇到了如上所述的问题。它的大小超过 450 MB。我正在使用最新版本的 http://commons.apache.org/sanselan/ 库进行提取(0.97 )。当我执行代码:时
String xmpMeta = null;
try {
xmpMeta = Sanselan.getXmpXml(file);
} catch ...
,我得到以下堆栈跟踪:
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)
...
我必须承认我正在增加虚拟机的 Xms 和 Xmx 属性,但它也失败了,但最后我对增加此属性不感兴趣,因为我可以获得更重的图片来解析。我将不胜感激在此问题上的帮助或引用另一个库来解析 JPEG / Tif 文件中的 xmp 元数据。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
那么你可以通过调用来调用具有更多堆空间的java,
这将使用512M堆空间运行java。我知道这不是一个好的解决方案。
也许您可以尝试以下示例中的一些内容:
http://www.example -code.com/java/java-xmp-extract.asp
Well you could call java with more heap space by calling
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