Document MAXBLOCK

This commit is contained in:
Andrew Murray 2025-08-19 15:45:42 +10:00
parent 1435339290
commit c826b932c0
2 changed files with 13 additions and 0 deletions

View File

@ -74,5 +74,6 @@ Constants
--------- ---------
.. autodata:: PIL.ImageFile.LOAD_TRUNCATED_IMAGES .. autodata:: PIL.ImageFile.LOAD_TRUNCATED_IMAGES
.. autodata:: PIL.ImageFile.MAXBLOCK
.. autodata:: PIL.ImageFile.ERRORS .. autodata:: PIL.ImageFile.ERRORS
:annotation: :annotation:

View File

@ -46,6 +46,18 @@ if TYPE_CHECKING:
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
MAXBLOCK = 65536 MAXBLOCK = 65536
"""
By default, Pillow processes image data in blocks. This helps to prevent excessive use
of resources. Codecs may disable this behaviour with ``_pulls_fd`` or ``_pushes_fd``.
When reading an image, this is the number of bytes to read at once.
When writing an image, this is the number of bytes to write at once.
If the image width times 4 is greater, then that will be used instead.
Plugins may also set a greater number.
User code may set this to another number.
"""
SAFEBLOCK = 1024 * 1024 SAFEBLOCK = 1024 * 1024