How do you trim the XMP XML contained within a jpg

ε祈祈猫儿з 提交于 2019-12-07 18:04:39

问题


Through the use of sanselan I've found that the root cause of iPhone photos imported to windows becoming uneditable is that there is content (white space?) after the actual XML (for more details and a linked example of the bad XMP XML see https://apple.stackexchange.com/questions/45326/why-can-i-not-edit-some-photos-imported-from-an-iphone-to-windows-vista).

I'd like to scan through my photo archive and 'trim' the XMP XML.

Is there an easy way to do this?

I have some java code that can recursively navigate my photo archive and DETECT the issue. I'm not sure how to trim and write the XML back though.


回答1:


Obtain the existing XML using any means.

The following works if using the Apache Sanselan library:

String xmpXml = Sanselan.getXmpXml(new File('/path/to/jpeg'));

Then trim it...

xmpXml = xmpXml.trim();

Then write it back to the file using the solution to serializing Xmp XML to an existing jpeg.




回答2:


try the following steps:

  1. collect all of the photos in a single folder (e.g. folder xmlToConvert on your Desktop)
  2. open a Terminal.app window
  3. cd to the directory you put the files in (e.g. cd ~/Desktop/xmlToConvert)
  4. run the following command from your command line prompt

    mkdir converted ; for f in *.xml ; do cat $f | head -n $(wc -l $f) > converted/$f ; done

the converted/ sub-directory should now contain all the files without the whitespace at the end.

(i.e. a folder called converted in the xmlToConvert you created on your Desktop)

hth



来源:https://stackoverflow.com/questions/9961629/how-do-you-trim-the-xmp-xml-contained-within-a-jpg

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