<p>一直在四处寻找,因为<em>仍然</em>似乎没有很好的文档记录和最新的图像exif/元数据操作。在</p>
<p>我使用<code>piexif</code>得到以下代码</p>
<pre><code>import os
import piexif
for root, dirs, files in os.walk("C:\\Users\\Alan Partridge\\Desktop\\images"):
if not files:
continue
prefix = os.path.basename(root)
for f in files:
#print os.path.join(root, f)
exif_dict = piexif.load(os.path.join(root, f))
print exif_dict
for ifd in ("0th", "Exif", "GPS", "1st"):
for tag in exif_dict[ifd]:
print(piexif.TAGS[ifd][tag]["name"], exif_dict[ifd][tag])
#os.rename(os.path.join(root, f), os.path.join(root, "{} ID {}".format(prefix, f)))
</code></pre>
<p>它遍历文件夹,根据文件夹名(注释掉)重命名文件,但现在,它输出库可以找到的任何数据。在</p>
<p>目前,它可以找到<code>ImageDescription</code>,这很好。我的问题是我如何着手修改它?不幸的是,我不知道该怎么做。也许我遗漏了一些显而易见的东西?在</p>