旧版Pillow 库中的一个BUG引起的odoo APP在手机上竖着拍照导致出错的问题

admin 2021-5-29 172663

最近发现odoo14配合官方APP使用,用手机拍照上传图片时,当手机竖着拍照就会报错:

d:/godoo14_ce_pg12.4_20201219/runtime/python/lib/python3.7/site-packages/PIL/TiffImagePlugin.py:603: UserWarning: Metadata Warning, tag 282 had too many entries: 2, expected 1
  % (tag, len(values))
d:/godoo14_ce_pg12.4_20201219/runtime/python/lib/python3.7/site-packages/PIL/TiffImagePlugin.py:603: UserWarning: Metadata Warning, tag 283 had too many entries: 2, expected 1
  % (tag, len(values))
d:/godoo14_ce_pg12.4_20201219/runtime/python/lib/python3.7/site-packages/PIL/TiffImagePlugin.py:603: UserWarning: Metadata Warning, tag 34853 had too many entries: 9, expected 1
  % (tag, len(values))
Traceback (most recent call last):
  File "test.py", line 21, in <module>
    image = ImageOps.exif_transpose(image)
  File "d:/godoo14_ce_pg12.4_20201219/runtime/python/lib/python3.7/site-packages/PIL/ImageOps.py", line 549, in exif_transpose
    transposed_image.info["exif"] = exif.tobytes()
  File "d:/godoo14_ce_pg12.4_20201219/runtime/python/lib/python3.7/site-packages/PIL/Image.py", line 3213, in tobytes
    return b"Exif\x00\x00" + head + ifd.tobytes(offset)
  File "d:/godoo14_ce_pg12.4_20201219/runtime/python/lib/python3.7/site-packages/PIL/TiffImagePlugin.py", line 837, in tobytes
    count = len(data)
TypeError: object of type 'int' has no len()

看出错日志是在 PIL 库里出错了,网上搜了一下,有不少人报告这个BUG,这个BUG在Pillow 7.0 之前的版本存在, 再检查一下Odoo中使用的版是Pillow 6.2,卸载旧版库,安装新版(8.2)后问题解决:

D:\GOdoo14_CE_pg12.4_20201219>runtime\python\python -m pip uninstall Pillow
Uninstalling Pillow-6.1.0:
  Would remove:
    d:\godoo14_ce_pg12.4_20201219\runtime\python\lib\site-packages\pil\*
    d:\godoo14_ce_pg12.4_20201219\runtime\python\lib\site-packages\pillow-6.1.0.dist-info\*
Proceed (y/n)? y
  Successfully uninstalled Pillow-6.1.0
D:\GOdoo14_CE_pg12.4_20201219>runtime\python\python -m pip install Pillow
Collecting Pillow
  Downloading https://files.pythonhosted.org/packages/84/41/b233abcfb9bae12768bffae92e2c96d2d807cd92a3cef7d24987df0e3d64/Pillow-8.2.0-cp37-cp37m-win_amd64.whl (2.2MB)
     |████████████████████████████████| 2.2MB 44kB/s
Installing collected packages: Pillow
Successfully installed Pillow-8.2.0
WARNING: You are using pip version 19.3.1; however, version 21.1.2 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.




最新回复 (0)
返回