从 Pillow 获取调试输出

Get debug output from Pillow

Python PIL incorrectly decoding TIFF colors (using incorrect colorspace)?, I infer that it used to be possible to get PIL to dump a bunch of useful debugging output by setting PIL.Image.DEBUG = True. However, this attribute no longer exists; per https://github.com/python-pillow/Pillow/issues/1191 看来它在几年前被内置日志记录模块的使用所取代。

但是,如果我这样做

import logging
logging.root.setLevel(logging.DEBUG)
logging.debug('Test')  # Trigger installation of default StreamHandler
from PIL import Image
Image.open('my_picture.tif').show()

除了我的 'Test' 消息外,我没有得到任何日志输出。

我需要做什么才能看到 Pillow 的调试日志记录?

获取您感兴趣的 TIFF 输出 -

from PIL import Image, TiffImagePlugin
TiffImagePlugin.DEBUG = True
Image.open('my_picture.tif')