在Python中读取图像XMP数据 [英] Read image XMP data in Python
问题描述
我可以使用PIL,例如这个例子?
Can I use PIL, like in this example?
我只需读取数据,我正在寻找最简单的方法(我无法安装 pyexiv )。
I only need to read the data, and I'm looking for the easiest simplest way to do it (I can't install pyexiv).
编辑:我不想相信这样做的唯一方法是使用一些库( python-xmp-toolkit , pyexiv2 ,...)需要Exempi和Boost。必须有另一种选择!
edit: I don't want to believe that the only way to do this is with some library (python-xmp-toolkit, pyexiv2, ...) that needs Exempi and Boost. There must be another option!
推荐答案
好吧,我正在寻找类似的东西,然后我遇到了 PHP等效问题,我将anwer翻译成Python:
Well, I was looking for something similar, then I came across the PHP equivalent question and I translated the anwer to Python:
f = 'example.jpg'
fd = open(f)
d= fd.read()
xmp_start = d.find('<x:xmpmeta')
xmp_end = d.find('</x:xmpmeta')
xmp_str = d[xmp_start:xmp_end+12]
print(xmp_str)
然后你可以转换xmp_str并用XML解析它API。
you can then convert xmp_str and parse it with an XML API.
这篇关于在Python中读取图像XMP数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!