用于在文件中读/写xmp字段的cli实用程序
xmp-tool的Python项目详细描述
这是一个读/写单个值的简单命令行实用程序 使用python-xmp-toolkit的xmp文件中的字段。
安装
从pip进行简单安装:
$ pip install xmp-tool
- 注释:python-xmp-toolkit取决于Exempi,这需要
- 为正确安装xmp而构建。
使用系统包管理器在Mac OS X上安装Exempi,使用 自制:
$ brew install exempi
在基于Debian的Linux系统上,执行以下操作:
# apt-get install libexempi-dev
用法:
$ xmp-tool -h usage: xmp-tool [-h][--value VALUE][--no-sidecar][field] file [file ...] Read or write XMP fields in a file positional arguments: field The field to read/write. If no field specified entire XMP document printed. file A file to work on optional arguments: -h, --help show this help message and exit --value VALUE A value to write to the field specified --no-sidecar Never write to sidecar files.
读取字段:
$ xmp-tool format test.jpg test.jpg: format=image/jpeg
读取文件的整个xmp内容:
$ xmp-tool test.jpg test.jpg: None=<?xpacket begin=""id="W5M0MpCehiHzreSzNTczkc9d"?> <x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="Exempi + XMP Core 5.1.2"> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> <rdf:Description rdf:about="" xmlns:dc="http://purl.org/dc/elements/1.1/"> <dc:PhysicalMedium>lto01</dc:PhysicalMedium> </rdf:Description> </rdf:RDF> </x:xmpmeta> <?xpacket end="w"?>
写入字段:
# First try to read the field when there's no data in it $ xmp-tool PhysicalMedium test.jpg test.jpeg: ERROR READING FIELD "PhysicalMedium"# Then try to add the data and then read the field $ xmp-tool PhysicalMedium --value lto01 test.jpg $ xmp-tool PhysicalMedium test.jpg test.jpg: PhysicalMedium=lto01