How can you serialize an XMP XML block to an existing JPEG Image?

徘徊边缘 提交于 2020-01-11 07:18:09

问题


I have many JPEG images which contain corrupted XMP XML blocks. I can easily fix these blocks but I'm unsure how to write the 'fixed' data back to the image files.

I'm currently using JAVA but am open to anything that will make this task easy.

This is the goal for another question around XMP XML asked earlier.


回答1:


In JAVA you can use the Apache Sanselan library:

String newXmpXmlString = "<the><new/><xmp/><xml/></the>";
File file = new File('path/to/file');
new JpegXmpRewriter().updateXmpXml(new ByteSourceFile(file), new BufferedOutputStream(new FileOutputStream(file)), newXmpXmlString);

For a more detailed example of the solution outlined above there is an open source project on Google Code that houses a small jPeg XMP XML Trimmer.



来源:https://stackoverflow.com/questions/10265206/how-can-you-serialize-an-xmp-xml-block-to-an-existing-jpeg-image

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!