首页 > 解决方案 > 从列表中获取图像标签的值

问题描述

我正在使用 python 来提取图像元数据。图像被放置在一个文件夹中,图像被添加到 python 的列表中。之后我从这些图像中提取标签和值,但它说 AttributeError: 'function' object has no attribute 'get' at value = val1.get(tagid)

代码也附上

exifdata = []

images_length = len(imagesList)

for i in range(images_length):
    metavar = imagesList[i].getexif
    exifdata.insert(i,metavar)

exif_length = len(exifdata)

for i in range(exif_length):
    for tagid in iter(exifdata):

        # getting the tag name instead of tag id
        tagname = TAGS.get(tagid, tagid)
    
        # passing the tagid to get its respective value
        val1 = exifdata[i]
        value = val1.get(tagid)
        
        # printing the final result
        print(f"{tagname:25}: {value}")

有谁知道代码有什么问题?

标签: pythonimagepython-imaging-libraryexif

解决方案


推荐阅读