From 7f829b60c9e30505c86bc5849ff1d39b1163a0f4 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Tue, 21 Jul 2020 23:01:51 +1000 Subject: [PATCH] MAX_IMAGE_PIXELS can be changed --- docs/reference/Image.rst | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/docs/reference/Image.rst b/docs/reference/Image.rst index fbf61073d..c656507d9 100644 --- a/docs/reference/Image.rst +++ b/docs/reference/Image.rst @@ -53,10 +53,16 @@ Functions To protect against potential DOS attacks caused by "`decompression bombs`_" (i.e. malicious files which decompress into a huge amount of data and are designed to crash or cause disruption by using up a lot of memory), Pillow will issue a ``DecompressionBombWarning`` if the number of pixels in an - image is over a certain limit, :py:data:`PIL.Image.MAX_IMAGE_PIXELS`. If desired, the warning can be - turned into an error with ``warnings.simplefilter('error', Image.DecompressionBombWarning)`` or - suppressed entirely with ``warnings.simplefilter('ignore', Image.DecompressionBombWarning)``. See - also `the logging documentation`_ to have warnings output to the logging facility instead of stderr. + image is over a certain limit, :py:data:`PIL.Image.MAX_IMAGE_PIXELS`. + + This threshold can be changed by setting :py:data:`PIL.Image.MAX_IMAGE_PIXELS`. It can be disabled + by setting ``Image.MAX_IMAGE_PIXELS = None``. + + If desired, the warning can be turned into an error with + ``warnings.simplefilter('error', Image.DecompressionBombWarning)`` or suppressed entirely with + ``warnings.simplefilter('ignore', Image.DecompressionBombWarning)``. See also + `the logging documentation`_ to have warnings output to the logging facility instead of stderr. + If the number of pixels is greater than twice :py:data:`PIL.Image.MAX_IMAGE_PIXELS`, then a ``DecompressionBombError`` will be raised instead.