diff --git a/docs/reference/Image.rst b/docs/reference/Image.rst index 738fd8c0e..57709ce8c 100644 --- a/docs/reference/Image.rst +++ b/docs/reference/Image.rst @@ -52,11 +52,11 @@ Functions .. warning:: 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 image is over a certain - limit. 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. + 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. .. _decompression bombs: https://en.wikipedia.org/wiki/Zip_bomb .. _the logging documentation: https://docs.python.org/3/library/logging.html#integration-with-the-warnings-module diff --git a/src/PIL/Image.py b/src/PIL/Image.py index cc1cd56a5..927147956 100644 --- a/src/PIL/Image.py +++ b/src/PIL/Image.py @@ -81,7 +81,7 @@ class DecompressionBombError(Exception): pass -# Limit to around a quarter gigabyte for a 24 bit (3 bpp) image +# Limit to around a quarter gigabyte for a 24-bit (3 bpp) image MAX_IMAGE_PIXELS = int(1024 * 1024 * 1024 // 4 // 3)