From 5931cc87296bab952a92b355a320aabc7ac38d3a Mon Sep 17 00:00:00 2001 From: qodelicious <162776175+qodelicious@users.noreply.github.com> Date: Thu, 22 Oct 2026 04:19:47 +0000 Subject: [PATCH 1/2] Document the compress_type save option for PNG --- docs/handbook/image-file-formats.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/handbook/image-file-formats.rst b/docs/handbook/image-file-formats.rst index 1cc01838909..bd345b8e445 100644 --- a/docs/handbook/image-file-formats.rst +++ b/docs/handbook/image-file-formats.rst @@ -955,6 +955,12 @@ The :py:meth:`~PIL.Image.Image.save` method supports the following options: When ``optimize`` option is True ``compress_level`` has no effect (it is set to 9 regardless of a value passed). +**compress_type** + ZLIB compression strategy, one of the strategy constants from Python's + :py:mod:`zlib` module: ``zlib.Z_DEFAULT_STRATEGY``, ``zlib.Z_FILTERED``, + ``zlib.Z_HUFFMAN_ONLY``, ``zlib.Z_RLE`` or ``zlib.Z_FIXED``. Defaults to + ``zlib.Z_FILTERED``. + **icc_profile** The ICC Profile to include in the saved file. From 674c3c8ac0f53331b20ef945d78a507504f18fe2 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Thu, 22 Oct 2026 20:02:15 +1100 Subject: [PATCH 2/2] Defaults to Z_DEFAULT_STRATEGY for P mode images --- docs/handbook/image-file-formats.rst | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/handbook/image-file-formats.rst b/docs/handbook/image-file-formats.rst index bd345b8e445..874cc2a3136 100644 --- a/docs/handbook/image-file-formats.rst +++ b/docs/handbook/image-file-formats.rst @@ -957,9 +957,10 @@ The :py:meth:`~PIL.Image.Image.save` method supports the following options: **compress_type** ZLIB compression strategy, one of the strategy constants from Python's - :py:mod:`zlib` module: ``zlib.Z_DEFAULT_STRATEGY``, ``zlib.Z_FILTERED``, - ``zlib.Z_HUFFMAN_ONLY``, ``zlib.Z_RLE`` or ``zlib.Z_FIXED``. Defaults to - ``zlib.Z_FILTERED``. + :py:mod:`zlib` module: ``zlib.Z_DEFAULT_STRATEGY`` (0), ``zlib.Z_FILTERED`` (1), + ``zlib.Z_HUFFMAN_ONLY`` (2), ``zlib.Z_RLE`` (3) or ``zlib.Z_FIXED`` (4). For ``P`` + images, defaults to ``zlib.Z_DEFAULT_STRATEGY`` (0). Otherwise defaults to + ``zlib.Z_FILTERED`` (1). **icc_profile** The ICC Profile to include in the saved file.