从枕头获取调试输出 [英] Get debug output from Pillow
问题描述
从 Python PIL错误地解码TIFF颜色(使用错误的颜色空间)?,我推断它曾经可以通过设置PIL.Image.DEBUG = True
使PIL转储一堆有用的调试输出.但是,该属性不再存在.每个 https://github.com/python-pillow/Pillow/issues/1191好像几年前已使用内置的日志记录模块取代了它.
From 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 it looks like it was replaced by usage of the built-in logging module a few years ago.
但是,如果我愿意
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()
然后,除了测试"消息外,没有任何日志记录输出.
then I get no logging output besides my 'Test' message.
我需要怎么做才能查看来自Pillow的调试日志记录?
What do I need to do to see debug logging from Pillow?
推荐答案
获取您感兴趣的TIFF输出-
To get the TIFF output that you're interested in -
from PIL import Image, TiffImagePlugin
TiffImagePlugin.DEBUG = True
Image.open('my_picture.tif')
这篇关于从枕头获取调试输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!