我正在尝试收集图像元数据,但是却遇到此错误

时间:2020-08-09 17:02:16

标签: python python-imaging-library exif computer-forensics

from PIL import Image
from PIL.ExifTags import TAGS

# path to the image or video
imagename=input("Enter image path:")

# read the image data using PIL
image=Image.open(imagename)

# extract EXIF data
exifdata=image.getexif()

# in exifdata , all fields are id's not a human readable form
#  iterate over all EXIF data fields

# print(exifdata)
for tag_id in exifdata:
    # get tag name, instead of human unreadavle tag id
    tag=TAGS.get(tag_id,tag_id)
    data=exifdata.get(tag_id)
    # decode bytes
    if isinstance(data,bytes):
        data=data.decode()
        print(f"{tag:25}:{data}")

回溯(最近通话最近): 文件“ image_metadata.py”,第23行,在 数据= data.decode() UnicodeDecodeError:“ utf-8”编解码器无法解码位置1的字节0xea:无效的继续字节

error image

0 个答案:

没有答案