编程语言
首页 > 编程语言> > java-如何将XMP XML块序列化为现有的JPEG图像?

java-如何将XMP XML块序列化为现有的JPEG图像?

作者:互联网

我有许多JPEG图像,其中包含损坏的XMP XML块.我可以轻松地修复这些块,但是不确定如何将“修复的”数据写回到图像文件中.

我目前正在使用JAVA,但愿意接受任何可以简化此任务的事情.

这是先前要求的another question around XMP XML的目标.

解决方法:

在JAVA中,您可以使用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);

有关上述解决方案的更详细示例,Google Code上有一个开源项目,其中包含一个小型jPeg XMP XML Trimmer.

标签:java,xml,jpeg,xmp
来源: https://codeday.me/bug/20191009/1879298.html