Skip to content

Commit

Permalink
Merge branch 'main' into libavif-plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
radarhere authored Jan 25, 2025
2 parents 4b29af4 + 569b785 commit 38f0d10
Show file tree
Hide file tree
Showing 10 changed files with 63 additions and 42 deletions.
17 changes: 9 additions & 8 deletions .github/workflows/test-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,12 @@ concurrency:
jobs:
build:

runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest"]
docker: [
# Run slower jobs first to give them a headstart and reduce waiting time
ubuntu-22.04-jammy-arm64v8,
ubuntu-24.04-noble-ppc64le,
ubuntu-24.04-noble-s390x,
# Then run the remainder
alpine,
amazon-2-amd64,
amazon-2023-amd64,
Expand All @@ -55,12 +51,17 @@ jobs:
]
dockerTag: [main]
include:
- docker: "ubuntu-22.04-jammy-arm64v8"
qemu-arch: "aarch64"
- docker: "ubuntu-24.04-noble-ppc64le"
os: "ubuntu-22.04"
qemu-arch: "ppc64le"
dockerTag: main
- docker: "ubuntu-24.04-noble-s390x"
os: "ubuntu-22.04"
qemu-arch: "s390x"
dockerTag: main
- docker: "ubuntu-24.04-noble-arm64v8"
os: "ubuntu-24.04-arm"
dockerTag: main

name: ${{ matrix.docker }}

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/wheels-dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ ARCHIVE_SDIR=pillow-depends-main

# Package versions for fresh source builds
FREETYPE_VERSION=2.13.3
HARFBUZZ_VERSION=10.1.0
LIBPNG_VERSION=1.6.45
HARFBUZZ_VERSION=10.2.0
LIBPNG_VERSION=1.6.46
JPEGTURBO_VERSION=3.1.0
OPENJPEG_VERSION=2.5.3
XZ_VERSION=5.6.3
XZ_VERSION=5.6.4
TIFF_VERSION=4.6.0
LCMS2_VERSION=2.16
ZLIB_NG_VERSION=2.2.3
Expand Down
2 changes: 1 addition & 1 deletion depends/install_imagequant.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# install libimagequant

archive_name=libimagequant
archive_version=4.3.3
archive_version=4.3.4

archive=$archive_name-$archive_version

Expand Down
2 changes: 1 addition & 1 deletion docs/installation/building-from-source.rst
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ Many of Pillow's features require external libraries:

* **libimagequant** provides improved color quantization

* Pillow has been tested with libimagequant **2.6-4.3.3**
* Pillow has been tested with libimagequant **2.6-4.3.4**
* Libimagequant is licensed GPLv3, which is more restrictive than
the Pillow license, therefore we will not be distributing binaries
with libimagequant support enabled.
Expand Down
6 changes: 2 additions & 4 deletions docs/installation/platform-support.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,9 @@ These platforms are built and tested for every change.
+----------------------------------+----------------------------+---------------------+
| Ubuntu Linux 22.04 LTS (Jammy) | 3.9, 3.10, 3.11, | x86-64 |
| | 3.12, 3.13, PyPy3 | |
| +----------------------------+---------------------+
| | 3.10 | arm64v8 |
+----------------------------------+----------------------------+---------------------+
| Ubuntu Linux 24.04 LTS (Noble) | 3.12 | x86-64, ppc64le, |
| | | s390x |
| Ubuntu Linux 24.04 LTS (Noble) | 3.12 | x86-64, arm64v8, |
| | | ppc64le, s390x |
+----------------------------------+----------------------------+---------------------+
| Windows Server 2019 | 3.9 | x86 |
+----------------------------------+----------------------------+---------------------+
Expand Down
1 change: 1 addition & 0 deletions docs/reference/features.rst
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ Feature version numbers are available only where stated.
Support for the following features can be checked:

* ``libjpeg_turbo``: (compile time) Whether Pillow was compiled against the libjpeg-turbo version of libjpeg. Compile-time version number is available.
* ``mozjpeg``: (compile time) Whether Pillow was compiled against the MozJPEG version of libjpeg. Compile-time version number is available.
* ``zlib_ng``: (compile time) Whether Pillow was compiled against the zlib-ng version of zlib. Compile-time version number is available.
* ``raqm``: Raqm library, required for ``ImageFont.Layout.RAQM`` in :py:func:`PIL.ImageFont.truetype`. Run-time version number is available for Raqm 0.7.0 or newer.
* ``libimagequant``: (compile time) ImageQuant quantization support in :py:func:`PIL.Image.Image.quantize`. Run-time version number is available.
Expand Down
11 changes: 8 additions & 3 deletions docs/releasenotes/11.2.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,15 @@ TODO
API Additions
=============

