问题
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:
- collect all of the photos in a single folder (e.g. folder
xmlToConvert
on your Desktop) - open a Terminal.app window
- cd to the directory you put the files in (e.g.
cd ~/Desktop/xmlToConvert
) 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