2

xmp 메타 데이터를 JPEG 파일에 추가하기 위해 commons io 이미징 라이브러리를 사용하고 있습니다. 위의 파일에 exiftool 실행XMP 메타 데이터 추출기로 이미지를 읽을 수 없음 XMP 데이터를

String xmpXml = "<dc:decription>some sample desc123</dc:description>"; 
    JpegXmpRewriter rewriter = new JpegXmpRewriter(); 
    rewriter.updateXmpXml(is,os, xmpXml); 

가 생성 된 XMP 위의 데이터 보여줍니다 그러나

$ exiftool 167_sample.jpg | grep "Description" 
Description     : some sample desc123 

을, 나는에서 Description 태그를 읽을 수 없습니다 metadata-extractor를 사용하여이 내가 그것을하고 있어요 어떻게 상기 :

Metadata metadata = com.drew.imaging.ImageMetadataReader.readMetadata(file.inputStream) 
for (XmpDirectory xmpDirectory : metadata.getDirectoriesOfType(XmpDirectory.class)) { 
    XMPMeta xmpMeta = xmpDirectory.getXMPMeta(); 
    XMPIterator itr = xmpMeta.iterator(); 
    while (itr.hasNext()) { 
     XMPPropertyInfo property = (XMPPropertyInfo) itr.next(); 
     System.out.println(property.getPath() + ": " + property.getValue()); 
    } 
} 

더 흥미롭게 metadata-extractor가 읽을 수 0,123 exiftool가 XMP 태그를

$ exiftool -xmp-dc:description=Manuallyaddedthis 167_sample.jpg 

Metadata metadata = com.drew.imaging.ImageMetadataReader.readMetadata(new File ("167_sample.jpg")) 
for (XmpDirectory xmpDirectory : metadata.getDirectoriesOfType(XmpDirectory.class)) { 
    XMPMeta xmpMeta = xmpDirectory.getXMPMeta(); 
    XMPIterator itr = xmpMeta.iterator(); 
    while (itr.hasNext()) { 
     XMPPropertyInfo property = (XMPPropertyInfo) itr.next(); 
     System.out.println(property.getPath() + ": " + property.getValue()); 
    } 
} 
+0

참고로이 질문은 https://github.com/drewnoakes/metadata-extractor/issues/200에서 발췌 한 것입니다. –

답변

0

메타 데이터 추출기를 만드는 데 사용되는태그에 대한 오류를 생성한다 (제 "자기 점착 라벨 ')이 문제에 연결된 이미지 :

ERROR: Error processing XMP data: XML parsing failure

더 찾고, XMP의 XML은 다음과 같은 포함 보인다

당신이 게시 코드의 첫 번째 줄에
<dc:description>some sample description</dc:description> 

, 그 이유는 분명하다.

유효한 XMP 문서가 아닙니다. Adobe의 XMPCore 라이브러리가이를 허용하지 않습니다.

유효한 XMP 문서를 생성하려면 XMPCore 라이브러리를 사용하는 것이 좋습니다. 또는 관련 상위 태그를 추가하십시오.