You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Pillow image.getexif()在Flatpak中执行失败,是否与版本差异有关?

Pillow版本差异导致Flatpak打包后getexif()失败?

问题情况

本地Python环境使用Pillow 8.3.2时,程序运行完全正常;但打包为Flatpak后,执行image.getexif()总是失败。Flatpak配置中使用的Pillow版本为5.4.1,请问该问题大概率由版本差异导致吗?

Python代码

import os
from PIL import Image, ExifTags, ImageOps 
from PIL.ExifTags import TAGS

if os.path.isfile(myfile):
    image = Image.open(myfile)
else:       
    return -2
try:
    image_exif = image.getexif()
except:
    test = 'image_exif failed'

Flatpak配置

- name: python3-pillow
    buildsystem: simple
    build-commands:
      - pip3 install --no-index --find-links="file://${PWD}" --prefix=${FLATPAK_DEST} Pillow
    sources:
      - type: file
        url: https://files.pythonhosted.org/packages/3c/7e/443be24431324bd34d22dd9d11cc845d995bcd3b500676bcf23142756975/Pillow-5.4.1.tar.gz
        sha256: 5233664eadfa342c639b9b9977190d64ad7aca4edc51a966394d7e08e7f38a9f

分析结论

大概率是Pillow版本差异导致的问题,原因如下:

  • Pillow在5.4.1到8.3.2的版本迭代中,对EXIF处理模块做了大量重构与bug修复:
    • 从Pillow 6.0.0开始,getexif()方法返回PIL.Image.Exif对象,而5.x版本返回字典(无EXIF数据时返回None),API行为的差异可能触发异常。
    • 5.4.1版本对部分图片格式的EXIF读取支持不完善,比如新式JPEG、带特殊EXIF数据的图片,这类场景在旧版本中读取会失败,而8.3.2已修复相关问题。

建议将Flatpak配置中的Pillow版本升级为8.3.2,重新打包测试。

内容的提问来源于stack exchange,提问作者user4588415

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.19 19:05:26