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

前端 未结 1 836
忘了有多久
忘了有多久 2021-01-16 08:08

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.

相关标签:
1条回答
  • 2021-01-16 08:54

    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.

    0 讨论(0)
提交回复
热议问题