TODO
^^^^
Check for MozJPEG
^^^^^^^^^^^^^^^^^

TODO
You can check if Pillow has been built against the MozJPEG version of the
libjpeg library, and what version of MozJPEG is being used::

from PIL import features
features.check_feature("mozjpeg") # True or False
features.version_feature("mozjpeg") # "4.1.1" for example, or None

Other Changes
=============
Expand Down
21 changes: 3 additions & 18 deletions src/PIL/Image.py
Original file line number Diff line number Diff line change
Expand Up @@ -603,24 +603,16 @@ def _new(self, im: core.ImagingCore) -> Image:
def __enter__(self):
return self

def _close_fp(self):
if getattr(self, "_fp", False):
if self._fp != self.fp:
self._fp.close()
self._fp = DeferredError(ValueError("Operation on closed image"))
if self.fp:
self.fp.close()

def __exit__(self, *args):
if hasattr(self, "fp"):
from . import ImageFile

if isinstance(self, ImageFile.ImageFile):
if getattr(self, "_exclusive_fp", False):
self._close_fp()
self.fp = None

def close(self) -> None:
"""
Closes the file pointer, if possible.
This operation will destroy the image core and release its memory.
The image data will be unusable afterward.
Expand All @@ -629,13 +621,6 @@ def close(self) -> None:
:py:meth:`~PIL.Image.Image.load` method. See :ref:`file-handling` for
more information.
"""
if hasattr(self, "fp"):
try:
self._close_fp()
self.fp = None
except Exception as msg:
logger.debug("Error closing: %s", msg)

if getattr(self, "map", None):
self.map: mmap.mmap | None = None

Expand Down
33 changes: 32 additions & 1 deletion src/PIL/ImageFile.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,21 @@
import abc
import io
import itertools
import logging
import os
import struct
import sys
from typing import IO, TYPE_CHECKING, Any, NamedTuple, cast

from . import ExifTags, Image
from ._deprecate import deprecate
from ._util import is_path
from ._util import DeferredError, is_path

if TYPE_CHECKING:
from ._typing import StrOrBytesPath

logger = logging.getLogger(__name__)

MAXBLOCK = 65536

SAFEBLOCK = 1024 * 1024
Expand Down Expand Up @@ -163,6 +166,34 @@ def __init__(
def _open(self) -> None:
pass

def _close_fp(self):
if getattr(self, "_fp", False):
if self._fp != self.fp:
self._fp.close()
self._fp = DeferredError(ValueError("Operation on closed image"))
if self.fp:
self.fp.close()

def close(self) -> None:
"""
Closes the file pointer, if possible.
This operation will destroy the image core and release its memory.
The image data will be unusable afterward.
This function is required to close images that have multiple frames or
have not had their file read and closed by the
:py:meth:`~PIL.Image.Image.load` method. See :ref:`file-handling` for
more information.
"""
try:
self._close_fp()
self.fp = None
except Exception as msg:
logger.debug("Error closing: %s", msg)

super().close()

def get_child_images(self) -> list[ImageFile]:
child_images = []
exif = self.getexif()
Expand Down
6 changes: 3 additions & 3 deletions winbuild/build_prepare.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,14 @@ def cmd_msbuild(
"BROTLI": "1.1.0",
"FREETYPE": "2.13.3",
"FRIBIDI": "1.0.16",
"HARFBUZZ": "10.1.0",
"HARFBUZZ": "10.2.0",
"JPEGTURBO": "3.1.0",
"LCMS2": "2.16",
"LIBPNG": "1.6.45",
"LIBPNG": "1.6.46",
"LIBWEBP": "1.5.0",
"OPENJPEG": "2.5.3",
"TIFF": "4.6.0",
"XZ": "5.6.3",
"XZ": "5.6.4",
"ZLIBNG": "2.2.3",
"LIBAVIF": "1.1.1",
}
Expand Down

0 comments on commit 38f0d10

Please sign in to comment.