python - 如何在 webp 图像中设置 exif 数据?

MGs*_*MGs 5 python exif setting webp

我正在尝试使用 exif 数据以 Webp 格式保存图像。Supponsenly 我已经构建了支持 webpmux 的 libwebp,但即使如此,我保存了图像,但没有保存 exif 数据。

有人能帮我吗?这是一个代码问题,或者我正在以错误的方式读取新照片的数据。

代码是:

img = PIL.Image.open(imgFile)

exif_dict = piexif.load(img.info["exif"])
exif_bytes = piexif.dump(exif_dict)

img.save(os.path.splitext(imgFile)[0] + '.webp', 'WebP', quality=80, exif=exif_bytes)  # Compress in webp
Run Code Online (Sandbox Code Playgroud)

提前致谢。

jji*_*now 0

我在 piexif 中发现了一个错误,它不能使用 img.save 在 webp 中正确保存 exif 数据,但可以使用

img.save(os.path.splitext(imgFile)[0] + '.webp', 'WebP', quality=80, exif=exif_bytes)  
piexif.insert(exif_bytes, imgFile)
Run Code Online (Sandbox Code Playgroud)