2014-06-24 64 views
5

我想在JPEG和PNG文件中读取/写入XMP元数据。有没有办法使用imagemagick读/写XMP元数据?

我能够做到这一点使用exiftool

~ $ exiftool -xmp-dc:description="FooBar" sample.png 
    1 image files updated 
~ $ exiftool sample.png | grep "Description" 
Description      : FooBar 

但是,我不能使用ImageMagick

~ $ identify -verbose sample.png | grep "Description" 

我的理由写XMP元数据是读取XMP元数据所以它可以被Adobe产品读取。

问题

  • 有没有办法使用ImageMagick读/写XMP元数据?
+0

题外话,但与Adobe产品的兼容性并不是要操作的唯一原因XMP元数据。 http://www.metadataworkinggroup.org/pdf/mwg_guidance.pdf – asp

+0

png不支持元数据 - > http://stackoverflow.com/questions/9542359/does-png-contain-exif-data-like-jpg –

+0

这只是关于EXIF元数据(尽管Exiftool和Exiv2有一个解决方法)。 PNG支持XMP元数据https://en.wikipedia.org/wiki/Extensible_Metadata_Platform#Location_in_file_types *编辑:* Bah,没有检查日期 – StarGeek

回答

1

你想问的是“ImageMagick支持读取或写入XMP(描述性)元数据吗?”。从这个问题的答案,从the documentation,是否定的。 ImageMagick读取(几乎)来自文件的所有元数据,但不读取描述性元数据。

如果出于某种原因,您必须使用ImageMagick来提取XMP元数据,那么您可以尝试添加一个过滤器。 Filters can be configured来处理图像文件,但它们不是ImageMagick本身的一部分。

1

转换-ping yourimage.jpg XMP: -

+0

谢谢,对我很好! ImageMagick 7 – Mark

+0

如何写入元数据? –

0

访问XMP数据可以做如下:

ImageMagick.XmpProfile xmp = image.GetXmpProfile(); 

Console.WriteLine("\n\n----> xmp:" + xmp); 
if (xmp != null) 
{ 
    you have to process the XML data of the XMPs result. 
    ie. use XPATH or some other XML interface. 
} 
相关问题