Merge branch 'main' into jxl-support2
|
@ -1 +1 @@
|
|||
cibuildwheel==2.16.5
|
||||
cibuildwheel==2.17.0
|
||||
|
|
|
@ -1 +1 @@
|
|||
mypy==1.7.1
|
||||
mypy==1.9.0
|
||||
|
|
20
.github/workflows/test-cygwin.yml
vendored
|
@ -50,7 +50,7 @@ jobs:
|
|||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install Cygwin
|
||||
uses: egor-tensin/setup-cygwin@v4
|
||||
uses: cygwin/cygwin-install-action@v4
|
||||
with:
|
||||
packages: >
|
||||
gcc-g++
|
||||
|
@ -71,7 +71,6 @@ jobs:
|
|||
make
|
||||
netpbm
|
||||
perl
|
||||
python39=3.9.16-1
|
||||
python3${{ matrix.python-minor-version }}-cffi
|
||||
python3${{ matrix.python-minor-version }}-cython
|
||||
python3${{ matrix.python-minor-version }}-devel
|
||||
|
@ -89,21 +88,15 @@ jobs:
|
|||
|
||||
- name: Select Python version
|
||||
run: |
|
||||
ln -sf c:/tools/cygwin/bin/python3.${{ matrix.python-minor-version }} c:/tools/cygwin/bin/python3
|
||||
|
||||
- name: Get latest NumPy version
|
||||
id: latest-numpy
|
||||
shell: bash.exe -eo pipefail -o igncr "{0}"
|
||||
run: |
|
||||
python3 -m pip list --outdated | grep numpy | sed -r 's/ +/ /g' | cut -d ' ' -f 3 | sed 's/^/version=/' >> $GITHUB_OUTPUT
|
||||
ln -sf c:/cygwin/bin/python3.${{ matrix.python-minor-version }} c:/cygwin/bin/python3
|
||||
|
||||
- name: pip cache
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: 'C:\cygwin\home\runneradmin\.cache\pip'
|
||||
key: ${{ runner.os }}-cygwin-pip3.${{ matrix.python-minor-version }}-numpy${{ steps.latest-numpy.outputs.version }}-${{ hashFiles('.ci/install.sh') }}
|
||||
key: ${{ runner.os }}-cygwin-pip3.${{ matrix.python-minor-version }}-${{ hashFiles('.ci/install.sh') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-cygwin-pip3.${{ matrix.python-minor-version }}-numpy${{ steps.latest-numpy.outputs.version }}-
|
||||
${{ runner.os }}-cygwin-pip3.${{ matrix.python-minor-version }}-
|
||||
|
||||
- name: Build system information
|
||||
run: |
|
||||
|
@ -113,11 +106,6 @@ jobs:
|
|||
run: |
|
||||
bash.exe .ci/install.sh
|
||||
|
||||
- name: Upgrade NumPy
|
||||
shell: dash.exe -l "{0}"
|
||||
run: |
|
||||
python3 -m pip install -U "numpy<1.26"
|
||||
|
||||
- name: Build
|
||||
shell: bash.exe -eo pipefail -o igncr "{0}"
|
||||
run: |
|
||||
|
|
2
.github/workflows/test-windows.yml
vendored
|
@ -35,7 +35,7 @@ jobs:
|
|||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
python-version: ["pypy3.10", "pypy3.9", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13.0-alpha.3"]
|
||||
python-version: ["pypy3.10", "pypy3.9", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
|
||||
|
||||
timeout-minutes: 30
|
||||
|
||||
|
|
34
.github/workflows/wheels-dependencies.sh
vendored
|
@ -17,25 +17,25 @@ ARCHIVE_SDIR=pillow-depends-main
|
|||
# Package versions for fresh source builds
|
||||
FREETYPE_VERSION=2.13.2
|
||||
HARFBUZZ_VERSION=8.3.0
|
||||
LIBPNG_VERSION=1.6.40
|
||||
JPEGTURBO_VERSION=3.0.1
|
||||
LIBPNG_VERSION=1.6.43
|
||||
JPEGTURBO_VERSION=3.0.2
|
||||
OPENJPEG_VERSION=2.5.2
|
||||
XZ_VERSION=5.4.5
|
||||
TIFF_VERSION=4.6.0
|
||||
LCMS2_VERSION=2.16
|
||||
if [[ -n "$IS_MACOS" ]]; then
|
||||
GIFLIB_VERSION=5.1.4
|
||||
GIFLIB_VERSION=5.2.2
|
||||
else
|
||||
GIFLIB_VERSION=5.2.1
|
||||
fi
|
||||
if [[ -n "$IS_MACOS" ]] || [[ "$MB_ML_VER" != 2014 ]]; then
|
||||
ZLIB_VERSION=1.3
|
||||
ZLIB_VERSION=1.3.1
|
||||
else
|
||||
ZLIB_VERSION=1.2.8
|
||||
fi
|
||||
LIBWEBP_VERSION=1.3.2
|
||||
BZIP2_VERSION=1.0.8
|
||||
LIBXCB_VERSION=1.16
|
||||
LIBXCB_VERSION=1.16.1
|
||||
BROTLI_VERSION=1.1.0
|
||||
|
||||
if [[ -n "$IS_MACOS" ]] && [[ "$CIBW_ARCHS" == "x86_64" ]]; then
|
||||
|
@ -62,7 +62,7 @@ function build_brotli {
|
|||
|
||||
function build {
|
||||
if [[ -n "$IS_MACOS" ]] && [[ "$CIBW_ARCHS" == "arm64" ]]; then
|
||||
export BUILD_PREFIX="/usr/local"
|
||||
sudo chown -R runner /usr/local
|
||||
fi
|
||||
build_xz
|
||||
if [ -z "$IS_ALPINE" ] && [ -z "$IS_MACOS" ]; then
|
||||
|
@ -75,8 +75,8 @@ function build {
|
|||
build_simple xorgproto 2023.2 https://www.x.org/pub/individual/proto
|
||||
build_simple libXau 1.0.11 https://www.x.org/pub/individual/lib
|
||||
build_simple libpthread-stubs 0.5 https://xcb.freedesktop.org/dist
|
||||
if [ -f /Library/Frameworks/Python.framework/Versions/Current/share/pkgconfig/xcb-proto.pc ]; then
|
||||
cp /Library/Frameworks/Python.framework/Versions/Current/share/pkgconfig/xcb-proto.pc /Library/Frameworks/Python.framework/Versions/Current/lib/pkgconfig/xcb-proto.pc
|
||||
if [[ "$CIBW_ARCHS" == "arm64" ]]; then
|
||||
cp /usr/local/share/pkgconfig/xcb-proto.pc /usr/local/lib/pkgconfig
|
||||
fi
|
||||
else
|
||||
sed s/\${pc_sysrootdir\}// /usr/local/share/pkgconfig/xcb-proto.pc > /usr/local/lib/pkgconfig/xcb-proto.pc
|
||||
|
@ -87,11 +87,6 @@ function build {
|
|||
build_tiff
|
||||
build_libpng
|
||||
build_lcms2
|
||||
if [[ -n "$IS_MACOS" ]] && [[ "$CIBW_ARCHS" == "arm64" ]]; then
|
||||
for dylib in libjpeg.dylib libtiff.dylib liblcms2.dylib; do
|
||||
cp $BUILD_PREFIX/lib/$dylib /opt/arm64-builds/lib
|
||||
done
|
||||
fi
|
||||
build_openjpeg
|
||||
if [ -f /usr/local/lib64/libopenjp2.so ]; then
|
||||
cp /usr/local/lib64/libopenjp2.so /usr/local/lib
|
||||
|
@ -131,14 +126,19 @@ curl -fsSL -o pillow-depends-main.zip https://github.com/python-pillow/pillow-de
|
|||
untar pillow-depends-main.zip
|
||||
|
||||
if [[ -n "$IS_MACOS" ]]; then
|
||||
# webp, libtiff, libxcb cause a conflict with building webp, libtiff, libxcb
|
||||
# libtiff and libxcb cause a conflict with building libtiff and libxcb
|
||||
# libxau and libxdmcp cause an issue on macOS < 11
|
||||
# if php is installed, brew tries to reinstall these after installing openblas
|
||||
# remove cairo to fix building harfbuzz on arm64
|
||||
# remove lcms2 and libpng to fix building openjpeg on arm64
|
||||
# remove zstd to avoid inclusion on x86_64
|
||||
# remove jpeg-turbo to avoid inclusion on arm64
|
||||
# remove webp and zstd to avoid inclusion on x86_64
|
||||
# curl from brew requires zstd, use system curl
|
||||
brew remove --ignore-dependencies webp libpng libtiff libxcb libxau libxdmcp curl php cairo lcms2 ghostscript zstd
|
||||
brew remove --ignore-dependencies libpng libtiff libxcb libxau libxdmcp curl cairo lcms2 zstd
|
||||
if [[ "$CIBW_ARCHS" == "arm64" ]]; then
|
||||
brew remove --ignore-dependencies jpeg-turbo
|
||||
else
|
||||
brew remove --ignore-dependencies webp
|
||||
fi
|
||||
|
||||
brew install pkg-config
|
||||
fi
|
||||
|
|
3
.github/workflows/wheels-test.sh
vendored
|
@ -4,6 +4,9 @@ set -e
|
|||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
brew install fribidi
|
||||
export PKG_CONFIG_PATH="/usr/local/opt/openblas/lib/pkgconfig"
|
||||
if [ -f /opt/homebrew/lib/libfribidi.dylib ]; then
|
||||
sudo cp /opt/homebrew/lib/libfribidi.dylib /usr/local/lib
|
||||
fi
|
||||
elif [ "${AUDITWHEEL_POLICY::9}" == "musllinux" ]; then
|
||||
apk add curl fribidi
|
||||
else
|
||||
|
|
4
.github/workflows/wheels.yml
vendored
|
@ -99,7 +99,7 @@ jobs:
|
|||
cibw_arch: x86_64
|
||||
macosx_deployment_target: "10.10"
|
||||
- name: "macOS arm64"
|
||||
os: macos-latest
|
||||
os: macos-14
|
||||
cibw_arch: arm64
|
||||
macosx_deployment_target: "11.0"
|
||||
- name: "manylinux2014 and musllinux x86_64"
|
||||
|
@ -132,7 +132,7 @@ jobs:
|
|||
CIBW_MANYLINUX_PYPY_X86_64_IMAGE: ${{ matrix.manylinux }}
|
||||
CIBW_MANYLINUX_X86_64_IMAGE: ${{ matrix.manylinux }}
|
||||
CIBW_SKIP: pp38-*
|
||||
CIBW_TEST_SKIP: "*-macosx_arm64"
|
||||
CIBW_TEST_SKIP: cp38-macosx_arm64
|
||||
MACOSX_DEPLOYMENT_TARGET: ${{ matrix.macosx_deployment_target }}
|
||||
|
||||
- uses: actions/upload-artifact@v4
|
||||
|
|
45
CHANGES.rst
|
@ -5,6 +5,51 @@ Changelog (Pillow)
|
|||
10.3.0 (unreleased)
|
||||
-------------------
|
||||
|
||||
- Fixed joined corners for ImageDraw rounded_rectangle() non-integer dimensions #7881
|
||||
[radarhere]
|
||||
|
||||
- Stop reading EPS image at EOF marker #7753
|
||||
[radarhere]
|
||||
|
||||
- PSD layer co-ordinates may be negative #7706
|
||||
[radarhere]
|
||||
|
||||
- Use subprocess with CREATE_NO_WINDOW flag in ImageShow WindowsViewer #7791
|
||||
[radarhere]
|
||||
|
||||
- When saving GIF frame that restores to background color, do not fill identical pixels #7788
|
||||
[radarhere]
|
||||
|
||||
- Fixed reading PNG iCCP compression method #7823
|
||||
[radarhere]
|
||||
|
||||
- Allow writing IFDRational to UNDEFINED tag #7840
|
||||
[radarhere]
|
||||
|
||||
- Fix logged tag name when loading Exif data #7842
|
||||
[radarhere]
|
||||
|
||||
- Use maximum frame size in IHDR chunk when saving APNG images #7821
|
||||
[radarhere]
|
||||
|
||||
- Prevent opening P TGA images without a palette #7797
|
||||
[radarhere]
|
||||
|
||||
- Use palette when loading ICO images #7798
|
||||
[radarhere]
|
||||
|
||||
- Use consistent arguments for load_read and load_seek #7713
|
||||
[radarhere]
|
||||
|
||||
- Turn off nullability warnings for macOS SDK #7827
|
||||
[radarhere]
|
||||
|
||||
- Fix shift-sign issue in Convert.c #7838
|
||||
[r-barnes, radarhere]
|
||||
|
||||
- Open 16-bit grayscale PNGs as I;16 #7849
|
||||
[radarhere]
|
||||
|
||||
- Handle truncated chunks at the end of PNG images #7709
|
||||
[lajiyuan, radarhere]
|
||||
|
||||
|
|
|
@ -23,7 +23,10 @@ def _get_mem_usage() -> float:
|
|||
|
||||
|
||||
def _test_leak(
|
||||
min_iterations: int, max_iterations: int, fn: Callable[..., None], *args: Any
|
||||
min_iterations: int,
|
||||
max_iterations: int,
|
||||
fn: Callable[..., Image.Image | None],
|
||||
*args: Any,
|
||||
) -> None:
|
||||
mem_limit = None
|
||||
for i in range(max_iterations):
|
||||
|
|
|
@ -17,6 +17,7 @@ def test_ignore_dos_text() -> None:
|
|||
finally:
|
||||
ImageFile.LOAD_TRUNCATED_IMAGES = False
|
||||
|
||||
assert isinstance(im, PngImagePlugin.PngImageFile)
|
||||
for s in im.text.values():
|
||||
assert len(s) < 1024 * 1024, "Text chunk larger than 1M"
|
||||
|
||||
|
@ -32,6 +33,7 @@ def test_dos_text() -> None:
|
|||
assert msg, "Decompressed Data Too Large"
|
||||
return
|
||||
|
||||
assert isinstance(im, PngImagePlugin.PngImageFile)
|
||||
for s in im.text.values():
|
||||
assert len(s) < 1024 * 1024, "Text chunk larger than 1M"
|
||||
|
||||
|
@ -57,6 +59,7 @@ def test_dos_total_memory() -> None:
|
|||
return
|
||||
|
||||
total_len = 0
|
||||
assert isinstance(im2, PngImagePlugin.PngImageFile)
|
||||
for txt in im2.text.values():
|
||||
total_len += len(txt)
|
||||
assert total_len < 64 * 1024 * 1024, "Total text chunks greater than 64M"
|
||||
|
|
|
@ -351,7 +351,7 @@ def is_mingw() -> bool:
|
|||
|
||||
|
||||
class CachedProperty:
|
||||
def __init__(self, func: Callable[[Any], None]) -> None:
|
||||
def __init__(self, func: Callable[[Any], Any]) -> None:
|
||||
self.func = func
|
||||
|
||||
def __get__(self, instance: Any, cls: type[Any] | None = None) -> Any:
|
||||
|
|
Before Width: | Height: | Size: 578 B |
BIN
Tests/images/16_bit_binary_pgm.tiff
Normal file
Before Width: | Height: | Size: 298 KiB |
BIN
Tests/images/cmx3g8_wv_1998.260_0745_mcidas.tiff
Normal file
Before Width: | Height: | Size: 48 KiB After Width: | Height: | Size: 48 KiB |
Before Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 48 KiB After Width: | Height: | Size: 48 KiB |
Before Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 180 B |
BIN
Tests/images/imagedraw_rectangle_I.tiff
Normal file
BIN
Tests/images/negative_top_left_layer.psd
Normal file
BIN
Tests/images/p_8.tga
Normal file
BIN
Tests/images/unknown_compression_method.png
Normal file
After Width: | Height: | Size: 4.0 KiB |
|
@ -7,7 +7,7 @@ import fuzzers
|
|||
import packaging
|
||||
import pytest
|
||||
|
||||
from PIL import Image, features
|
||||
from PIL import Image, UnidentifiedImageError, features
|
||||
from Tests.helper import skip_unless_feature
|
||||
|
||||
if sys.platform.startswith("win32"):
|
||||
|
@ -43,7 +43,7 @@ def test_fuzz_images(path: str) -> None:
|
|||
except (
|
||||
Image.DecompressionBombError,
|
||||
Image.DecompressionBombWarning,
|
||||
Image.UnidentifiedImageError,
|
||||
UnidentifiedImageError,
|
||||
):
|
||||
# Known Image.* exceptions
|
||||
assert True
|
||||
|
|
|
@ -668,6 +668,16 @@ def test_apng_save_blend(tmp_path: Path) -> None:
|
|||
assert im.getpixel((0, 0)) == (0, 255, 0, 255)
|
||||
|
||||
|
||||
def test_apng_save_size(tmp_path: Path) -> None:
|
||||
test_file = str(tmp_path / "temp.png")
|
||||
|
||||
im = Image.new("L", (100, 100))
|
||||
im.save(test_file, save_all=True, append_images=[Image.new("L", (200, 200))])
|
||||
|
||||
with Image.open(test_file) as reloaded:
|
||||
assert reloaded.size == (200, 200)
|
||||
|
||||
|
||||
def test_seek_after_close() -> None:
|
||||
im = Image.open("Tests/images/apng/delay.png")
|
||||
im.seek(1)
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import Literal
|
||||
|
||||
import pytest
|
||||
|
||||
from PIL import ContainerIO, Image
|
||||
|
@ -21,9 +23,16 @@ def test_isatty() -> None:
|
|||
assert container.isatty() is False
|
||||
|
||||
|
||||
def test_seek_mode_0() -> None:
|
||||
@pytest.mark.parametrize(
|
||||
"mode, expected_position",
|
||||
(
|
||||
(0, 33),
|
||||
(1, 66),
|
||||
(2, 100),
|
||||
),
|
||||
)
|
||||
def test_seek_mode(mode: Literal[0, 1, 2], expected_position: int) -> None:
|
||||
# Arrange
|
||||
mode = 0
|
||||
with open(TEST_FILE, "rb") as fh:
|
||||
container = ContainerIO.ContainerIO(fh, 22, 100)
|
||||
|
||||
|
@ -32,35 +41,7 @@ def test_seek_mode_0() -> None:
|
|||
container.seek(33, mode)
|
||||
|
||||
# Assert
|
||||
assert container.tell() == 33
|
||||
|
||||
|
||||
def test_seek_mode_1() -> None:
|
||||
# Arrange
|
||||
mode = 1
|
||||
with open(TEST_FILE, "rb") as fh:
|
||||
container = ContainerIO.ContainerIO(fh, 22, 100)
|
||||
|
||||
# Act
|
||||
container.seek(33, mode)
|
||||
container.seek(33, mode)
|
||||
|
||||
# Assert
|
||||
assert container.tell() == 66
|
||||
|
||||
|
||||
def test_seek_mode_2() -> None:
|
||||
# Arrange
|
||||
mode = 2
|
||||
with open(TEST_FILE, "rb") as fh:
|
||||
container = ContainerIO.ContainerIO(fh, 22, 100)
|
||||
|
||||
# Act
|
||||
container.seek(33, mode)
|
||||
container.seek(33, mode)
|
||||
|
||||
# Assert
|
||||
assert container.tell() == 100
|
||||
assert container.tell() == expected_position
|
||||
|
||||
|
||||
@pytest.mark.parametrize("bytesmode", (True, False))
|
||||
|
|
|
@ -5,7 +5,7 @@ from pathlib import Path
|
|||
|
||||
import pytest
|
||||
|
||||
from PIL import EpsImagePlugin, Image, features
|
||||
from PIL import EpsImagePlugin, Image, UnidentifiedImageError, features
|
||||
|
||||
from .helper import (
|
||||
assert_image_similar,
|
||||
|
@ -419,7 +419,7 @@ def test_emptyline() -> None:
|
|||
)
|
||||
def test_timeout(test_file: str) -> None:
|
||||
with open(test_file, "rb") as f:
|
||||
with pytest.raises(Image.UnidentifiedImageError):
|
||||
with pytest.raises(UnidentifiedImageError):
|
||||
with Image.open(f):
|
||||
pass
|
||||
|
||||
|
@ -437,3 +437,11 @@ def test_eof_before_bounding_box() -> None:
|
|||
with pytest.raises(OSError):
|
||||
with Image.open("Tests/images/zero_bb_eof_before_boundingbox.eps"):
|
||||
pass
|
||||
|
||||
|
||||
def test_invalid_data_after_eof() -> None:
|
||||
with open("Tests/images/illuCS6_preview.eps", "rb") as f:
|
||||
img_bytes = io.BytesIO(f.read() + b"\r\n%" + (b" " * 255))
|
||||
|
||||
with Image.open(img_bytes) as img:
|
||||
assert img.mode == "RGB"
|
||||
|
|
|
@ -647,6 +647,9 @@ def test_dispose2_palette(tmp_path: Path) -> None:
|
|||
# Center remains red every frame
|
||||
assert rgb_img.getpixel((50, 50)) == circle
|
||||
|
||||
# Check that frame transparency wasn't added unnecessarily
|
||||
assert img._frame_transparency is None
|
||||
|
||||
|
||||
def test_dispose2_diff(tmp_path: Path) -> None:
|
||||
out = str(tmp_path / "temp.gif")
|
||||
|
@ -734,6 +737,25 @@ def test_dispose2_background_frame(tmp_path: Path) -> None:
|
|||
assert im.n_frames == 3
|
||||
|
||||
|
||||
def test_dispose2_previous_frame(tmp_path: Path) -> None:
|
||||
out = str(tmp_path / "temp.gif")
|
||||
|
||||
im = Image.new("P", (100, 100))
|
||||
im.info["transparency"] = 0
|
||||
d = ImageDraw.Draw(im)
|
||||
d.rectangle([(0, 0), (100, 50)], 1)
|
||||
im.putpalette((0, 0, 0, 255, 0, 0))
|
||||
|
||||
im2 = Image.new("P", (100, 100))
|
||||
im2.putpalette((0, 0, 0))
|
||||
|
||||
im.save(out, save_all=True, append_images=[im2], disposal=[0, 2])
|
||||
|
||||
with Image.open(out) as im:
|
||||
im.seek(1)
|
||||
assert im.getpixel((0, 0)) == (0, 0, 0, 255)
|
||||
|
||||
|
||||
def test_transparency_in_second_frame(tmp_path: Path) -> None:
|
||||
out = str(tmp_path / "temp.gif")
|
||||
with Image.open("Tests/images/different_transparency.gif") as im:
|
||||
|
|
|
@ -38,6 +38,17 @@ def test_black_and_white() -> None:
|
|||
assert im.size == (16, 16)
|
||||
|
||||
|
||||
def test_palette(tmp_path: Path) -> None:
|
||||
temp_file = str(tmp_path / "temp.ico")
|
||||
|
||||
im = Image.new("P", (16, 16))
|
||||
im.save(temp_file)
|
||||
|
||||
with Image.open(temp_file) as reloaded:
|
||||
assert reloaded.mode == "P"
|
||||
assert reloaded.palette is not None
|
||||
|
||||
|
||||
def test_invalid_file() -> None:
|
||||
with open("Tests/images/flower.jpg", "rb") as fp:
|
||||
with pytest.raises(SyntaxError):
|
||||
|
|
|
@ -6,7 +6,7 @@ import warnings
|
|||
from io import BytesIO
|
||||
from pathlib import Path
|
||||
from types import ModuleType
|
||||
from typing import Any
|
||||
from typing import Any, cast
|
||||
|
||||
import pytest
|
||||
|
||||
|
@ -45,14 +45,20 @@ TEST_FILE = "Tests/images/hopper.jpg"
|
|||
|
||||
@skip_unless_feature("jpg")
|
||||
class TestFileJpeg:
|
||||
def roundtrip(self, im: Image.Image, **options: Any) -> Image.Image:
|
||||
def roundtrip_with_bytes(
|
||||
self, im: Image.Image, **options: Any
|
||||
) -> tuple[JpegImagePlugin.JpegImageFile, int]:
|
||||
out = BytesIO()
|
||||
im.save(out, "JPEG", **options)
|
||||
test_bytes = out.tell()
|
||||
out.seek(0)
|
||||
im = Image.open(out)
|
||||
im.bytes = test_bytes # for testing only
|
||||
return im
|
||||
reloaded = cast(JpegImagePlugin.JpegImageFile, Image.open(out))
|
||||
return reloaded, test_bytes
|
||||
|
||||
def roundtrip(
|
||||
self, im: Image.Image, **options: Any
|
||||
) -> JpegImagePlugin.JpegImageFile:
|
||||
return self.roundtrip_with_bytes(im, **options)[0]
|
||||
|
||||
def gen_random_image(self, size: tuple[int, int], mode: str = "RGB") -> Image.Image:
|
||||
"""Generates a very hard to compress file
|
||||
|
@ -246,13 +252,13 @@ class TestFileJpeg:
|
|||
im.save(f, progressive=True, quality=94, exif=b" " * 43668)
|
||||
|
||||
def test_optimize(self) -> None:
|
||||
im1 = self.roundtrip(hopper())
|
||||
im2 = self.roundtrip(hopper(), optimize=0)
|
||||
im3 = self.roundtrip(hopper(), optimize=1)
|
||||
im1, im1_bytes = self.roundtrip_with_bytes(hopper())
|
||||
im2, im2_bytes = self.roundtrip_with_bytes(hopper(), optimize=0)
|
||||
im3, im3_bytes = self.roundtrip_with_bytes(hopper(), optimize=1)
|
||||
assert_image_equal(im1, im2)
|
||||
assert_image_equal(im1, im3)
|
||||
assert im1.bytes >= im2.bytes
|
||||
assert im1.bytes >= im3.bytes
|
||||
assert im1_bytes >= im2_bytes
|
||||
assert im1_bytes >= im3_bytes
|
||||
|
||||
def test_optimize_large_buffer(self, tmp_path: Path) -> None:
|
||||
# https://github.com/python-pillow/Pillow/issues/148
|
||||
|
@ -262,15 +268,15 @@ class TestFileJpeg:
|
|||
im.save(f, format="JPEG", optimize=True)
|
||||
|
||||
def test_progressive(self) -> None:
|
||||
im1 = self.roundtrip(hopper())
|
||||
im1, im1_bytes = self.roundtrip_with_bytes(hopper())
|
||||
im2 = self.roundtrip(hopper(), progressive=False)
|
||||
im3 = self.roundtrip(hopper(), progressive=True)
|
||||
im3, im3_bytes = self.roundtrip_with_bytes(hopper(), progressive=True)
|
||||
assert not im1.info.get("progressive")
|
||||
assert not im2.info.get("progressive")
|
||||
assert im3.info.get("progressive")
|
||||
|
||||
assert_image_equal(im1, im3)
|
||||
assert im1.bytes >= im3.bytes
|
||||
assert im1_bytes >= im3_bytes
|
||||
|
||||
def test_progressive_large_buffer(self, tmp_path: Path) -> None:
|
||||
f = str(tmp_path / "temp.jpg")
|
||||
|
@ -341,6 +347,7 @@ class TestFileJpeg:
|
|||
assert exif.get_ifd(0x8825) == {}
|
||||
|
||||
transposed = ImageOps.exif_transpose(im)
|
||||
assert transposed is not None
|
||||
exif = transposed.getexif()
|
||||
assert exif.get_ifd(0x8825) == {}
|
||||
|
||||
|
@ -419,14 +426,14 @@ class TestFileJpeg:
|
|||
assert im3.info.get("progression")
|
||||
|
||||
def test_quality(self) -> None:
|
||||
im1 = self.roundtrip(hopper())
|
||||
im2 = self.roundtrip(hopper(), quality=50)
|
||||
im1, im1_bytes = self.roundtrip_with_bytes(hopper())
|
||||
im2, im2_bytes = self.roundtrip_with_bytes(hopper(), quality=50)
|
||||
assert_image(im1, im2.mode, im2.size)
|
||||
assert im1.bytes >= im2.bytes
|
||||
assert im1_bytes >= im2_bytes
|
||||
|
||||
im3 = self.roundtrip(hopper(), quality=0)
|
||||
im3, im3_bytes = self.roundtrip_with_bytes(hopper(), quality=0)
|
||||
assert_image(im1, im3.mode, im3.size)
|
||||
assert im2.bytes > im3.bytes
|
||||
assert im2_bytes > im3_bytes
|
||||
|
||||
def test_smooth(self) -> None:
|
||||
im1 = self.roundtrip(hopper())
|
||||
|
@ -986,13 +993,7 @@ class TestFileJpeg:
|
|||
def decode(self, buffer: bytes) -> tuple[int, int]:
|
||||
return 0, 0
|
||||
|
||||
decoder = InfiniteMockPyDecoder(None)
|
||||
|
||||
def closure(mode: str, *args) -> InfiniteMockPyDecoder:
|
||||
decoder.__init__(mode, *args)
|
||||
return decoder
|
||||
|
||||
Image.register_decoder("INFINITE", closure)
|
||||
Image.register_decoder("INFINITE", InfiniteMockPyDecoder)
|
||||
|
||||
with Image.open(TEST_FILE) as im:
|
||||
im.tile = [
|
||||
|
|
|
@ -40,10 +40,8 @@ test_card.load()
|
|||
def roundtrip(im: Image.Image, **options: Any) -> Image.Image:
|
||||
out = BytesIO()
|
||||
im.save(out, "JPEG2000", **options)
|
||||
test_bytes = out.tell()
|
||||
out.seek(0)
|
||||
with Image.open(out) as im:
|
||||
im.bytes = test_bytes # for testing only
|
||||
im.load()
|
||||
return im
|
||||
|
||||
|
@ -77,7 +75,9 @@ def test_invalid_file() -> None:
|
|||
def test_bytesio() -> None:
|
||||
with open("Tests/images/test-card-lossless.jp2", "rb") as f:
|
||||
data = BytesIO(f.read())
|
||||
assert_image_similar_tofile(test_card, data, 1.0e-3)
|
||||
with Image.open(data) as im:
|
||||
im.load()
|
||||
assert_image_similar(im, test_card, 1.0e-3)
|
||||
|
||||
|
||||
# These two test pre-written JPEG 2000 files that were not written with
|
||||
|
@ -340,6 +340,7 @@ def test_parser_feed() -> None:
|
|||
p.feed(data)
|
||||
|
||||
# Assert
|
||||
assert p.image is not None
|
||||
assert p.image.size == (640, 480)
|
||||
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ from .helper import (
|
|||
|
||||
@skip_unless_feature("libtiff")
|
||||
class LibTiffTestCase:
|
||||
def _assert_noerr(self, tmp_path: Path, im: Image.Image) -> None:
|
||||
def _assert_noerr(self, tmp_path: Path, im: TiffImagePlugin.TiffImageFile) -> None:
|
||||
"""Helper tests that assert basic sanity about the g4 tiff reading"""
|
||||
# 1 bit
|
||||
assert im.mode == "1"
|
||||
|
@ -524,7 +524,8 @@ class TestFileLibTiff(LibTiffTestCase):
|
|||
im.save(out, compression=compression)
|
||||
|
||||
def test_fp_leak(self) -> None:
|
||||
im = Image.open("Tests/images/hopper_g4_500.tif")
|
||||
im: Image.Image | None = Image.open("Tests/images/hopper_g4_500.tif")
|
||||
assert im is not None
|
||||
fn = im.fp.fileno()
|
||||
|
||||
os.fstat(fn)
|
||||
|
@ -716,6 +717,7 @@ class TestFileLibTiff(LibTiffTestCase):
|
|||
f.write(src.read())
|
||||
|
||||
im = Image.open(tmpfile)
|
||||
assert isinstance(im, TiffImagePlugin.TiffImageFile)
|
||||
im.n_frames
|
||||
im.close()
|
||||
# Should not raise PermissionError.
|
||||
|
@ -1097,6 +1099,7 @@ class TestFileLibTiff(LibTiffTestCase):
|
|||
|
||||
with Image.open(out) as im:
|
||||
# Assert that there are multiple strips
|
||||
assert isinstance(im, TiffImagePlugin.TiffImageFile)
|
||||
assert len(im.tag_v2[STRIPOFFSETS]) > 1
|
||||
|
||||
@pytest.mark.parametrize("argument", (True, False))
|
||||
|
@ -1113,6 +1116,7 @@ class TestFileLibTiff(LibTiffTestCase):
|
|||
im.save(out, **arguments)
|
||||
|
||||
with Image.open(out) as im:
|
||||
assert isinstance(im, TiffImagePlugin.TiffImageFile)
|
||||
assert len(im.tag_v2[STRIPOFFSETS]) == 1
|
||||
finally:
|
||||
TiffImagePlugin.STRIP_SIZE = 65536
|
||||
|
|
|
@ -19,7 +19,7 @@ def test_valid_file() -> None:
|
|||
# https://ghrc.nsstc.nasa.gov/hydro/details/cmx3g8
|
||||
# https://ghrc.nsstc.nasa.gov/pub/fieldCampaigns/camex3/cmx3g8/browse/
|
||||
test_file = "Tests/images/cmx3g8_wv_1998.260_0745_mcidas.ara"
|
||||
saved_file = "Tests/images/cmx3g8_wv_1998.260_0745_mcidas.png"
|
||||
saved_file = "Tests/images/cmx3g8_wv_1998.260_0745_mcidas.tiff"
|
||||
|
||||
# Act
|
||||
with Image.open(test_file) as im:
|
||||
|
|
|
@ -2,11 +2,11 @@ from __future__ import annotations
|
|||
|
||||
import warnings
|
||||
from io import BytesIO
|
||||
from typing import Any
|
||||
from typing import Any, cast
|
||||
|
||||
import pytest
|
||||
|
||||
from PIL import Image
|
||||
from PIL import Image, MpoImagePlugin
|
||||
|
||||
from .helper import (
|
||||
assert_image_equal,
|
||||
|
@ -20,14 +20,11 @@ test_files = ["Tests/images/sugarshack.mpo", "Tests/images/frozenpond.mpo"]
|
|||
pytestmark = skip_unless_feature("jpg")
|
||||
|
||||
|
||||
def roundtrip(im: Image.Image, **options: Any) -> Image.Image:
|
||||
def roundtrip(im: Image.Image, **options: Any) -> MpoImagePlugin.MpoImageFile:
|
||||
out = BytesIO()
|
||||
im.save(out, "MPO", **options)
|
||||
test_bytes = out.tell()
|
||||
out.seek(0)
|
||||
im = Image.open(out)
|
||||
im.bytes = test_bytes # for testing only
|
||||
return im
|
||||
return cast(MpoImagePlugin.MpoImageFile, Image.open(out))
|
||||
|
||||
|
||||
@pytest.mark.parametrize("test_file", test_files)
|
||||
|
|
|
@ -7,7 +7,7 @@ import zlib
|
|||
from io import BytesIO
|
||||
from pathlib import Path
|
||||
from types import ModuleType
|
||||
from typing import Any
|
||||
from typing import Any, cast
|
||||
|
||||
import pytest
|
||||
|
||||
|
@ -59,11 +59,11 @@ def load(data: bytes) -> Image.Image:
|
|||
return Image.open(BytesIO(data))
|
||||
|
||||
|
||||
def roundtrip(im: Image.Image, **options: Any) -> Image.Image:
|
||||
def roundtrip(im: Image.Image, **options: Any) -> PngImagePlugin.PngImageFile:
|
||||
out = BytesIO()
|
||||
im.save(out, "PNG", **options)
|
||||
out.seek(0)
|
||||
return Image.open(out)
|
||||
return cast(PngImagePlugin.PngImageFile, Image.open(out))
|
||||
|
||||
|
||||
@skip_unless_feature("zlib")
|
||||
|
@ -102,7 +102,7 @@ class TestFilePng:
|
|||
im = hopper(mode)
|
||||
im.save(test_file)
|
||||
with Image.open(test_file) as reloaded:
|
||||
if mode in ("I;16", "I;16B"):
|
||||
if mode in ("I", "I;16B"):
|
||||
reloaded = reloaded.convert(mode)
|
||||
assert_image_equal(reloaded, im)
|
||||
|
||||
|
@ -304,8 +304,8 @@ class TestFilePng:
|
|||
assert im.getcolors() == [(100, (0, 0, 0, 0))]
|
||||
|
||||
def test_save_grayscale_transparency(self, tmp_path: Path) -> None:
|
||||
for mode, num_transparent in {"1": 1994, "L": 559, "I": 559}.items():
|
||||
in_file = "Tests/images/" + mode.lower() + "_trns.png"
|
||||
for mode, num_transparent in {"1": 1994, "L": 559, "I;16": 559}.items():
|
||||
in_file = "Tests/images/" + mode.split(";")[0].lower() + "_trns.png"
|
||||
with Image.open(in_file) as im:
|
||||
assert im.mode == mode
|
||||
assert im.info["transparency"] == 255
|
||||
|
@ -619,6 +619,10 @@ class TestFilePng:
|
|||
with Image.open("Tests/images/hopper_idat_after_image_end.png") as im:
|
||||
assert im.text == {"TXT": "VALUE", "ZIP": "VALUE"}
|
||||
|
||||
def test_unknown_compression_method(self) -> None:
|
||||
with pytest.raises(SyntaxError, match="Unknown compression method"):
|
||||
PngImagePlugin.PngImageFile("Tests/images/unknown_compression_method.png")
|
||||
|
||||
def test_padded_idat(self) -> None:
|
||||
# This image has been manually hexedited
|
||||
# so that the IDAT chunk has padding at the end
|
||||
|
|
|
@ -88,7 +88,7 @@ def test_16bit_pgm() -> None:
|
|||
assert im.size == (20, 100)
|
||||
assert im.get_format_mimetype() == "image/x-portable-graymap"
|
||||
|
||||
assert_image_equal_tofile(im, "Tests/images/16_bit_binary_pgm.png")
|
||||
assert_image_equal_tofile(im, "Tests/images/16_bit_binary_pgm.tiff")
|
||||
|
||||
|
||||
def test_16bit_pgm_write(tmp_path: Path) -> None:
|
||||
|
|
|
@ -4,7 +4,7 @@ import warnings
|
|||
|
||||
import pytest
|
||||
|
||||
from PIL import Image, PsdImagePlugin
|
||||
from PIL import Image, PsdImagePlugin, UnidentifiedImageError
|
||||
|
||||
from .helper import assert_image_equal_tofile, assert_image_similar, hopper, is_pypy
|
||||
|
||||
|
@ -113,6 +113,11 @@ def test_rgba() -> None:
|
|||
assert_image_equal_tofile(im, "Tests/images/imagedraw_square.png")
|
||||
|
||||
|
||||
def test_negative_top_left_layer() -> None:
|
||||
with Image.open("Tests/images/negative_top_left_layer.psd") as im:
|
||||
assert im.layers[0][2] == (-50, -50, 50, 50)
|
||||
|
||||
|
||||
def test_layer_skip() -> None:
|
||||
with Image.open("Tests/images/five_channels.psd") as im:
|
||||
assert im.n_frames == 1
|
||||
|
@ -147,11 +152,11 @@ def test_combined_larger_than_size() -> None:
|
|||
[
|
||||
(
|
||||
"Tests/images/timeout-1ee28a249896e05b83840ae8140622de8e648ba9.psd",
|
||||
Image.UnidentifiedImageError,
|
||||
UnidentifiedImageError,
|
||||
),
|
||||
(
|
||||
"Tests/images/timeout-598843abc37fc080ec36a2699ebbd44f795d3a6f.psd",
|
||||
Image.UnidentifiedImageError,
|
||||
UnidentifiedImageError,
|
||||
),
|
||||
("Tests/images/timeout-c8efc3fded6426986ba867a399791bae544f59bc.psd", OSError),
|
||||
("Tests/images/timeout-dedc7a4ebd856d79b4359bbcc79e8ef231ce38f6.psd", OSError),
|
||||
|
|
|
@ -9,7 +9,7 @@ import pytest
|
|||
|
||||
from PIL import Image, ImageSequence, SpiderImagePlugin
|
||||
|
||||
from .helper import assert_image_equal_tofile, hopper, is_pypy
|
||||
from .helper import assert_image_equal, hopper, is_pypy
|
||||
|
||||
TEST_FILE = "Tests/images/hopper.spider"
|
||||
|
||||
|
@ -160,4 +160,5 @@ def test_odd_size() -> None:
|
|||
im.save(data, format="SPIDER")
|
||||
|
||||
data.seek(0)
|
||||
assert_image_equal_tofile(im, data)
|
||||
with Image.open(data) as im2:
|
||||
assert_image_equal(im, im2)
|
||||
|
|
|
@ -7,7 +7,7 @@ from pathlib import Path
|
|||
|
||||
import pytest
|
||||
|
||||
from PIL import Image
|
||||
from PIL import Image, UnidentifiedImageError
|
||||
|
||||
from .helper import assert_image_equal, assert_image_equal_tofile, hopper
|
||||
|
||||
|
@ -65,6 +65,11 @@ def test_sanity(mode: str, tmp_path: Path) -> None:
|
|||
roundtrip(original_im)
|
||||
|
||||
|
||||
def test_palette_depth_8(tmp_path: Path) -> None:
|
||||
with pytest.raises(UnidentifiedImageError):
|
||||
Image.open("Tests/images/p_8.tga")
|
||||
|
||||
|
||||
def test_palette_depth_16(tmp_path: Path) -> None:
|
||||
with Image.open("Tests/images/p_16.tga") as im:
|
||||
assert_image_equal_tofile(im.convert("RGB"), "Tests/images/p_16.png")
|
||||
|
@ -133,6 +138,11 @@ def test_small_palette(tmp_path: Path) -> None:
|
|||
assert reloaded.getpalette() == colors
|
||||
|
||||
|
||||
def test_missing_palette() -> None:
|
||||
with Image.open("Tests/images/dilation4.lut") as im:
|
||||
assert im.mode == "L"
|
||||
|
||||
|
||||
def test_save_wrong_mode(tmp_path: Path) -> None:
|
||||
im = hopper("PA")
|
||||
out = str(tmp_path / "temp.tga")
|
||||
|
|
|
@ -623,6 +623,7 @@ class TestFileTiff:
|
|||
im.save(outfile, tiffinfo={278: 256})
|
||||
|
||||
with Image.open(outfile) as im:
|
||||
assert isinstance(im, TiffImagePlugin.TiffImageFile)
|
||||
assert im.tag_v2[278] == 256
|
||||
|
||||
def test_strip_raw(self) -> None:
|
||||
|
|
|
@ -224,14 +224,17 @@ def test_writing_other_types_to_bytes(value: int | IFDRational, tmp_path: Path)
|
|||
assert reloaded.tag_v2[700] == b"\x01"
|
||||
|
||||
|
||||
def test_writing_other_types_to_undefined(tmp_path: Path) -> None:
|
||||
@pytest.mark.parametrize("value", (1, IFDRational(1)))
|
||||
def test_writing_other_types_to_undefined(
|
||||
value: int | IFDRational, tmp_path: Path
|
||||
) -> None:
|
||||
im = hopper()
|
||||
info = TiffImagePlugin.ImageFileDirectory_v2()
|
||||
|
||||
tag = TiffTags.TAGS_V2[33723]
|
||||
assert tag.type == TiffTags.UNDEFINED
|
||||
|
||||
info[33723] = 1
|
||||
info[33723] = value
|
||||
|
||||
out = str(tmp_path / "temp.tiff")
|
||||
im.save(out, tiffinfo=info)
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from PIL import Image, ImageDraw, ImageFont
|
||||
from PIL import Image, ImageDraw, ImageFont, _util
|
||||
|
||||
from .helper import PillowLeakTestCase, skip_unless_feature
|
||||
from .helper import PillowLeakTestCase, features, skip_unless_feature
|
||||
|
||||
original_core = ImageFont.core
|
||||
|
||||
|
||||
class TestTTypeFontLeak(PillowLeakTestCase):
|
||||
|
@ -31,5 +33,11 @@ class TestDefaultFontLeak(TestTTypeFontLeak):
|
|||
mem_limit = 1024 # k
|
||||
|
||||
def test_leak(self) -> None:
|
||||
default_font = ImageFont.load_default()
|
||||
if features.check_module("freetype2"):
|
||||
ImageFont.core = _util.DeferredError(ImportError)
|
||||
try:
|
||||
default_font = ImageFont.load_default()
|
||||
finally:
|
||||
ImageFont.core = original_core
|
||||
|
||||
self._test_font(default_font)
|
||||
|
|
|
@ -16,6 +16,7 @@ from PIL import (
|
|||
ExifTags,
|
||||
Image,
|
||||
ImageDraw,
|
||||
ImageFile,
|
||||
ImagePalette,
|
||||
UnidentifiedImageError,
|
||||
features,
|
||||
|
@ -138,13 +139,13 @@ class TestImage:
|
|||
assert im.height == 2
|
||||
|
||||
with pytest.raises(AttributeError):
|
||||
im.size = (3, 4)
|
||||
im.size = (3, 4) # type: ignore[misc]
|
||||
|
||||
def test_set_mode(self) -> None:
|
||||
im = Image.new("RGB", (1, 1))
|
||||
|
||||
with pytest.raises(AttributeError):
|
||||
im.mode = "P"
|
||||
im.mode = "P" # type: ignore[misc]
|
||||
|
||||
def test_invalid_image(self) -> None:
|
||||
im = io.BytesIO(b"")
|
||||
|
@ -1041,25 +1042,20 @@ class TestImage:
|
|||
assert im.fp is None
|
||||
|
||||
|
||||
class MockEncoder:
|
||||
args: tuple[str, ...]
|
||||
|
||||
|
||||
def mock_encode(*args: str) -> MockEncoder:
|
||||
encoder = MockEncoder()
|
||||
encoder.args = args
|
||||
return encoder
|
||||
class MockEncoder(ImageFile.PyEncoder):
|
||||
pass
|
||||
|
||||
|
||||
class TestRegistry:
|
||||
def test_encode_registry(self) -> None:
|
||||
Image.register_encoder("MOCK", mock_encode)
|
||||
Image.register_encoder("MOCK", MockEncoder)
|
||||
assert "MOCK" in Image.ENCODERS
|
||||
|
||||
enc = Image._getencoder("RGB", "MOCK", ("args",), extra=("extra",))
|
||||
|
||||
assert isinstance(enc, MockEncoder)
|
||||
assert enc.args == ("RGB", "args", "extra")
|
||||
assert enc.mode == "RGB"
|
||||
assert enc.args == ("args", "extra")
|
||||
|
||||
def test_encode_registry_fail(self) -> None:
|
||||
with pytest.raises(OSError):
|
||||
|
|
|
@ -14,6 +14,7 @@ from .helper import assert_image_equal, hopper, is_win32
|
|||
|
||||
# CFFI imports pycparser which doesn't support PYTHONOPTIMIZE=2
|
||||
# https://github.com/eliben/pycparser/pull/198#issuecomment-317001670
|
||||
cffi: ModuleType | None
|
||||
if os.environ.get("PYTHONOPTIMIZE") == "2":
|
||||
cffi = None
|
||||
else:
|
||||
|
|
|
@ -148,9 +148,7 @@ def test_kernel_not_enough_coefficients() -> None:
|
|||
@pytest.mark.parametrize("mode", ("L", "LA", "I", "RGB", "CMYK"))
|
||||
def test_consistency_3x3(mode: str) -> None:
|
||||
with Image.open("Tests/images/hopper.bmp") as source:
|
||||
reference_name = "hopper_emboss"
|
||||
reference_name += "_I.png" if mode == "I" else ".bmp"
|
||||
with Image.open("Tests/images/" + reference_name) as reference:
|
||||
with Image.open("Tests/images/hopper_emboss.bmp") as reference:
|
||||
kernel = ImageFilter.Kernel(
|
||||
(3, 3),
|
||||
# fmt: off
|
||||
|
@ -160,23 +158,13 @@ def test_consistency_3x3(mode: str) -> None:
|
|||
# fmt: on
|
||||
0.3,
|
||||
)
|
||||
source = source.split() * 2
|
||||
reference = reference.split() * 2
|
||||
|
||||
if mode == "I":
|
||||
source = source[0].convert(mode)
|
||||
else:
|
||||
source = Image.merge(mode, source[: len(mode)])
|
||||
reference = Image.merge(mode, reference[: len(mode)])
|
||||
assert_image_equal(source.filter(kernel), reference)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("mode", ("L", "LA", "I", "RGB", "CMYK"))
|
||||
def test_consistency_5x5(mode: str) -> None:
|
||||
with Image.open("Tests/images/hopper.bmp") as source:
|
||||
reference_name = "hopper_emboss_more"
|
||||
reference_name += "_I.png" if mode == "I" else ".bmp"
|
||||
with Image.open("Tests/images/" + reference_name) as reference:
|
||||
with Image.open("Tests/images/hopper_emboss_more.bmp") as reference:
|
||||
kernel = ImageFilter.Kernel(
|
||||
(5, 5),
|
||||
# fmt: off
|
||||
|
@ -188,14 +176,6 @@ def test_consistency_5x5(mode: str) -> None:
|
|||
# fmt: on
|
||||
0.3,
|
||||
)
|
||||
source = source.split() * 2
|
||||
reference = reference.split() * 2
|
||||
|
||||
if mode == "I":
|
||||
source = source[0].convert(mode)
|
||||
else:
|
||||
source = Image.merge(mode, source[: len(mode)])
|
||||
reference = Image.merge(mode, reference[: len(mode)])
|
||||
assert_image_equal(source.filter(kernel), reference)
|
||||
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import warnings
|
||||
from typing import Generator
|
||||
|
||||
import pytest
|
||||
|
||||
|
@ -17,19 +16,16 @@ pytestmark = pytest.mark.skipif(
|
|||
not ImageQt.qt_is_installed, reason="Qt bindings are not installed"
|
||||
)
|
||||
|
||||
ims = [
|
||||
hopper(),
|
||||
Image.open("Tests/images/transparent.png"),
|
||||
Image.open("Tests/images/7x13.png"),
|
||||
]
|
||||
|
||||
@pytest.fixture
|
||||
def test_images() -> Generator[Image.Image, None, None]:
|
||||
ims = [
|
||||
hopper(),
|
||||
Image.open("Tests/images/transparent.png"),
|
||||
Image.open("Tests/images/7x13.png"),
|
||||
]
|
||||
try:
|
||||
yield ims
|
||||
finally:
|
||||
for im in ims:
|
||||
im.close()
|
||||
|
||||
def teardown_module() -> None:
|
||||
for im in ims:
|
||||
im.close()
|
||||
|
||||
|
||||
def roundtrip(expected: Image.Image) -> None:
|
||||
|
@ -44,26 +40,26 @@ def roundtrip(expected: Image.Image) -> None:
|
|||
assert_image_equal(result, expected.convert("RGB"))
|
||||
|
||||
|
||||
def test_sanity_1(test_images: Generator[Image.Image, None, None]) -> None:
|
||||
for im in test_images:
|
||||
def test_sanity_1() -> None:
|
||||
for im in ims:
|
||||
roundtrip(im.convert("1"))
|
||||
|
||||
|
||||
def test_sanity_rgb(test_images: Generator[Image.Image, None, None]) -> None:
|
||||
for im in test_images:
|
||||
def test_sanity_rgb() -> None:
|
||||
for im in ims:
|
||||
roundtrip(im.convert("RGB"))
|
||||
|
||||
|
||||
def test_sanity_rgba(test_images: Generator[Image.Image, None, None]) -> None:
|
||||
for im in test_images:
|
||||
def test_sanity_rgba() -> None:
|
||||
for im in ims:
|
||||
roundtrip(im.convert("RGBA"))
|
||||
|
||||
|
||||
def test_sanity_l(test_images: Generator[Image.Image, None, None]) -> None:
|
||||
for im in test_images:
|
||||
def test_sanity_l() -> None:
|
||||
for im in ims:
|
||||
roundtrip(im.convert("L"))
|
||||
|
||||
|
||||
def test_sanity_p(test_images: Generator[Image.Image, None, None]) -> None:
|
||||
for im in test_images:
|
||||
def test_sanity_p() -> None:
|
||||
for im in ims:
|
||||
roundtrip(im.convert("P"))
|
||||
|
|
|
@ -32,7 +32,7 @@ class TestImagingPaste:
|
|||
def assert_9points_paste(
|
||||
self,
|
||||
im: Image.Image,
|
||||
im2: Image.Image,
|
||||
im2: Image.Image | str | tuple[int, ...],
|
||||
mask: Image.Image,
|
||||
expected: list[tuple[int, int, int, int]],
|
||||
) -> None:
|
||||
|
|
|
@ -237,7 +237,7 @@ class TestCoreResampleConsistency:
|
|||
im = Image.new(mode, (512, 9), fill)
|
||||
return im.resize((9, 512), Image.Resampling.LANCZOS), im.load()[0, 0]
|
||||
|
||||
def run_case(self, case: tuple[Image.Image, Image.Image]) -> None:
|
||||
def run_case(self, case: tuple[Image.Image, int | tuple[int, ...]]) -> None:
|
||||
channel, color = case
|
||||
px = channel.load()
|
||||
for x in range(channel.size[0]):
|
||||
|
|
|
@ -154,7 +154,7 @@ class TestImagingCoreResize:
|
|||
|
||||
def test_unknown_filter(self) -> None:
|
||||
with pytest.raises(ValueError):
|
||||
self.resize(hopper(), (10, 10), 9)
|
||||
self.resize(hopper(), (10, 10), 9) # type: ignore[arg-type]
|
||||
|
||||
def test_cross_platform(self, tmp_path: Path) -> None:
|
||||
# This test is intended for only check for consistent behaviour across
|
||||
|
|
|
@ -753,7 +753,7 @@ def test_rectangle_I16(bbox: Coords) -> None:
|
|||
draw.rectangle(bbox, outline=0xFFFF)
|
||||
|
||||
# Assert
|
||||
assert_image_equal_tofile(im.convert("I"), "Tests/images/imagedraw_rectangle_I.png")
|
||||
assert_image_equal_tofile(im, "Tests/images/imagedraw_rectangle_I.tiff")
|
||||
|
||||
|
||||
@pytest.mark.parametrize("bbox", BBOX)
|
||||
|
@ -868,8 +868,10 @@ def test_rounded_rectangle_zero_radius(bbox: Coords) -> None:
|
|||
[
|
||||
((20, 10, 80, 90), "x"),
|
||||
((20, 10, 81, 90), "x_odd"),
|
||||
((20, 10, 81.1, 90), "x_odd"),
|
||||
((10, 20, 90, 80), "y"),
|
||||
((10, 20, 90, 81), "y_odd"),
|
||||
((10, 20, 90, 81.1), "y_odd"),
|
||||
((20, 20, 80, 80), "both"),
|
||||
],
|
||||
)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from io import BytesIO
|
||||
from typing import Any
|
||||
|
||||
import pytest
|
||||
|
||||
|
@ -201,12 +202,22 @@ class TestImageFile:
|
|||
|
||||
|
||||
class MockPyDecoder(ImageFile.PyDecoder):
|
||||
def __init__(self, mode: str, *args: Any) -> None:
|
||||
MockPyDecoder.last = self
|
||||
|
||||
super().__init__(mode, *args)
|
||||
|
||||
def decode(self, buffer):
|
||||
# eof
|
||||
return -1, 0
|
||||
|
||||
|
||||
class MockPyEncoder(ImageFile.PyEncoder):
|
||||
def __init__(self, mode: str, *args: Any) -> None:
|
||||
MockPyEncoder.last = self
|
||||
|
||||
super().__init__(mode, *args)
|
||||
|
||||
def encode(self, buffer):
|
||||
return 1, 1, b""
|
||||
|
||||
|
@ -228,19 +239,8 @@ class MockImageFile(ImageFile.ImageFile):
|
|||
class CodecsTest:
|
||||
@classmethod
|
||||
def setup_class(cls) -> None:
|
||||
cls.decoder = MockPyDecoder(None)
|
||||
cls.encoder = MockPyEncoder(None)
|
||||
|
||||
def decoder_closure(mode, *args):
|
||||
cls.decoder.__init__(mode, *args)
|
||||
return cls.decoder
|
||||
|
||||
def encoder_closure(mode, *args):
|
||||
cls.encoder.__init__(mode, *args)
|
||||
return cls.encoder
|
||||
|
||||
Image.register_decoder("MOCK", decoder_closure)
|
||||
Image.register_encoder("MOCK", encoder_closure)
|
||||
Image.register_decoder("MOCK", MockPyDecoder)
|
||||
Image.register_encoder("MOCK", MockPyEncoder)
|
||||
|
||||
|
||||
class TestPyDecoder(CodecsTest):
|
||||
|
@ -251,13 +251,13 @@ class TestPyDecoder(CodecsTest):
|
|||
|
||||
im.load()
|
||||
|
||||
assert self.decoder.state.xoff == xoff
|
||||
assert self.decoder.state.yoff == yoff
|
||||
assert self.decoder.state.xsize == xsize
|
||||
assert self.decoder.state.ysize == ysize
|
||||
assert MockPyDecoder.last.state.xoff == xoff
|
||||
assert MockPyDecoder.last.state.yoff == yoff
|
||||
assert MockPyDecoder.last.state.xsize == xsize
|
||||
assert MockPyDecoder.last.state.ysize == ysize
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
self.decoder.set_as_raw(b"\x00")
|
||||
MockPyDecoder.last.set_as_raw(b"\x00")
|
||||
|
||||
def test_extents_none(self) -> None:
|
||||
buf = BytesIO(b"\x00" * 255)
|
||||
|
@ -267,10 +267,10 @@ class TestPyDecoder(CodecsTest):
|
|||
|
||||
im.load()
|
||||
|
||||
assert self.decoder.state.xoff == 0
|
||||
assert self.decoder.state.yoff == 0
|
||||
assert self.decoder.state.xsize == 200
|
||||
assert self.decoder.state.ysize == 200
|
||||
assert MockPyDecoder.last.state.xoff == 0
|
||||
assert MockPyDecoder.last.state.yoff == 0
|
||||
assert MockPyDecoder.last.state.xsize == 200
|
||||
assert MockPyDecoder.last.state.ysize == 200
|
||||
|
||||
def test_negsize(self) -> None:
|
||||
buf = BytesIO(b"\x00" * 255)
|
||||
|
@ -315,10 +315,10 @@ class TestPyEncoder(CodecsTest):
|
|||
im, fp, [("MOCK", (xoff, yoff, xoff + xsize, yoff + ysize), 0, "RGB")]
|
||||
)
|
||||
|
||||
assert self.encoder.state.xoff == xoff
|
||||
assert self.encoder.state.yoff == yoff
|
||||
assert self.encoder.state.xsize == xsize
|
||||
assert self.encoder.state.ysize == ysize
|
||||
assert MockPyEncoder.last.state.xoff == xoff
|
||||
assert MockPyEncoder.last.state.yoff == yoff
|
||||
assert MockPyEncoder.last.state.xsize == xsize
|
||||
assert MockPyEncoder.last.state.ysize == ysize
|
||||
|
||||
def test_extents_none(self) -> None:
|
||||
buf = BytesIO(b"\x00" * 255)
|
||||
|
@ -329,10 +329,10 @@ class TestPyEncoder(CodecsTest):
|
|||
fp = BytesIO()
|
||||
ImageFile._save(im, fp, [("MOCK", None, 0, "RGB")])
|
||||
|
||||
assert self.encoder.state.xoff == 0
|
||||
assert self.encoder.state.yoff == 0
|
||||
assert self.encoder.state.xsize == 200
|
||||
assert self.encoder.state.ysize == 200
|
||||
assert MockPyEncoder.last.state.xoff == 0
|
||||
assert MockPyEncoder.last.state.yoff == 0
|
||||
assert MockPyEncoder.last.state.xsize == 200
|
||||
assert MockPyEncoder.last.state.ysize == 200
|
||||
|
||||
def test_negsize(self) -> None:
|
||||
buf = BytesIO(b"\x00" * 255)
|
||||
|
@ -340,12 +340,12 @@ class TestPyEncoder(CodecsTest):
|
|||
im = MockImageFile(buf)
|
||||
|
||||
fp = BytesIO()
|
||||
self.encoder.cleanup_called = False
|
||||
MockPyEncoder.last = None
|
||||
with pytest.raises(ValueError):
|
||||
ImageFile._save(
|
||||
im, fp, [("MOCK", (xoff, yoff, -10, yoff + ysize), 0, "RGB")]
|
||||
)
|
||||
assert self.encoder.cleanup_called
|
||||
assert MockPyEncoder.last.cleanup_called
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
ImageFile._save(
|
||||
|
|
|
@ -73,15 +73,16 @@ def test_lut(op: str) -> None:
|
|||
|
||||
|
||||
def test_no_operator_loaded() -> None:
|
||||
im = Image.new("L", (1, 1))
|
||||
mop = ImageMorph.MorphOp()
|
||||
with pytest.raises(Exception) as e:
|
||||
mop.apply(None)
|
||||
mop.apply(im)
|
||||
assert str(e.value) == "No operator loaded"
|
||||
with pytest.raises(Exception) as e:
|
||||
mop.match(None)
|
||||
mop.match(im)
|
||||
assert str(e.value) == "No operator loaded"
|
||||
with pytest.raises(Exception) as e:
|
||||
mop.save_lut(None)
|
||||
mop.save_lut("")
|
||||
assert str(e.value) == "No operator loaded"
|
||||
|
||||
|
||||
|
|
|
@ -13,8 +13,12 @@ from .helper import (
|
|||
)
|
||||
|
||||
|
||||
class Deformer:
|
||||
def getmesh(self, im: Image.Image) -> list[tuple[tuple[int, ...], tuple[int, ...]]]:
|
||||
class Deformer(ImageOps.SupportsGetMesh):
|
||||
def getmesh(
|
||||
self, im: Image.Image
|
||||
) -> list[
|
||||
tuple[tuple[int, int, int, int], tuple[int, int, int, int, int, int, int, int]]
|
||||
]:
|
||||
x, y = im.size
|
||||
return [((0, 0, x, y), (0, 0, x, 0, x, y, y, 0))]
|
||||
|
||||
|
@ -376,6 +380,7 @@ def test_exif_transpose() -> None:
|
|||
else:
|
||||
original_exif = im.info["exif"]
|
||||
transposed_im = ImageOps.exif_transpose(im)
|
||||
assert transposed_im is not None
|
||||
assert_image_similar(base_im, transposed_im, 17)
|
||||
if orientation_im is base_im:
|
||||
assert "exif" not in im.info
|
||||
|
@ -387,6 +392,7 @@ def test_exif_transpose() -> None:
|
|||
|
||||
# Repeat the operation to test that it does not keep transposing
|
||||
transposed_im2 = ImageOps.exif_transpose(transposed_im)
|
||||
assert transposed_im2 is not None
|
||||
assert_image_equal(transposed_im2, transposed_im)
|
||||
|
||||
check(base_im)
|
||||
|
@ -402,6 +408,7 @@ def test_exif_transpose() -> None:
|
|||
assert im.getexif()[0x0112] == 3
|
||||
|
||||
transposed_im = ImageOps.exif_transpose(im)
|
||||
assert transposed_im is not None
|
||||
assert 0x0112 not in transposed_im.getexif()
|
||||
|
||||
transposed_im._reload_exif()
|
||||
|
@ -414,12 +421,14 @@ def test_exif_transpose() -> None:
|
|||
assert im.getexif()[0x0112] == 3
|
||||
|
||||
transposed_im = ImageOps.exif_transpose(im)
|
||||
assert transposed_im is not None
|
||||
assert 0x0112 not in transposed_im.getexif()
|
||||
|
||||
# Orientation set directly on Image.Exif
|
||||
im = hopper()
|
||||
im.getexif()[0x0112] = 3
|
||||
transposed_im = ImageOps.exif_transpose(im)
|
||||
assert transposed_im is not None
|
||||
assert 0x0112 not in transposed_im.getexif()
|
||||
|
||||
|
||||
|
@ -499,7 +508,7 @@ def test_autocontrast_mask_real_input() -> None:
|
|||
|
||||
|
||||
def test_autocontrast_preserve_tone() -> None:
|
||||
def autocontrast(mode: str, preserve_tone: bool) -> Image.Image:
|
||||
def autocontrast(mode: str, preserve_tone: bool) -> list[int]:
|
||||
im = hopper(mode)
|
||||
return ImageOps.autocontrast(im, preserve_tone=preserve_tone).histogram()
|
||||
|
||||
|
|
|
@ -28,8 +28,8 @@ def test_filter_api(test_images: dict[str, Image.Image]) -> None:
|
|||
assert i.mode == "RGB"
|
||||
assert i.size == (128, 128)
|
||||
|
||||
test_filter = ImageFilter.UnsharpMask(2.0, 125, 8)
|
||||
i = im.filter(test_filter)
|
||||
test_filter2 = ImageFilter.UnsharpMask(2.0, 125, 8)
|
||||
i = im.filter(test_filter2)
|
||||
assert i.mode == "RGB"
|
||||
assert i.size == (128, 128)
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ def test_sanity(tmp_path: Path) -> None:
|
|||
assert index == 1
|
||||
|
||||
with pytest.raises(AttributeError):
|
||||
ImageSequence.Iterator(0)
|
||||
ImageSequence.Iterator(0) # type: ignore[arg-type]
|
||||
|
||||
|
||||
def test_iterator() -> None:
|
||||
|
@ -72,6 +72,7 @@ def test_consecutive() -> None:
|
|||
for frame in ImageSequence.Iterator(im):
|
||||
if first_frame is None:
|
||||
first_frame = frame.copy()
|
||||
assert first_frame is not None
|
||||
for frame in ImageSequence.Iterator(im):
|
||||
assert_image_equal(frame, first_frame)
|
||||
break
|
||||
|
|
|
@ -68,10 +68,11 @@ def test_show_without_viewers() -> None:
|
|||
def test_viewer() -> None:
|
||||
viewer = ImageShow.Viewer()
|
||||
|
||||
assert viewer.get_format(None) is None
|
||||
im = Image.new("L", (1, 1))
|
||||
assert viewer.get_format(im) is None
|
||||
|
||||
with pytest.raises(NotImplementedError):
|
||||
viewer.get_command(None)
|
||||
viewer.get_command("")
|
||||
|
||||
|
||||
@pytest.mark.parametrize("viewer", ImageShow._viewers)
|
||||
|
|
|
@ -78,7 +78,7 @@ def test_basic(tmp_path: Path, mode: str) -> None:
|
|||
|
||||
|
||||
def test_tobytes() -> None:
|
||||
def tobytes(mode: str) -> Image.Image:
|
||||
def tobytes(mode: str) -> bytes:
|
||||
return Image.new(mode, (1, 1), 1).tobytes()
|
||||
|
||||
order = 1 if Image._ENDIAN == "<" else -1
|
||||
|
|
|
@ -47,9 +47,8 @@ def test_tiff_crashes(test_file: str) -> None:
|
|||
with Image.open(test_file) as im:
|
||||
im.load()
|
||||
except FileNotFoundError:
|
||||
if not on_ci():
|
||||
pytest.skip("test image not found")
|
||||
return
|
||||
raise
|
||||
if on_ci():
|
||||
raise
|
||||
pytest.skip("test image not found")
|
||||
except OSError:
|
||||
pass
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
# install libimagequant
|
||||
|
||||
archive_name=libimagequant
|
||||
archive_version=4.2.2
|
||||
archive_version=4.3.0
|
||||
|
||||
archive=$archive_name-$archive_version
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ Like PIL, Pillow is `licensed under the open source HPND License <https://raw.gi
|
|||
Why a fork?
|
||||
-----------
|
||||
|
||||
PIL is not setuptools compatible. Please see `this Image-SIG post`_ for a more detailed explanation. Also, PIL's current bi-yearly (or greater) release schedule is too infrequent to accommodate the large number and frequency of issues reported.
|
||||
PIL is not setuptools compatible. Please see `this Image-SIG post`_ for a more detailed explanation. Also, PIL's bi-yearly (or greater) release schedule was too infrequent to accommodate the large number and frequency of issues reported.
|
||||
|
||||
.. _this Image-SIG post: https://mail.python.org/pipermail/image-sig/2010-August/006480.html
|
||||
|
||||
|
@ -35,4 +35,4 @@ What about PIL?
|
|||
Prior to Pillow 2.0.0, very few image code changes were made. Pillow 2.0.0
|
||||
added Python 3 support and includes many bug fixes from many contributors.
|
||||
|
||||
As more time passes since the last PIL release (1.1.7 in 2009), the likelihood of a new PIL release decreases. However, we've yet to hear an official "PIL is dead" announcement.
|
||||
The last PIL release was in 2009 (1.1.7) and `no future releases are expected <https://github.com/python-pillow/Pillow/issues/1535>`_. In January 2020, `the PyPI moderators exhausted the PEP 541 process for contacting the PIL project owner <https://github.com/python-pillow/Pillow/issues/1535#issuecomment-570308446>`_ and the `PIL project on PyPI <https://pypi.org/project/PIL>`_ was transferred to the `Pillow team <https://github.com/python-pillow/Pillow/graphs/contributors>`_. The Pillow team has no plans to update the PIL project on PyPI.
|
||||
|
|
|
@ -232,10 +232,10 @@ Previous code::
|
|||
|
||||
im = Image.new("RGB", (100, 100))
|
||||
draw = ImageDraw.Draw(im)
|
||||
width, height = draw.textsize("Hello world")
|
||||
width, height = draw.textsize("Hello world", font)
|
||||
|
||||
width, height = font.getsize_multiline("Hello\nworld")
|
||||
width, height = draw.multiline_textsize("Hello\nworld")
|
||||
width, height = draw.multiline_textsize("Hello\nworld", font)
|
||||
|
||||
Use instead::
|
||||
|
||||
|
@ -247,11 +247,43 @@ Use instead::
|
|||
|
||||
im = Image.new("RGB", (100, 100))
|
||||
draw = ImageDraw.Draw(im)
|
||||
width = draw.textlength("Hello world")
|
||||
width = draw.textlength("Hello world", font)
|
||||
|
||||
left, top, right, bottom = draw.multiline_textbbox((0, 0), "Hello\nworld")
|
||||
left, top, right, bottom = draw.multiline_textbbox((0, 0), "Hello\nworld", font)
|
||||
width, height = right - left, bottom - top
|
||||
|
||||
Previously, the ``size`` methods returned a ``height`` that included the vertical
|
||||
offset of the text, while the new ``bbox`` methods distinguish this as a ``top``
|
||||
offset.
|
||||
|
||||
.. image:: ./example/size_vs_bbox.png
|
||||
:alt: In bbox methods, top measures the vertical distance above the text, while bottom measures that plus the vertical distance of the text itself. In size methods, height also measures the vertical distance above the text plus the vertical distance of the text itself.
|
||||
:align: center
|
||||
|
||||
If you are using these methods for aligning text, consider using :ref:`text-anchors` instead
|
||||
which avoid issues that can occur with non-English text or unusual fonts.
|
||||
For example, instead of the following code::
|
||||
|
||||
from PIL import Image, ImageDraw, ImageFont
|
||||
|
||||
font = ImageFont.truetype("Tests/fonts/FreeMono.ttf")
|
||||
|
||||
im = Image.new("RGB", (100, 100))
|
||||
draw = ImageDraw.Draw(im)
|
||||
width, height = draw.textsize("Hello world", font)
|
||||
x, y = (100 - width) / 2, (100 - height) / 2
|
||||
draw.text((x, y), "Hello world", font=font)
|
||||
|
||||
Use instead::
|
||||
|
||||
from PIL import Image, ImageDraw, ImageFont
|
||||
|
||||
font = ImageFont.truetype("Tests/fonts/FreeMono.ttf")
|
||||
|
||||
im = Image.new("RGB", (100, 100))
|
||||
draw = ImageDraw.Draw(im)
|
||||
draw.text((100 / 2, 100 / 2), "Hello world", font=font, anchor="mm")
|
||||
|
||||
FreeTypeFont.getmask2 fill parameter
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
|
BIN
docs/example/size_vs_bbox.png
Normal file
After Width: | Height: | Size: 13 KiB |
|
@ -93,7 +93,7 @@ The core image library is designed for fast access to data stored in a few basic
|
|||
.. toctree::
|
||||
:maxdepth: 2
|
||||
|
||||
installation.rst
|
||||
installation/index.rst
|
||||
handbook/index.rst
|
||||
reference/index.rst
|
||||
porting.rst
|
||||
|
|
|
@ -1,597 +1,29 @@
|
|||
:orphan:
|
||||
|
||||
Installation
|
||||
============
|
||||
|
||||
.. raw:: html
|
||||
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
activateTab(getOS());
|
||||
});
|
||||
</script>
|
||||
|
||||
Python Support
|
||||
--------------
|
||||
|
||||
Pillow supports these Python versions.
|
||||
|
||||
.. csv-table:: Newer versions
|
||||
:file: newer-versions.csv
|
||||
:header-rows: 1
|
||||
|
||||
.. csv-table:: Older versions
|
||||
:file: older-versions.csv
|
||||
:header-rows: 1
|
||||
|
||||
.. _Linux Installation:
|
||||
.. _macOS Installation:
|
||||
.. _Windows Installation:
|
||||
.. _FreeBSD Installation:
|
||||
|
||||
Basic Installation
|
||||
------------------
|
||||
|
||||
.. note::
|
||||
.. Note:: This section has moved to :ref:`basic-installation`. Please update references accordingly.
|
||||
|
||||
The following instructions will install Pillow with support for
|
||||
most common image formats. See :ref:`external-libraries` for a
|
||||
full list of external libraries supported.
|
||||
Python Support
|
||||
--------------
|
||||
|
||||
Install Pillow with :command:`pip`::
|
||||
|
||||
python3 -m pip install --upgrade pip
|
||||
python3 -m pip install --upgrade Pillow
|
||||
|
||||
Optionally, install :pypi:`defusedxml` for Pillow to read XMP data,
|
||||
and :pypi:`olefile` for Pillow to read FPX and MIC images::
|
||||
|
||||
python3 -m pip install --upgrade defusedxml olefile
|
||||
|
||||
|
||||
.. tab:: Linux
|
||||
|
||||
We provide binaries for Linux for each of the supported Python
|
||||
versions in the manylinux wheel format. These include support for all
|
||||
optional libraries except libimagequant. Raqm support requires
|
||||
FriBiDi to be installed separately::
|
||||
|
||||
python3 -m pip install --upgrade pip
|
||||
python3 -m pip install --upgrade Pillow
|
||||
|
||||
Most major Linux distributions, including Fedora, Ubuntu and ArchLinux
|
||||
also include Pillow in packages that previously contained PIL e.g.
|
||||
``python-imaging``. Debian splits it into two packages, ``python3-pil``
|
||||
and ``python3-pil.imagetk``.
|
||||
|
||||
.. tab:: macOS
|
||||
|
||||
We provide binaries for macOS for each of the supported Python
|
||||
versions in the wheel format. These include support for all optional
|
||||
libraries except libimagequant. Raqm support requires
|
||||
FriBiDi to be installed separately::
|
||||
|
||||
python3 -m pip install --upgrade pip
|
||||
python3 -m pip install --upgrade Pillow
|
||||
|
||||
While we provide binaries for both x86-64 and arm64, we do not provide universal2
|
||||
binaries. However, it is simple to combine our current binaries to create one::
|
||||
|
||||
python3 -m pip download --only-binary=:all: --platform macosx_10_10_x86_64 Pillow
|
||||
python3 -m pip download --only-binary=:all: --platform macosx_11_0_arm64 Pillow
|
||||
python3 -m pip install delocate
|
||||
|
||||
Then, with the names of the downloaded wheels, use Python to combine them::
|
||||
|
||||
from delocate.fuse import fuse_wheels
|
||||
fuse_wheels('Pillow-9.4.0-2-cp39-cp39-macosx_10_10_x86_64.whl', 'Pillow-9.4.0-cp39-cp39-macosx_11_0_arm64.whl', 'Pillow-9.4.0-cp39-cp39-macosx_11_0_universal2.whl')
|
||||
|
||||
.. tab:: Windows
|
||||
|
||||
We provide Pillow binaries for Windows compiled for the matrix of supported
|
||||
Pythons in the wheel format. These include x86, x86-64 and arm64 versions
|
||||
(with the exception of Python 3.8 on arm64). These binaries include support
|
||||
for all optional libraries except libimagequant and libxcb. Raqm support
|
||||
requires FriBiDi to be installed separately::
|
||||
|
||||
python3 -m pip install --upgrade pip
|
||||
python3 -m pip install --upgrade Pillow
|
||||
|
||||
To install Pillow in MSYS2, see `Building on Windows using MSYS2/MinGW`_.
|
||||
|
||||
.. tab:: FreeBSD
|
||||
|
||||
Pillow can be installed on FreeBSD via the official Ports or Packages systems:
|
||||
|
||||
**Ports**::
|
||||
|
||||
cd /usr/ports/graphics/py-pillow && make install clean
|
||||
|
||||
**Packages**::
|
||||
|
||||
pkg install py38-pillow
|
||||
|
||||
.. note::
|
||||
|
||||
The `Pillow FreeBSD port
|
||||
<https://www.freshports.org/graphics/py-pillow/>`_ and packages
|
||||
are tested by the ports team with all supported FreeBSD versions.
|
||||
|
||||
|
||||
.. _Building on Linux:
|
||||
.. _Building on macOS:
|
||||
.. _Building on Windows:
|
||||
.. _Building on Windows using MSYS2/MinGW:
|
||||
.. _Building on FreeBSD:
|
||||
.. _Building on Android:
|
||||
|
||||
Building From Source
|
||||
--------------------
|
||||
|
||||
.. _external-libraries:
|
||||
|
||||
External Libraries
|
||||
^^^^^^^^^^^^^^^^^^
|
||||
|
||||
.. note::
|
||||
|
||||
You **do not need to install all supported external libraries** to
|
||||
use Pillow's basic features. **Zlib** and **libjpeg** are required
|
||||
by default.
|
||||
|
||||
.. note::
|
||||
|
||||
There are Dockerfiles in our `Docker images repo
|
||||
<https://github.com/python-pillow/docker-images>`_ to install the
|
||||
dependencies for some operating systems.
|
||||
|
||||
Many of Pillow's features require external libraries:
|
||||
|
||||
* **libjpeg** provides JPEG functionality.
|
||||
|
||||
* Pillow has been tested with libjpeg versions **6b**, **8**, **9-9d** and
|
||||
libjpeg-turbo version **8**.
|
||||
* Starting with Pillow 3.0.0, libjpeg is required by default. It can be
|
||||
disabled with the ``-C jpeg=disable`` flag.
|
||||
|
||||
* **zlib** provides access to compressed PNGs
|
||||
|
||||
* Starting with Pillow 3.0.0, zlib is required by default. It can be
|
||||
disabled with the ``-C zlib=disable`` flag.
|
||||
|
||||
* **libtiff** provides compressed TIFF functionality
|
||||
|
||||
* Pillow has been tested with libtiff versions **3.x** and **4.0-4.6.0**
|
||||
|
||||
* **libfreetype** provides type related services
|
||||
|
||||
* **littlecms** provides color management
|
||||
|
||||
* Pillow version 2.2.1 and below uses liblcms1, Pillow 2.3.0 and
|
||||
above uses liblcms2. Tested with **1.19** and **2.7-2.16**.
|
||||
|
||||
* **libwebp** provides the WebP format.
|
||||
|
||||
* Pillow has been tested with version **0.1.3**, which does not read
|
||||
transparent WebP files. Versions **0.3.0** and above support
|
||||
transparency.
|
||||
|
||||
* **openjpeg** provides JPEG 2000 functionality.
|
||||
|
||||
* Pillow has been tested with openjpeg **2.0.0**, **2.1.0**, **2.3.1**,
|
||||
**2.4.0**, **2.5.0** and **2.5.2**.
|
||||
* Pillow does **not** support the earlier **1.5** series which ships
|
||||
with Debian Jessie.
|
||||
|
||||
* **libimagequant** provides improved color quantization
|
||||
|
||||
* Pillow has been tested with libimagequant **2.6-4.2.2**
|
||||
* Libimagequant is licensed GPLv3, which is more restrictive than
|
||||
the Pillow license, therefore we will not be distributing binaries
|
||||
with libimagequant support enabled.
|
||||
|
||||
* **libraqm** provides complex text layout support.
|
||||
|
||||
* libraqm provides bidirectional text support (using FriBiDi),
|
||||
shaping (using HarfBuzz), and proper script itemization. As a
|
||||
result, Raqm can support most writing systems covered by Unicode.
|
||||
* libraqm depends on the following libraries: FreeType, HarfBuzz,
|
||||
FriBiDi, make sure that you install them before installing libraqm
|
||||
if not available as package in your system.
|
||||
* Setting text direction or font features is not supported without libraqm.
|
||||
* Pillow wheels since version 8.2.0 include a modified version of libraqm that
|
||||
loads libfribidi at runtime if it is installed.
|
||||
On Windows this requires compiling FriBiDi and installing ``fribidi.dll``
|
||||
into a directory listed in the `Dynamic-link library search order (Microsoft Learn)
|
||||
<https://learn.microsoft.com/en-us/windows/win32/dlls/dynamic-link-library-search-order#search-order-for-unpackaged-apps>`_
|
||||
(``fribidi-0.dll`` or ``libfribidi-0.dll`` are also detected).
|
||||
See `Build Options`_ to see how to build this version.
|
||||
* Previous versions of Pillow (5.0.0 to 8.1.2) linked libraqm dynamically at runtime.
|
||||
|
||||
* **libxcb** provides X11 screengrab support.
|
||||
|
||||
.. tab:: Linux
|
||||
|
||||
If you didn't build Python from source, make sure you have Python's
|
||||
development libraries installed.
|
||||
|
||||
In Debian or Ubuntu::
|
||||
|
||||
sudo apt-get install python3-dev python3-setuptools
|
||||
|
||||
In Fedora, the command is::
|
||||
|
||||
sudo dnf install python3-devel redhat-rpm-config
|
||||
|
||||
In Alpine, the command is::
|
||||
|
||||
sudo apk add python3-dev py3-setuptools
|
||||
|
||||
.. Note:: ``redhat-rpm-config`` is required on Fedora 23, but not earlier versions.
|
||||
|
||||
Prerequisites for **Ubuntu 16.04 LTS - 22.04 LTS** are installed with::
|
||||
|
||||
sudo apt-get install libtiff5-dev libjpeg8-dev libopenjp2-7-dev zlib1g-dev \
|
||||
libfreetype6-dev liblcms2-dev libwebp-dev tcl8.6-dev tk8.6-dev python3-tk \
|
||||
libharfbuzz-dev libfribidi-dev libxcb1-dev
|
||||
|
||||
To install libraqm, ``sudo apt-get install meson`` and then see
|
||||
``depends/install_raqm.sh``.
|
||||
|
||||
Prerequisites are installed on recent **Red Hat**, **CentOS** or **Fedora** with::
|
||||
|
||||
sudo dnf install libtiff-devel libjpeg-devel openjpeg2-devel zlib-devel \
|
||||
freetype-devel lcms2-devel libwebp-devel tcl-devel tk-devel \
|
||||
harfbuzz-devel fribidi-devel libraqm-devel libimagequant-devel libxcb-devel
|
||||
|
||||
Note that the package manager may be yum or DNF, depending on the
|
||||
exact distribution.
|
||||
|
||||
Prerequisites are installed for **Alpine** with::
|
||||
|
||||
sudo apk add tiff-dev jpeg-dev openjpeg-dev zlib-dev freetype-dev lcms2-dev \
|
||||
libwebp-dev tcl-dev tk-dev harfbuzz-dev fribidi-dev libimagequant-dev \
|
||||
libxcb-dev libpng-dev
|
||||
|
||||
See also the ``Dockerfile``\s in the Test Infrastructure repo
|
||||
(https://github.com/python-pillow/docker-images) for a known working
|
||||
install process for other tested distros.
|
||||
|
||||
.. tab:: macOS
|
||||
|
||||
The Xcode command line tools are required to compile portions of
|
||||
Pillow. The tools are installed by running ``xcode-select --install``
|
||||
from the command line. The command line tools are required even if you
|
||||
have the full Xcode package installed. It may be necessary to run
|
||||
``sudo xcodebuild -license`` to accept the license prior to using the
|
||||
tools.
|
||||
|
||||
The easiest way to install external libraries is via `Homebrew
|
||||
<https://brew.sh/>`_. After you install Homebrew, run::
|
||||
|
||||
brew install libjpeg libtiff little-cms2 openjpeg webp
|
||||
|
||||
To install libraqm on macOS use Homebrew to install its dependencies::
|
||||
|
||||
brew install freetype harfbuzz fribidi
|
||||
|
||||
Then see ``depends/install_raqm_cmake.sh`` to install libraqm.
|
||||
|
||||
.. tab:: Windows
|
||||
|
||||
We recommend you use prebuilt wheels from PyPI.
|
||||
If you wish to compile Pillow manually, you can use the build scripts
|
||||
in the ``winbuild`` directory used for CI testing and development.
|
||||
These scripts require Visual Studio 2017 or newer and NASM.
|
||||
|
||||
The scripts also install Pillow from the local copy of the source code, so the
|
||||
`Installing`_ instructions will not be necessary afterwards.
|
||||
|
||||
.. tab:: Windows using MSYS2/MinGW
|
||||
|
||||
To build Pillow using MSYS2, make sure you run the **MSYS2 MinGW 32-bit** or
|
||||
**MSYS2 MinGW 64-bit** console, *not* **MSYS2** directly.
|
||||
|
||||
The following instructions target the 64-bit build, for 32-bit
|
||||
replace all occurrences of ``mingw-w64-x86_64-`` with ``mingw-w64-i686-``.
|
||||
|
||||
Make sure you have Python and GCC installed::
|
||||
|
||||
pacman -S \
|
||||
mingw-w64-x86_64-gcc \
|
||||
mingw-w64-x86_64-python3 \
|
||||
mingw-w64-x86_64-python3-pip \
|
||||
mingw-w64-x86_64-python3-setuptools
|
||||
|
||||
Prerequisites are installed on **MSYS2 MinGW 64-bit** with::
|
||||
|
||||
pacman -S \
|
||||
mingw-w64-x86_64-libjpeg-turbo \
|
||||
mingw-w64-x86_64-zlib \
|
||||
mingw-w64-x86_64-libtiff \
|
||||
mingw-w64-x86_64-freetype \
|
||||
mingw-w64-x86_64-lcms2 \
|
||||
mingw-w64-x86_64-libwebp \
|
||||
mingw-w64-x86_64-openjpeg2 \
|
||||
mingw-w64-x86_64-libimagequant \
|
||||
mingw-w64-x86_64-libraqm
|
||||
|
||||
https://www.msys2.org/docs/python/ states that setuptools >= 60 does not work with
|
||||
MSYS2. To workaround this, before installing Pillow you must run::
|
||||
|
||||
export SETUPTOOLS_USE_DISTUTILS=stdlib
|
||||
|
||||
.. tab:: FreeBSD
|
||||
|
||||
.. Note:: Only FreeBSD 10 and 11 tested
|
||||
|
||||
Make sure you have Python's development libraries installed::
|
||||
|
||||
sudo pkg install python3
|
||||
|
||||
Prerequisites are installed on **FreeBSD 10 or 11** with::
|
||||
|
||||
sudo pkg install jpeg-turbo tiff webp lcms2 freetype2 openjpeg harfbuzz fribidi libxcb
|
||||
|
||||
Then see ``depends/install_raqm_cmake.sh`` to install libraqm.
|
||||
|
||||
.. tab:: Android
|
||||
|
||||
Basic Android support has been added for compilation within the Termux
|
||||
environment. The dependencies can be installed by::
|
||||
|
||||
pkg install -y python ndk-sysroot clang make \
|
||||
libjpeg-turbo
|
||||
|
||||
This has been tested within the Termux app on ChromeOS, on x86.
|
||||
|
||||
Installing
|
||||
^^^^^^^^^^
|
||||
|
||||
Once you have installed the prerequisites, to install Pillow from the source
|
||||
code on PyPI, run::
|
||||
|
||||
python3 -m pip install --upgrade pip
|
||||
python3 -m pip install --upgrade Pillow --no-binary :all:
|
||||
|
||||
If the prerequisites are installed in the standard library locations
|
||||
for your machine (e.g. :file:`/usr` or :file:`/usr/local`), no
|
||||
additional configuration should be required. If they are installed in
|
||||
a non-standard location, you may need to configure setuptools to use
|
||||
those locations by editing :file:`setup.py` or
|
||||
:file:`pyproject.toml`, or by adding environment variables on the command
|
||||
line::
|
||||
|
||||
CFLAGS="-I/usr/pkg/include" python3 -m pip install --upgrade Pillow --no-binary :all:
|
||||
|
||||
If Pillow has been previously built without the required
|
||||
prerequisites, it may be necessary to manually clear the pip cache or
|
||||
build without cache using the ``--no-cache-dir`` option to force a
|
||||
build with newly installed external libraries.
|
||||
|
||||
If you would like to install from a local copy of the source code instead, you
|
||||
can clone from GitHub with ``git clone https://github.com/python-pillow/Pillow``
|
||||
or download and extract the `compressed archive from PyPI`_.
|
||||
|
||||
After navigating to the Pillow directory, run::
|
||||
|
||||
python3 -m pip install --upgrade pip
|
||||
python3 -m pip install .
|
||||
|
||||
.. _compressed archive from PyPI: https://pypi.org/project/pillow/#files
|
||||
|
||||
Build Options
|
||||
"""""""""""""
|
||||
|
||||
* Environment variable: ``MAX_CONCURRENCY=n``. Pillow can use
|
||||
multiprocessing to build the extension. Setting ``MAX_CONCURRENCY``
|
||||
sets the number of CPUs to use, or can disable parallel building by
|
||||
using a setting of 1. By default, it uses 4 CPUs, or if 4 are not
|
||||
available, as many as are present.
|
||||
|
||||
* Config settings: ``-C zlib=disable``, ``-C jpeg=disable``,
|
||||
``-C tiff=disable``, ``-C freetype=disable``, ``-C raqm=disable``,
|
||||
``-C lcms=disable``, ``-C webp=disable``, ``-C webpmux=disable``,
|
||||
``-C jpeg2000=disable``, ``-C imagequant=disable``, ``-C xcb=disable``.
|
||||
Disable building the corresponding feature even if the development
|
||||
libraries are present on the building machine.
|
||||
|
||||
* Config settings: ``-C zlib=enable``, ``-C jpeg=enable``,
|
||||
``-C tiff=enable``, ``-C freetype=enable``, ``-C raqm=enable``,
|
||||
``-C lcms=enable``, ``-C webp=enable``, ``-C webpmux=enable``,
|
||||
``-C jpeg2000=enable``, ``-C imagequant=enable``, ``-C xcb=enable``.
|
||||
Require that the corresponding feature is built. The build will raise
|
||||
an exception if the libraries are not found. Webpmux (WebP metadata)
|
||||
relies on WebP support. Tcl and Tk also must be used together.
|
||||
|
||||
* Config settings: ``-C raqm=vendor``, ``-C fribidi=vendor``.
|
||||
These flags are used to compile a modified version of libraqm and
|
||||
a shim that dynamically loads libfribidi at runtime. These are
|
||||
used to compile the standard Pillow wheels. Compiling libraqm requires
|
||||
a C99-compliant compiler.
|
||||
|
||||
* Build flag: ``-C platform-guessing=disable``. Skips all of the
|
||||
platform dependent guessing of include and library directories for
|
||||
automated build systems that configure the proper paths in the
|
||||
environment variables (e.g. Buildroot).
|
||||
|
||||
* Build flag: ``-C debug=true``. Adds a debugging flag to the include and
|
||||
library search process to dump all paths searched for and found to
|
||||
stdout.
|
||||
|
||||
|
||||
Sample usage::
|
||||
|
||||
python3 -m pip install --upgrade Pillow -C [feature]=enable
|
||||
.. Note:: This section has moved to :ref:`python-support`. Please update references accordingly.
|
||||
|
||||
Platform Support
|
||||
----------------
|
||||
|
||||
Current platform support for Pillow. Binary distributions are
|
||||
contributed for each release on a volunteer basis, but the source
|
||||
should compile and run everywhere platform support is listed. In
|
||||
general, we aim to support all current versions of Linux, macOS, and
|
||||
Windows.
|
||||
.. Note:: This section has moved to :ref:`platform-support`. Please update references accordingly.
|
||||
|
||||
Continuous Integration Targets
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
Building From Source
|
||||
--------------------
|
||||
|
||||
These platforms are built and tested for every change.
|
||||
|
||||
+----------------------------------+----------------------------+---------------------+
|
||||
| Operating system | Tested Python versions | Tested architecture |
|
||||
+==================================+============================+=====================+
|
||||
| Alpine | 3.9 | x86-64 |
|
||||
+----------------------------------+----------------------------+---------------------+
|
||||
| Amazon Linux 2 | 3.9 | x86-64 |
|
||||
+----------------------------------+----------------------------+---------------------+
|
||||
| Amazon Linux 2023 | 3.9 | x86-64 |
|
||||
+----------------------------------+----------------------------+---------------------+
|
||||
| Arch | 3.9 | x86-64 |
|
||||
+----------------------------------+----------------------------+---------------------+
|
||||
| CentOS 7 | 3.9 | x86-64 |
|
||||
+----------------------------------+----------------------------+---------------------+
|
||||
| CentOS Stream 8 | 3.9 | x86-64 |
|
||||
+----------------------------------+----------------------------+---------------------+
|
||||
| CentOS Stream 9 | 3.9 | x86-64 |
|
||||
+----------------------------------+----------------------------+---------------------+
|
||||
| Debian 11 Bullseye | 3.9 | x86-64 |
|
||||
+----------------------------------+----------------------------+---------------------+
|
||||
| Debian 12 Bookworm | 3.11 | x86, x86-64 |
|
||||
+----------------------------------+----------------------------+---------------------+
|
||||
| Fedora 38 | 3.11 | x86-64 |
|
||||
+----------------------------------+----------------------------+---------------------+
|
||||
| Fedora 39 | 3.12 | x86-64 |
|
||||
+----------------------------------+----------------------------+---------------------+
|
||||
| Gentoo | 3.9 | x86-64 |
|
||||
+----------------------------------+----------------------------+---------------------+
|
||||
| macOS 12 Monterey | 3.8, 3.9, 3.10, 3.11, | x86-64 |
|
||||
| | 3.12, PyPy3 | |
|
||||
+----------------------------------+----------------------------+---------------------+
|
||||
| Ubuntu Linux 20.04 LTS (Focal) | 3.8 | x86-64 |
|
||||
+----------------------------------+----------------------------+---------------------+
|
||||
| Ubuntu Linux 22.04 LTS (Jammy) | 3.8, 3.9, 3.10, 3.11, | x86-64 |
|
||||
| | 3.12, PyPy3 | |
|
||||
| +----------------------------+---------------------+
|
||||
| | 3.10 | arm64v8, ppc64le, |
|
||||
| | | s390x |
|
||||
+----------------------------------+----------------------------+---------------------+
|
||||
| Windows Server 2016 | 3.8 | x86-64 |
|
||||
+----------------------------------+----------------------------+---------------------+
|
||||
| Windows Server 2022 | 3.8, 3.9, 3.10, 3.11, | x86-64 |
|
||||
| | 3.12, PyPy3 | |
|
||||
| +----------------------------+---------------------+
|
||||
| | 3.12 | x86 |
|
||||
| +----------------------------+---------------------+
|
||||
| | 3.9 (MinGW) | x86-64 |
|
||||
| +----------------------------+---------------------+
|
||||
| | 3.8, 3.9 (Cygwin) | x86-64 |
|
||||
+----------------------------------+----------------------------+---------------------+
|
||||
|
||||
|
||||
Other Platforms
|
||||
^^^^^^^^^^^^^^^
|
||||
|
||||
These platforms have been reported to work at the versions mentioned.
|
||||
|
||||
.. note::
|
||||
|
||||
Contributors please test Pillow on your platform then update this
|
||||
document and send a pull request.
|
||||
|
||||
+----------------------------------+----------------------------+------------------+--------------+
|
||||
| Operating system | | Tested Python | | Latest tested | | Tested |
|
||||
| | | versions | | Pillow version | | processors |
|
||||
+==================================+============================+==================+==============+
|
||||
| macOS 14 Sonoma | 3.8, 3.9, 3.10, 3.11, 3.12 | 10.2.0 |arm |
|
||||
+----------------------------------+----------------------------+------------------+--------------+
|
||||
| macOS 13 Ventura | 3.8, 3.9, 3.10, 3.11 | 10.0.1 |arm |
|
||||
| +----------------------------+------------------+ |
|
||||
| | 3.7 | 9.5.0 | |
|
||||
+----------------------------------+----------------------------+------------------+--------------+
|
||||
| macOS 12 Monterey | 3.7, 3.8, 3.9, 3.10, 3.11 | 9.3.0 |arm |
|
||||
+----------------------------------+----------------------------+------------------+--------------+
|
||||
| macOS 11 Big Sur | 3.7, 3.8, 3.9, 3.10 | 8.4.0 |arm |
|
||||
| +----------------------------+------------------+--------------+
|
||||
| | 3.7, 3.8, 3.9, 3.10, 3.11 | 9.4.0 |x86-64 |
|
||||
| +----------------------------+------------------+ |
|
||||
| | 3.6 | 8.4.0 | |
|
||||
+----------------------------------+----------------------------+------------------+--------------+
|
||||
| macOS 10.15 Catalina | 3.6, 3.7, 3.8, 3.9 | 8.3.2 |x86-64 |
|
||||
| +----------------------------+------------------+ |
|
||||
| | 3.5 | 7.2.0 | |
|
||||
+----------------------------------+----------------------------+------------------+--------------+
|
||||
| macOS 10.14 Mojave | 3.5, 3.6, 3.7, 3.8 | 7.2.0 |x86-64 |
|
||||
| +----------------------------+------------------+ |
|
||||
| | 2.7 | 6.0.0 | |
|
||||
| +----------------------------+------------------+ |
|
||||
| | 3.4 | 5.4.1 | |
|
||||
+----------------------------------+----------------------------+------------------+--------------+
|
||||
| macOS 10.13 High Sierra | 2.7, 3.4, 3.5, 3.6 | 4.2.1 |x86-64 |
|
||||
+----------------------------------+----------------------------+------------------+--------------+
|
||||
| macOS 10.12 Sierra | 2.7, 3.4, 3.5, 3.6 | 4.1.1 |x86-64 |
|
||||
+----------------------------------+----------------------------+------------------+--------------+
|
||||
| Mac OS X 10.11 El Capitan | 2.7, 3.4, 3.5, 3.6, 3.7 | 5.4.1 |x86-64 |
|
||||
| +----------------------------+------------------+ |
|
||||
| | 3.3 | 4.1.0 | |
|
||||
+----------------------------------+----------------------------+------------------+--------------+
|
||||
| Mac OS X 10.9 Mavericks | 2.7, 3.2, 3.3, 3.4 | 3.0.0 |x86-64 |
|
||||
+----------------------------------+----------------------------+------------------+--------------+
|
||||
| Mac OS X 10.8 Mountain Lion | 2.6, 2.7, 3.2, 3.3 | |x86-64 |
|
||||
+----------------------------------+----------------------------+------------------+--------------+
|
||||
| Redhat Linux 6 | 2.6 | |x86 |
|
||||
+----------------------------------+----------------------------+------------------+--------------+
|
||||
| CentOS 6.3 | 2.7, 3.3 | |x86 |
|
||||
+----------------------------------+----------------------------+------------------+--------------+
|
||||
| CentOS 8 | 3.9 | 9.0.0 |x86-64 |
|
||||
+----------------------------------+----------------------------+------------------+--------------+
|
||||
| Fedora 23 | 2.7, 3.4 | 3.1.0 |x86-64 |
|
||||
+----------------------------------+----------------------------+------------------+--------------+
|
||||
| Ubuntu Linux 12.04 LTS (Precise) | | 2.6, 3.2, 3.3, 3.4, 3.5 | 3.4.1 |x86,x86-64 |
|
||||
| | | PyPy5.3.1, PyPy3 v2.4.0 | | |
|
||||
| +----------------------------+------------------+--------------+
|
||||
| | 2.7 | 4.3.0 |x86-64 |
|
||||
| +----------------------------+------------------+--------------+
|
||||
| | 2.7, 3.2 | 3.4.1 |ppc |
|
||||
+----------------------------------+----------------------------+------------------+--------------+
|
||||
| Ubuntu Linux 10.04 LTS (Lucid) | 2.6 | 2.3.0 |x86,x86-64 |
|
||||
+----------------------------------+----------------------------+------------------+--------------+
|
||||
| Debian 8.2 Jessie | 2.7, 3.4 | 3.1.0 |x86-64 |
|
||||
+----------------------------------+----------------------------+------------------+--------------+
|
||||
| Raspbian Jessie | 2.7, 3.4 | 3.1.0 |arm |
|
||||
+----------------------------------+----------------------------+------------------+--------------+
|
||||
| Raspbian Stretch | 2.7, 3.5 | 4.0.0 |arm |
|
||||
+----------------------------------+----------------------------+------------------+--------------+
|
||||
| Raspberry Pi OS | 3.6, 3.7, 3.8, 3.9 | 8.2.0 |arm |
|
||||
| +----------------------------+------------------+ |
|
||||
| | 2.7 | 6.2.2 | |
|
||||
+----------------------------------+----------------------------+------------------+--------------+
|
||||
| Gentoo Linux | 2.7, 3.2 | 2.1.0 |x86-64 |
|
||||
+----------------------------------+----------------------------+------------------+--------------+
|
||||
| FreeBSD 11.1 | 2.7, 3.4, 3.5, 3.6 | 4.3.0 |x86-64 |
|
||||
+----------------------------------+----------------------------+------------------+--------------+
|
||||
| FreeBSD 10.3 | 2.7, 3.4, 3.5 | 4.2.0 |x86-64 |
|
||||
+----------------------------------+----------------------------+------------------+--------------+
|
||||
| FreeBSD 10.2 | 2.7, 3.4 | 3.1.0 |x86-64 |
|
||||
+----------------------------------+----------------------------+------------------+--------------+
|
||||
| Windows 11 | 3.9, 3.10, 3.11, 3.12 | 10.2.0 |arm64 |
|
||||
+----------------------------------+----------------------------+------------------+--------------+
|
||||
| Windows 11 Pro | 3.11, 3.12 | 10.2.0 |x86-64 |
|
||||
+----------------------------------+----------------------------+------------------+--------------+
|
||||
| Windows 10 | 3.7 | 7.1.0 |x86-64 |
|
||||
+----------------------------------+----------------------------+------------------+--------------+
|
||||
| Windows 10/Cygwin 3.3 | 3.6, 3.7, 3.8, 3.9 | 8.4.0 |x86-64 |
|
||||
+----------------------------------+----------------------------+------------------+--------------+
|
||||
| Windows 8.1 Pro | 2.6, 2.7, 3.2, 3.3, 3.4 | 2.4.0 |x86,x86-64 |
|
||||
+----------------------------------+----------------------------+------------------+--------------+
|
||||
| Windows 8 Pro | 2.6, 2.7, 3.2, 3.3, 3.4a3 | 2.2.0 |x86,x86-64 |
|
||||
+----------------------------------+----------------------------+------------------+--------------+
|
||||
| Windows 7 Professional | 3.7 | 7.0.0 |x86,x86-64 |
|
||||
+----------------------------------+----------------------------+------------------+--------------+
|
||||
| Windows Server 2008 R2 Enterprise| 3.3 | |x86-64 |
|
||||
+----------------------------------+----------------------------+------------------+--------------+
|
||||
.. Note:: This section has moved to :ref:`building-from-source`. Please update references accordingly.
|
||||
|
||||
Old Versions
|
||||
------------
|
||||
|
||||
You can download old distributions from the `release history at PyPI
|
||||
<https://pypi.org/project/pillow/#history>`_ and by direct URL access
|
||||
eg. https://pypi.org/project/pillow/1.0/.
|
||||
.. Note:: This section has moved to :ref:`old-versions`. Please update references accordingly.
|
||||
|
|
97
docs/installation/basic-installation.rst
Normal file
|
@ -0,0 +1,97 @@
|
|||
.. raw:: html
|
||||
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
activateTab(getOS());
|
||||
});
|
||||
</script>
|
||||
|
||||
.. _basic-installation:
|
||||
|
||||
Basic Installation
|
||||
==================
|
||||
|
||||
.. note::
|
||||
|
||||
The following instructions will install Pillow with support for
|
||||
most common image formats. See :ref:`external-libraries` for a
|
||||
full list of external libraries supported.
|
||||
|
||||
Install Pillow with :command:`pip`::
|
||||
|
||||
python3 -m pip install --upgrade pip
|
||||
python3 -m pip install --upgrade Pillow
|
||||
|
||||
Optionally, install :pypi:`defusedxml` for Pillow to read XMP data,
|
||||
and :pypi:`olefile` for Pillow to read FPX and MIC images::
|
||||
|
||||
python3 -m pip install --upgrade defusedxml olefile
|
||||
|
||||
|
||||
.. tab:: Linux
|
||||
|
||||
We provide binaries for Linux for each of the supported Python
|
||||
versions in the manylinux wheel format. These include support for all
|
||||
optional libraries except libimagequant. Raqm support requires
|
||||
FriBiDi to be installed separately::
|
||||
|
||||
python3 -m pip install --upgrade pip
|
||||
python3 -m pip install --upgrade Pillow
|
||||
|
||||
Most major Linux distributions, including Fedora, Ubuntu and ArchLinux
|
||||
also include Pillow in packages that previously contained PIL e.g.
|
||||
``python-imaging``. Debian splits it into two packages, ``python3-pil``
|
||||
and ``python3-pil.imagetk``.
|
||||
|
||||
.. tab:: macOS
|
||||
|
||||
We provide binaries for macOS for each of the supported Python
|
||||
versions in the wheel format. These include support for all optional
|
||||
libraries except libimagequant. Raqm support requires
|
||||
FriBiDi to be installed separately::
|
||||
|
||||
python3 -m pip install --upgrade pip
|
||||
python3 -m pip install --upgrade Pillow
|
||||
|
||||
While we provide binaries for both x86-64 and arm64, we do not provide universal2
|
||||
binaries. However, it is simple to combine our current binaries to create one::
|
||||
|
||||
python3 -m pip download --only-binary=:all: --platform macosx_10_10_x86_64 Pillow
|
||||
python3 -m pip download --only-binary=:all: --platform macosx_11_0_arm64 Pillow
|
||||
python3 -m pip install delocate
|
||||
|
||||
Then, with the names of the downloaded wheels, use Python to combine them::
|
||||
|
||||
from delocate.fuse import fuse_wheels
|
||||
fuse_wheels('Pillow-9.4.0-2-cp39-cp39-macosx_10_10_x86_64.whl', 'Pillow-9.4.0-cp39-cp39-macosx_11_0_arm64.whl', 'Pillow-9.4.0-cp39-cp39-macosx_11_0_universal2.whl')
|
||||
|
||||
.. tab:: Windows
|
||||
|
||||
We provide Pillow binaries for Windows compiled for the matrix of supported
|
||||
Pythons in the wheel format. These include x86, x86-64 and arm64 versions
|
||||
(with the exception of Python 3.8 on arm64). These binaries include support
|
||||
for all optional libraries except libimagequant and libxcb. Raqm support
|
||||
requires FriBiDi to be installed separately::
|
||||
|
||||
python3 -m pip install --upgrade pip
|
||||
python3 -m pip install --upgrade Pillow
|
||||
|
||||
To install Pillow in MSYS2, see :ref:`building-from-source`.
|
||||
|
||||
.. tab:: FreeBSD
|
||||
|
||||
Pillow can be installed on FreeBSD via the official Ports or Packages systems:
|
||||
|
||||
**Ports**::
|
||||
|
||||
cd /usr/ports/graphics/py-pillow && make install clean
|
||||
|
||||
**Packages**::
|
||||
|
||||
pkg install py38-pillow
|
||||
|
||||
.. note::
|
||||
|
||||
The `Pillow FreeBSD port
|
||||
<https://www.freshports.org/graphics/py-pillow/>`_ and packages
|
||||
are tested by the ports team with all supported FreeBSD versions.
|
317
docs/installation/building-from-source.rst
Normal file
|
@ -0,0 +1,317 @@
|
|||
.. raw:: html
|
||||
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
activateTab(getOS());
|
||||
});
|
||||
</script>
|
||||
|
||||
.. _building-from-source:
|
||||
|
||||
Building From Source
|
||||
====================
|
||||
|
||||
.. _external-libraries:
|
||||
|
||||
External Libraries
|
||||
------------------
|
||||
|
||||
.. note::
|
||||
|
||||
You **do not need to install all supported external libraries** to
|
||||
use Pillow's basic features. **Zlib** and **libjpeg** are required
|
||||
by default.
|
||||
|
||||
.. note::
|
||||
|
||||
There are Dockerfiles in our `Docker images repo
|
||||
<https://github.com/python-pillow/docker-images>`_ to install the
|
||||
dependencies for some operating systems.
|
||||
|
||||
Many of Pillow's features require external libraries:
|
||||
|
||||
* **libjpeg** provides JPEG functionality.
|
||||
|
||||
* Pillow has been tested with libjpeg versions **6b**, **8**, **9-9d** and
|
||||
libjpeg-turbo version **8**.
|
||||
* Starting with Pillow 3.0.0, libjpeg is required by default. It can be
|
||||
disabled with the ``-C jpeg=disable`` flag.
|
||||
|
||||
* **zlib** provides access to compressed PNGs
|
||||
|
||||
* Starting with Pillow 3.0.0, zlib is required by default. It can be
|
||||
disabled with the ``-C zlib=disable`` flag.
|
||||
|
||||
* **libtiff** provides compressed TIFF functionality
|
||||
|
||||
* Pillow has been tested with libtiff versions **3.x** and **4.0-4.6.0**
|
||||
|
||||
* **libfreetype** provides type related services
|
||||
|
||||
* **littlecms** provides color management
|
||||
|
||||
* Pillow version 2.2.1 and below uses liblcms1, Pillow 2.3.0 and
|
||||
above uses liblcms2. Tested with **1.19** and **2.7-2.16**.
|
||||
|
||||
* **libwebp** provides the WebP format.
|
||||
|
||||
* Pillow has been tested with version **0.1.3**, which does not read
|
||||
transparent WebP files. Versions **0.3.0** and above support
|
||||
transparency.
|
||||
|
||||
* **openjpeg** provides JPEG 2000 functionality.
|
||||
|
||||
* Pillow has been tested with openjpeg **2.0.0**, **2.1.0**, **2.3.1**,
|
||||
**2.4.0**, **2.5.0** and **2.5.2**.
|
||||
* Pillow does **not** support the earlier **1.5** series which ships
|
||||
with Debian Jessie.
|
||||
|
||||
* **libimagequant** provides improved color quantization
|
||||
|
||||
* Pillow has been tested with libimagequant **2.6-4.3**
|
||||
* Libimagequant is licensed GPLv3, which is more restrictive than
|
||||
the Pillow license, therefore we will not be distributing binaries
|
||||
with libimagequant support enabled.
|
||||
|
||||
* **libraqm** provides complex text layout support.
|
||||
|
||||
* libraqm provides bidirectional text support (using FriBiDi),
|
||||
shaping (using HarfBuzz), and proper script itemization. As a
|
||||
result, Raqm can support most writing systems covered by Unicode.
|
||||
* libraqm depends on the following libraries: FreeType, HarfBuzz,
|
||||
FriBiDi, make sure that you install them before installing libraqm
|
||||
if not available as package in your system.
|
||||
* Setting text direction or font features is not supported without libraqm.
|
||||
* Pillow wheels since version 8.2.0 include a modified version of libraqm that
|
||||
loads libfribidi at runtime if it is installed.
|
||||
On Windows this requires compiling FriBiDi and installing ``fribidi.dll``
|
||||
into a directory listed in the `Dynamic-link library search order (Microsoft Learn)
|
||||
<https://learn.microsoft.com/en-us/windows/win32/dlls/dynamic-link-library-search-order#search-order-for-unpackaged-apps>`_
|
||||
(``fribidi-0.dll`` or ``libfribidi-0.dll`` are also detected).
|
||||
See `Build Options`_ to see how to build this version.
|
||||
* Previous versions of Pillow (5.0.0 to 8.1.2) linked libraqm dynamically at runtime.
|
||||
|
||||
* **libxcb** provides X11 screengrab support.
|
||||
|
||||
.. tab:: Linux
|
||||
|
||||
If you didn't build Python from source, make sure you have Python's
|
||||
development libraries installed.
|
||||
|
||||
In Debian or Ubuntu::
|
||||
|
||||
sudo apt-get install python3-dev python3-setuptools
|
||||
|
||||
In Fedora, the command is::
|
||||
|
||||
sudo dnf install python3-devel redhat-rpm-config
|
||||
|
||||
In Alpine, the command is::
|
||||
|
||||
sudo apk add python3-dev py3-setuptools
|
||||
|
||||
.. Note:: ``redhat-rpm-config`` is required on Fedora 23, but not earlier versions.
|
||||
|
||||
Prerequisites for **Ubuntu 16.04 LTS - 22.04 LTS** are installed with::
|
||||
|
||||
sudo apt-get install libtiff5-dev libjpeg8-dev libopenjp2-7-dev zlib1g-dev \
|
||||
libfreetype6-dev liblcms2-dev libwebp-dev tcl8.6-dev tk8.6-dev python3-tk \
|
||||
libharfbuzz-dev libfribidi-dev libxcb1-dev
|
||||
|
||||
To install libraqm, ``sudo apt-get install meson`` and then see
|
||||
``depends/install_raqm.sh``.
|
||||
|
||||
Prerequisites are installed on recent **Red Hat**, **CentOS** or **Fedora** with::
|
||||
|
||||
sudo dnf install libtiff-devel libjpeg-devel openjpeg2-devel zlib-devel \
|
||||
freetype-devel lcms2-devel libwebp-devel tcl-devel tk-devel \
|
||||
harfbuzz-devel fribidi-devel libraqm-devel libimagequant-devel libxcb-devel
|
||||
|
||||
Note that the package manager may be yum or DNF, depending on the
|
||||
exact distribution.
|
||||
|
||||
Prerequisites are installed for **Alpine** with::
|
||||
|
||||
sudo apk add tiff-dev jpeg-dev openjpeg-dev zlib-dev freetype-dev lcms2-dev \
|
||||
libwebp-dev tcl-dev tk-dev harfbuzz-dev fribidi-dev libimagequant-dev \
|
||||
libxcb-dev libpng-dev
|
||||
|
||||
See also the ``Dockerfile``\s in the Test Infrastructure repo
|
||||
(https://github.com/python-pillow/docker-images) for a known working
|
||||
install process for other tested distros.
|
||||
|
||||
.. tab:: macOS
|
||||
|
||||
The Xcode command line tools are required to compile portions of
|
||||
Pillow. The tools are installed by running ``xcode-select --install``
|
||||
from the command line. The command line tools are required even if you
|
||||
have the full Xcode package installed. It may be necessary to run
|
||||
``sudo xcodebuild -license`` to accept the license prior to using the
|
||||
tools.
|
||||
|
||||
The easiest way to install external libraries is via `Homebrew
|
||||
<https://brew.sh/>`_. After you install Homebrew, run::
|
||||
|
||||
brew install libjpeg libtiff little-cms2 openjpeg webp
|
||||
|
||||
To install libraqm on macOS use Homebrew to install its dependencies::
|
||||
|
||||
brew install freetype harfbuzz fribidi
|
||||
|
||||
Then see ``depends/install_raqm_cmake.sh`` to install libraqm.
|
||||
|
||||
.. tab:: Windows
|
||||
|
||||
We recommend you use prebuilt wheels from PyPI.
|
||||
If you wish to compile Pillow manually, you can use the build scripts
|
||||
in the ``winbuild`` directory used for CI testing and development.
|
||||
These scripts require Visual Studio 2017 or newer and NASM.
|
||||
|
||||
The scripts also install Pillow from the local copy of the source code, so the
|
||||
`Installing`_ instructions will not be necessary afterwards.
|
||||
|
||||
.. tab:: Windows using MSYS2/MinGW
|
||||
|
||||
To build Pillow using MSYS2, make sure you run the **MSYS2 MinGW 32-bit** or
|
||||
**MSYS2 MinGW 64-bit** console, *not* **MSYS2** directly.
|
||||
|
||||
The following instructions target the 64-bit build, for 32-bit
|
||||
replace all occurrences of ``mingw-w64-x86_64-`` with ``mingw-w64-i686-``.
|
||||
|
||||
Make sure you have Python and GCC installed::
|
||||
|
||||
pacman -S \
|
||||
mingw-w64-x86_64-gcc \
|
||||
mingw-w64-x86_64-python3 \
|
||||
mingw-w64-x86_64-python3-pip \
|
||||
mingw-w64-x86_64-python3-setuptools
|
||||
|
||||
Prerequisites are installed on **MSYS2 MinGW 64-bit** with::
|
||||
|
||||
pacman -S \
|
||||
mingw-w64-x86_64-libjpeg-turbo \
|
||||
mingw-w64-x86_64-zlib \
|
||||
mingw-w64-x86_64-libtiff \
|
||||
mingw-w64-x86_64-freetype \
|
||||
mingw-w64-x86_64-lcms2 \
|
||||
mingw-w64-x86_64-libwebp \
|
||||
mingw-w64-x86_64-openjpeg2 \
|
||||
mingw-w64-x86_64-libimagequant \
|
||||
mingw-w64-x86_64-libraqm
|
||||
|
||||
https://www.msys2.org/docs/python/ states that setuptools >= 60 does not work with
|
||||
MSYS2. To workaround this, before installing Pillow you must run::
|
||||
|
||||
export SETUPTOOLS_USE_DISTUTILS=stdlib
|
||||
|
||||
.. tab:: FreeBSD
|
||||
|
||||
.. Note:: Only FreeBSD 10 and 11 tested
|
||||
|
||||
Make sure you have Python's development libraries installed::
|
||||
|
||||
sudo pkg install python3
|
||||
|
||||
Prerequisites are installed on **FreeBSD 10 or 11** with::
|
||||
|
||||
sudo pkg install jpeg-turbo tiff webp lcms2 freetype2 openjpeg harfbuzz fribidi libxcb
|
||||
|
||||
Then see ``depends/install_raqm_cmake.sh`` to install libraqm.
|
||||
|
||||
.. tab:: Android
|
||||
|
||||
Basic Android support has been added for compilation within the Termux
|
||||
environment. The dependencies can be installed by::
|
||||
|
||||
pkg install -y python ndk-sysroot clang make \
|
||||
libjpeg-turbo
|
||||
|
||||
This has been tested within the Termux app on ChromeOS, on x86.
|
||||
|
||||
Installing
|
||||
----------
|
||||
|
||||
Once you have installed the prerequisites, to install Pillow from the source
|
||||
code on PyPI, run::
|
||||
|
||||
python3 -m pip install --upgrade pip
|
||||
python3 -m pip install --upgrade Pillow --no-binary :all:
|
||||
|
||||
If the prerequisites are installed in the standard library locations
|
||||
for your machine (e.g. :file:`/usr` or :file:`/usr/local`), no
|
||||
additional configuration should be required. If they are installed in
|
||||
a non-standard location, you may need to configure setuptools to use
|
||||
those locations by editing :file:`setup.py` or
|
||||
:file:`pyproject.toml`, or by adding environment variables on the command
|
||||
line::
|
||||
|
||||
CFLAGS="-I/usr/pkg/include" python3 -m pip install --upgrade Pillow --no-binary :all:
|
||||
|
||||
If Pillow has been previously built without the required
|
||||
prerequisites, it may be necessary to manually clear the pip cache or
|
||||
build without cache using the ``--no-cache-dir`` option to force a
|
||||
build with newly installed external libraries.
|
||||
|
||||
If you would like to install from a local copy of the source code instead, you
|
||||
can clone from GitHub with ``git clone https://github.com/python-pillow/Pillow``
|
||||
or download and extract the `compressed archive from PyPI`_.
|
||||
|
||||
After navigating to the Pillow directory, run::
|
||||
|
||||
python3 -m pip install --upgrade pip
|
||||
python3 -m pip install .
|
||||
|
||||
.. _compressed archive from PyPI: https://pypi.org/project/pillow/#files
|
||||
|
||||
Build Options
|
||||
^^^^^^^^^^^^^
|
||||
|
||||
* Environment variable: ``MAX_CONCURRENCY=n``. Pillow can use
|
||||
multiprocessing to build the extension. Setting ``MAX_CONCURRENCY``
|
||||
sets the number of CPUs to use, or can disable parallel building by
|
||||
using a setting of 1. By default, it uses 4 CPUs, or if 4 are not
|
||||
available, as many as are present.
|
||||
|
||||
* Config settings: ``-C zlib=disable``, ``-C jpeg=disable``,
|
||||
``-C tiff=disable``, ``-C freetype=disable``, ``-C raqm=disable``,
|
||||
``-C lcms=disable``, ``-C webp=disable``, ``-C webpmux=disable``,
|
||||
``-C jpeg2000=disable``, ``-C imagequant=disable``, ``-C xcb=disable``.
|
||||
Disable building the corresponding feature even if the development
|
||||
libraries are present on the building machine.
|
||||
|
||||
* Config settings: ``-C zlib=enable``, ``-C jpeg=enable``,
|
||||
``-C tiff=enable``, ``-C freetype=enable``, ``-C raqm=enable``,
|
||||
``-C lcms=enable``, ``-C webp=enable``, ``-C webpmux=enable``,
|
||||
``-C jpeg2000=enable``, ``-C imagequant=enable``, ``-C xcb=enable``.
|
||||
Require that the corresponding feature is built. The build will raise
|
||||
an exception if the libraries are not found. Webpmux (WebP metadata)
|
||||
relies on WebP support. Tcl and Tk also must be used together.
|
||||
|
||||
* Config settings: ``-C raqm=vendor``, ``-C fribidi=vendor``.
|
||||
These flags are used to compile a modified version of libraqm and
|
||||
a shim that dynamically loads libfribidi at runtime. These are
|
||||
used to compile the standard Pillow wheels. Compiling libraqm requires
|
||||
a C99-compliant compiler.
|
||||
|
||||
* Build flag: ``-C platform-guessing=disable``. Skips all of the
|
||||
platform dependent guessing of include and library directories for
|
||||
automated build systems that configure the proper paths in the
|
||||
environment variables (e.g. Buildroot).
|
||||
|
||||
* Build flag: ``-C debug=true``. Adds a debugging flag to the include and
|
||||
library search process to dump all paths searched for and found to
|
||||
stdout.
|
||||
|
||||
|
||||
Sample usage::
|
||||
|
||||
python3 -m pip install --upgrade Pillow -C [feature]=enable
|
||||
|
||||
.. _old-versions:
|
||||
|
||||
Old Versions
|
||||
============
|
||||
|
||||
You can download old distributions from the `release history at PyPI
|
||||
<https://pypi.org/project/pillow/#history>`_ and by direct URL access
|
||||
eg. https://pypi.org/project/pillow/1.0/.
|
10
docs/installation/index.rst
Normal file
|
@ -0,0 +1,10 @@
|
|||
Installation
|
||||
============
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
|
||||
basic-installation
|
||||
python-support
|
||||
platform-support
|
||||
building-from-source
|
170
docs/installation/platform-support.rst
Normal file
|
@ -0,0 +1,170 @@
|
|||
.. _platform-support:
|
||||
|
||||
Platform Support
|
||||
================
|
||||
|
||||
Current platform support for Pillow. Binary distributions are
|
||||
contributed for each release on a volunteer basis, but the source
|
||||
should compile and run everywhere platform support is listed. In
|
||||
general, we aim to support all current versions of Linux, macOS, and
|
||||
Windows.
|
||||
|
||||
Continuous Integration Targets
|
||||
------------------------------
|
||||
|
||||
These platforms are built and tested for every change.
|
||||
|
||||
+----------------------------------+----------------------------+---------------------+
|
||||
| Operating system | Tested Python versions | Tested architecture |
|
||||
+==================================+============================+=====================+
|
||||
| Alpine | 3.9 | x86-64 |
|
||||
+----------------------------------+----------------------------+---------------------+
|
||||
| Amazon Linux 2 | 3.9 | x86-64 |
|
||||
+----------------------------------+----------------------------+---------------------+
|
||||
| Amazon Linux 2023 | 3.9 | x86-64 |
|
||||
+----------------------------------+----------------------------+---------------------+
|
||||
| Arch | 3.9 | x86-64 |
|
||||
+----------------------------------+----------------------------+---------------------+
|
||||
| CentOS 7 | 3.9 | x86-64 |
|
||||
+----------------------------------+----------------------------+---------------------+
|
||||
| CentOS Stream 8 | 3.9 | x86-64 |
|
||||
+----------------------------------+----------------------------+---------------------+
|
||||
| CentOS Stream 9 | 3.9 | x86-64 |
|
||||
+----------------------------------+----------------------------+---------------------+
|
||||
| Debian 11 Bullseye | 3.9 | x86-64 |
|
||||
+----------------------------------+----------------------------+---------------------+
|
||||
| Debian 12 Bookworm | 3.11 | x86, x86-64 |
|
||||
+----------------------------------+----------------------------+---------------------+
|
||||
| Fedora 38 | 3.11 | x86-64 |
|
||||
+----------------------------------+----------------------------+---------------------+
|
||||
| Fedora 39 | 3.12 | x86-64 |
|
||||
+----------------------------------+----------------------------+---------------------+
|
||||
| Gentoo | 3.9 | x86-64 |
|
||||
+----------------------------------+----------------------------+---------------------+
|
||||
| macOS 12 Monterey | 3.8, 3.9 | x86-64 |
|
||||
+----------------------------------+----------------------------+---------------------+
|
||||
| macOS 14 Sonoma | 3.10, 3.11, 3.12, 3.13, | arm64 |
|
||||
| | PyPy3 | |
|
||||
+----------------------------------+----------------------------+---------------------+
|
||||
| Ubuntu Linux 20.04 LTS (Focal) | 3.8 | x86-64 |
|
||||
+----------------------------------+----------------------------+---------------------+
|
||||
| Ubuntu Linux 22.04 LTS (Jammy) | 3.8, 3.9, 3.10, 3.11, | x86-64 |
|
||||
| | 3.12, 3.13, PyPy3 | |
|
||||
| +----------------------------+---------------------+
|
||||
| | 3.10 | arm64v8, ppc64le, |
|
||||
| | | s390x |
|
||||
+----------------------------------+----------------------------+---------------------+
|
||||
| Windows Server 2016 | 3.8 | x86-64 |
|
||||
+----------------------------------+----------------------------+---------------------+
|
||||
| Windows Server 2022 | 3.8, 3.9, 3.10, 3.11, | x86-64 |
|
||||
| | 3.12, 3.13, PyPy3 | |
|
||||
| +----------------------------+---------------------+
|
||||
| | 3.12 | x86 |
|
||||
| +----------------------------+---------------------+
|
||||
| | 3.9 (MinGW) | x86-64 |
|
||||
| +----------------------------+---------------------+
|
||||
| | 3.8, 3.9 (Cygwin) | x86-64 |
|
||||
+----------------------------------+----------------------------+---------------------+
|
||||
|
||||
|
||||
Other Platforms
|
||||
---------------
|
||||
|
||||
These platforms have been reported to work at the versions mentioned.
|
||||
|
||||
.. note::
|
||||
|
||||
Contributors please test Pillow on your platform then update this
|
||||
document and send a pull request.
|
||||
|
||||
+----------------------------------+----------------------------+------------------+--------------+
|
||||
| Operating system | | Tested Python | | Latest tested | | Tested |
|
||||
| | | versions | | Pillow version | | processors |
|
||||
+==================================+============================+==================+==============+
|
||||
| macOS 14 Sonoma | 3.8, 3.9, 3.10, 3.11, 3.12 | 10.2.0 |arm |
|
||||
+----------------------------------+----------------------------+------------------+--------------+
|
||||
| macOS 13 Ventura | 3.8, 3.9, 3.10, 3.11 | 10.0.1 |arm |
|
||||
| +----------------------------+------------------+ |
|
||||
| | 3.7 | 9.5.0 | |
|
||||
+----------------------------------+----------------------------+------------------+--------------+
|
||||
| macOS 12 Monterey | 3.7, 3.8, 3.9, 3.10, 3.11 | 9.3.0 |arm |
|
||||
+----------------------------------+----------------------------+------------------+--------------+
|
||||
| macOS 11 Big Sur | 3.7, 3.8, 3.9, 3.10 | 8.4.0 |arm |
|
||||
| +----------------------------+------------------+--------------+
|
||||
| | 3.7, 3.8, 3.9, 3.10, 3.11 | 9.4.0 |x86-64 |
|
||||
| +----------------------------+------------------+ |
|
||||
| | 3.6 | 8.4.0 | |
|
||||
+----------------------------------+----------------------------+------------------+--------------+
|
||||
| macOS 10.15 Catalina | 3.6, 3.7, 3.8, 3.9 | 8.3.2 |x86-64 |
|
||||
| +----------------------------+------------------+ |
|
||||
| | 3.5 | 7.2.0 | |
|
||||
+----------------------------------+----------------------------+------------------+--------------+
|
||||
| macOS 10.14 Mojave | 3.5, 3.6, 3.7, 3.8 | 7.2.0 |x86-64 |
|
||||
| +----------------------------+------------------+ |
|
||||
| | 2.7 | 6.0.0 | |
|
||||
| +----------------------------+------------------+ |
|
||||
| | 3.4 | 5.4.1 | |
|
||||
+----------------------------------+----------------------------+------------------+--------------+
|
||||
| macOS 10.13 High Sierra | 2.7, 3.4, 3.5, 3.6 | 4.2.1 |x86-64 |
|
||||
+----------------------------------+----------------------------+------------------+--------------+
|
||||
| macOS 10.12 Sierra | 2.7, 3.4, 3.5, 3.6 | 4.1.1 |x86-64 |
|
||||
+----------------------------------+----------------------------+------------------+--------------+
|
||||
| Mac OS X 10.11 El Capitan | 2.7, 3.4, 3.5, 3.6, 3.7 | 5.4.1 |x86-64 |
|
||||
| +----------------------------+------------------+ |
|
||||
| | 3.3 | 4.1.0 | |
|
||||
+----------------------------------+----------------------------+------------------+--------------+
|
||||
| Mac OS X 10.9 Mavericks | 2.7, 3.2, 3.3, 3.4 | 3.0.0 |x86-64 |
|
||||
+----------------------------------+----------------------------+------------------+--------------+
|
||||
| Mac OS X 10.8 Mountain Lion | 2.6, 2.7, 3.2, 3.3 | |x86-64 |
|
||||
+----------------------------------+----------------------------+------------------+--------------+
|
||||
| Redhat Linux 6 | 2.6 | |x86 |
|
||||
+----------------------------------+----------------------------+------------------+--------------+
|
||||
| CentOS 6.3 | 2.7, 3.3 | |x86 |
|
||||
+----------------------------------+----------------------------+------------------+--------------+
|
||||
| CentOS 8 | 3.9 | 9.0.0 |x86-64 |
|
||||
+----------------------------------+----------------------------+------------------+--------------+
|
||||
| Fedora 23 | 2.7, 3.4 | 3.1.0 |x86-64 |
|
||||
+----------------------------------+----------------------------+------------------+--------------+
|
||||
| Ubuntu Linux 12.04 LTS (Precise) | | 2.6, 3.2, 3.3, 3.4, 3.5 | 3.4.1 |x86,x86-64 |
|
||||
| | | PyPy5.3.1, PyPy3 v2.4.0 | | |
|
||||
| +----------------------------+------------------+--------------+
|
||||
| | 2.7 | 4.3.0 |x86-64 |
|
||||
| +----------------------------+------------------+--------------+
|
||||
| | 2.7, 3.2 | 3.4.1 |ppc |
|
||||
+----------------------------------+----------------------------+------------------+--------------+
|
||||
| Ubuntu Linux 10.04 LTS (Lucid) | 2.6 | 2.3.0 |x86,x86-64 |
|
||||
+----------------------------------+----------------------------+------------------+--------------+
|
||||
| Debian 8.2 Jessie | 2.7, 3.4 | 3.1.0 |x86-64 |
|
||||
+----------------------------------+----------------------------+------------------+--------------+
|
||||
| Raspbian Jessie | 2.7, 3.4 | 3.1.0 |arm |
|
||||
+----------------------------------+----------------------------+------------------+--------------+
|
||||
| Raspbian Stretch | 2.7, 3.5 | 4.0.0 |arm |
|
||||
+----------------------------------+----------------------------+------------------+--------------+
|
||||
| Raspberry Pi OS | 3.6, 3.7, 3.8, 3.9 | 8.2.0 |arm |
|
||||
| +----------------------------+------------------+ |
|
||||
| | 2.7 | 6.2.2 | |
|
||||
+----------------------------------+----------------------------+------------------+--------------+
|
||||
| Gentoo Linux | 2.7, 3.2 | 2.1.0 |x86-64 |
|
||||
+----------------------------------+----------------------------+------------------+--------------+
|
||||
| FreeBSD 11.1 | 2.7, 3.4, 3.5, 3.6 | 4.3.0 |x86-64 |
|
||||
+----------------------------------+----------------------------+------------------+--------------+
|
||||
| FreeBSD 10.3 | 2.7, 3.4, 3.5 | 4.2.0 |x86-64 |
|
||||
+----------------------------------+----------------------------+------------------+--------------+
|
||||
| FreeBSD 10.2 | 2.7, 3.4 | 3.1.0 |x86-64 |
|
||||
+----------------------------------+----------------------------+------------------+--------------+
|
||||
| Windows 11 | 3.9, 3.10, 3.11, 3.12 | 10.2.0 |arm64 |
|
||||
+----------------------------------+----------------------------+------------------+--------------+
|
||||
| Windows 11 Pro | 3.11, 3.12 | 10.2.0 |x86-64 |
|
||||
+----------------------------------+----------------------------+------------------+--------------+
|
||||
| Windows 10 | 3.7 | 7.1.0 |x86-64 |
|
||||
+----------------------------------+----------------------------+------------------+--------------+
|
||||
| Windows 10/Cygwin 3.3 | 3.6, 3.7, 3.8, 3.9 | 8.4.0 |x86-64 |
|
||||
+----------------------------------+----------------------------+------------------+--------------+
|
||||
| Windows 8.1 Pro | 2.6, 2.7, 3.2, 3.3, 3.4 | 2.4.0 |x86,x86-64 |
|
||||
+----------------------------------+----------------------------+------------------+--------------+
|
||||
| Windows 8 Pro | 2.6, 2.7, 3.2, 3.3, 3.4a3 | 2.2.0 |x86,x86-64 |
|
||||
+----------------------------------+----------------------------+------------------+--------------+
|
||||
| Windows 7 Professional | 3.7 | 7.0.0 |x86,x86-64 |
|
||||
+----------------------------------+----------------------------+------------------+--------------+
|
||||
| Windows Server 2008 R2 Enterprise| 3.3 | |x86-64 |
|
||||
+----------------------------------+----------------------------+------------------+--------------+
|
14
docs/installation/python-support.rst
Normal file
|
@ -0,0 +1,14 @@
|
|||
.. _python-support:
|
||||
|
||||
Python Support
|
||||
==============
|
||||
|
||||
Pillow supports these Python versions.
|
||||
|
||||
.. csv-table:: Newer versions
|
||||
:file: newer-versions.csv
|
||||
:header-rows: 1
|
||||
|
||||
.. csv-table:: Older versions
|
||||
:file: older-versions.csv
|
||||
:header-rows: 1
|
|
@ -1,6 +1,33 @@
|
|||
10.0.0
|
||||
------
|
||||
|
||||
Security
|
||||
========
|
||||
|
||||
Limit size even if one dimension is zero
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
When performing decompression bomb checks, Pillow did not reject images with
|
||||
excessive width and zero height, or zero width and excessive height. That has
|
||||
now been fixed.
|
||||
|
||||
This effectively dates to the PIL fork, since problem images would still have
|
||||
been processed before Pillow started checking for decompression bombs.
|
||||
|
||||
.. _Added ImageFont.MAX_STRING_LENGTH:
|
||||
|
||||
:cve:`2023-44271`: Added ImageFont.MAX_STRING_LENGTH
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
To protect against potential DOS attacks when using arbitrary strings as text
|
||||
input, Pillow will now raise a :py:exc:`ValueError` if the number of characters
|
||||
passed into ImageFont methods is over a certain limit,
|
||||
:py:data:`PIL.ImageFont.MAX_STRING_LENGTH`.
|
||||
|
||||
This threshold can be changed by setting
|
||||
:py:data:`PIL.ImageFont.MAX_STRING_LENGTH`. It can be disabled by setting
|
||||
``ImageFont.MAX_STRING_LENGTH = None``.
|
||||
|
||||
Backwards Incompatible Changes
|
||||
==============================
|
||||
|
||||
|
@ -157,31 +184,6 @@ Added ``alpha_only`` argument to ``getbbox()``
|
|||
and the image has an alpha channel, trim transparent pixels. Otherwise, trim
|
||||
pixels when all channels are zero.
|
||||
|
||||
Security
|
||||
========
|
||||
|
||||
Limit size even if one dimension is zero
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
When performing decompression bomb checks, Pillow did not reject images with
|
||||
excessive width and zero height, or zero width and excessive height. That has
|
||||
now been fixed.
|
||||
|
||||
This effectively dates to the PIL fork, since problem images would still have
|
||||
been processed before Pillow started checking for decompression bombs.
|
||||
|
||||
Added ImageFont.MAX_STRING_LENGTH
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
:cve:`2023-44271`: To protect against potential DOS attacks when using arbitrary strings as text
|
||||
input, Pillow will now raise a :py:exc:`ValueError` if the number of characters
|
||||
passed into ImageFont methods is over a certain limit,
|
||||
:py:data:`PIL.ImageFont.MAX_STRING_LENGTH`.
|
||||
|
||||
This threshold can be changed by setting
|
||||
:py:data:`PIL.ImageFont.MAX_STRING_LENGTH`. It can be disabled by setting
|
||||
``ImageFont.MAX_STRING_LENGTH = None``.
|
||||
|
||||
Other Changes
|
||||
=============
|
||||
|
||||
|
|
|
@ -4,11 +4,17 @@
|
|||
Security
|
||||
========
|
||||
|
||||
This release addresses :cve:`2023-4863`, by providing an updated install script and
|
||||
updated wheels to include libwebp 1.3.2, preventing a potential heap buffer overflow
|
||||
in WebP.
|
||||
:cve:`2023-4863`: Updated install script and updated wheels
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
This release provides an updated install script and updated wheels to
|
||||
include libwebp 1.3.2, preventing a potential heap buffer overflow in
|
||||
WebP.
|
||||
|
||||
Other Changes
|
||||
=============
|
||||
|
||||
Updated tests to pass with latest zlib version
|
||||
==============================================
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
The release of zlib 1.3 caused one of the tests in the Pillow test suite to fail.
|
||||
|
|
|
@ -1,6 +1,38 @@
|
|||
10.2.0
|
||||
------
|
||||
|
||||
Security
|
||||
========
|
||||
|
||||
ImageFont.getmask: Applied ImageFont.MAX_STRING_LENGTH
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
To protect against potential DOS attacks when using arbitrary strings as text input,
|
||||
Pillow will now raise a :py:exc:`ValueError` if the number of characters passed into
|
||||
:py:meth:`PIL.ImageFont.ImageFont.getmask` is over a certain limit,
|
||||
:py:data:`PIL.ImageFont.MAX_STRING_LENGTH`.
|
||||
|
||||
This threshold can be changed by setting :py:data:`PIL.ImageFont.MAX_STRING_LENGTH`. It
|
||||
can be disabled by setting ``ImageFont.MAX_STRING_LENGTH = None``.
|
||||
|
||||
A decompression bomb check has also been added to
|
||||
:py:meth:`PIL.ImageFont.ImageFont.getmask`.
|
||||
|
||||
ImageFont.getmask: Trim glyph size
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
To protect against potential DOS attacks when using PIL fonts,
|
||||
:py:class:`PIL.ImageFont.ImageFont` now trims the size of individual glyphs so that
|
||||
they do not extend beyond the bitmap image.
|
||||
|
||||
:cve:`2023-50447`: ImageMath.eval: Restricted environment keys
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
If an attacker has control over the keys passed to the
|
||||
``environment`` argument of :py:meth:`PIL.ImageMath.eval`, they may be able to execute
|
||||
arbitrary code. To prevent this, keys matching the names of builtins and keys
|
||||
containing double underscores will now raise a :py:exc:`ValueError`.
|
||||
|
||||
Deprecations
|
||||
============
|
||||
|
||||
|
@ -63,38 +95,6 @@ JPEG tables-only streamtype
|
|||
When saving JPEG files, ``streamtype`` can now be set to 1, for tables-only. This will
|
||||
output only the quantization and Huffman tables for the image.
|
||||
|
||||
Security
|
||||
========
|
||||
|
||||
ImageFont.getmask: Applied ImageFont.MAX_STRING_LENGTH
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
To protect against potential DOS attacks when using arbitrary strings as text input,
|
||||
Pillow will now raise a :py:exc:`ValueError` if the number of characters passed into
|
||||
:py:meth:`PIL.ImageFont.ImageFont.getmask` is over a certain limit,
|
||||
:py:data:`PIL.ImageFont.MAX_STRING_LENGTH`.
|
||||
|
||||
This threshold can be changed by setting :py:data:`PIL.ImageFont.MAX_STRING_LENGTH`. It
|
||||
can be disabled by setting ``ImageFont.MAX_STRING_LENGTH = None``.
|
||||
|
||||
A decompression bomb check has also been added to
|
||||
:py:meth:`PIL.ImageFont.ImageFont.getmask`.
|
||||
|
||||
ImageFont.getmask: Trim glyph size
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
To protect against potential DOS attacks when using PIL fonts,
|
||||
:py:class:`PIL.ImageFont.ImageFont` now trims the size of individual glyphs so that
|
||||
they do not extend beyond the bitmap image.
|
||||
|
||||
ImageMath.eval: Restricted environment keys
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
:cve:`2023-50447`: If an attacker has control over the keys passed to the
|
||||
``environment`` argument of :py:meth:`PIL.ImageMath.eval`, they may be able to execute
|
||||
arbitrary code. To prevent this, keys matching the names of builtins and keys
|
||||
containing double underscores will now raise a :py:exc:`ValueError`.
|
||||
|
||||
Other Changes
|
||||
=============
|
||||
|
||||
|
|
|
@ -1,6 +1,19 @@
|
|||
10.3.0
|
||||
------
|
||||
|
||||
Security
|
||||
========
|
||||
|
||||
TODO
|
||||
^^^^
|
||||
|
||||
TODO
|
||||
|
||||
:cve:`YYYY-XXXXX`: TODO
|
||||
^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
TODO
|
||||
|
||||
Backwards Incompatible Changes
|
||||
==============================
|
||||
|
||||
|
@ -63,14 +76,6 @@ Added PerspectiveTransform
|
|||
that all of the :py:data:`~PIL.Image.Transform` values now have a corresponding
|
||||
subclass of :py:class:`~PIL.ImageTransform.Transform`.
|
||||
|
||||
Security
|
||||
========
|
||||
|
||||
TODO
|
||||
^^^^
|
||||
|
||||
TODO
|
||||
|
||||
Other Changes
|
||||
=============
|
||||
|
||||
|
|
26
docs/releasenotes/2.3.1.rst
Normal file
|
@ -0,0 +1,26 @@
|
|||
2.3.1
|
||||
-----
|
||||
|
||||
Security
|
||||
========
|
||||
|
||||
These issues were reported in
|
||||
`Debian bug #737059 <https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=737059>`_.
|
||||
|
||||
:cve:`2014-1932`: Fix insecure use of :py:func:`tempfile.mktemp`
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
The (1) ``load_djpeg`` function in ``JpegImagePlugin.py``, (2) Ghostscript function
|
||||
in ``EpsImagePlugin.py``, (3) ``load`` function in ``IptcImagePlugin.py``, and (4)
|
||||
``_copy`` function in ``Image.py`` in
|
||||
Pillow before 2.3.1 do not properly create temporary files, which allow
|
||||
local users to overwrite arbitrary files and obtain sensitive information via a
|
||||
symlink attack on the temporary file.
|
||||
|
||||
:cve:`2014-1933`: Fix insecure use of :py:func:`tempfile.mktemp`
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
The (1) ``JpegImagePlugin.py`` and (2) ``EpsImagePlugin.py`` scripts in
|
||||
Pillow before 2.3.1 uses the names of
|
||||
temporary files on the command line, which makes it easier for local users to
|
||||
conduct symlink attacks by listing the processes.
|
14
docs/releasenotes/2.3.2.rst
Normal file
|
@ -0,0 +1,14 @@
|
|||
2.3.2
|
||||
-----
|
||||
|
||||
Security
|
||||
========
|
||||
|
||||
:cve:`2014-3589`: Fix DOS attack
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
``PIL/IcnsImagePlugin.py`` in Pillow before 2.3.2 and
|
||||
2.5.x before 2.5.2 allows remote attackers to cause a denial of service via a crafted
|
||||
block size.
|
||||
|
||||
Found and reported by Andrew Drake of `Dropbox <https://www.dropbox.com/>`__.
|
14
docs/releasenotes/2.5.2.rst
Normal file
|
@ -0,0 +1,14 @@
|
|||
2.5.2
|
||||
-----
|
||||
|
||||
Security
|
||||
========
|
||||
|
||||
:cve:`2014-3589`: Fix DOS attack
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
``PIL/IcnsImagePlugin.py`` in Pillow before 2.3.2 and
|
||||
2.5.x before 2.5.2 allows remote attackers to cause a denial of service via a crafted
|
||||
block size.
|
||||
|
||||
Found and reported by Andrew Drake of `Dropbox <https://www.dropbox.com/>`__.
|
14
docs/releasenotes/2.6.0.rst
Normal file
|
@ -0,0 +1,14 @@
|
|||
2.6.0
|
||||
-----
|
||||
|
||||
Security
|
||||
========
|
||||
|
||||
:cve:`2014-3589`: Fix DOS attack
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
``PIL/IcnsImagePlugin.py`` in Pillow before 2.3.2 and
|
||||
2.5.x before 2.5.2 allows remote attackers to cause a denial of service via a crafted
|
||||
block size.
|
||||
|
||||
Found and reported by Andrew Drake of `Dropbox <https://www.dropbox.com/>`__.
|
|
@ -1,15 +1,14 @@
|
|||
2.7.0
|
||||
=====
|
||||
-----
|
||||
|
||||
Sane Plugin
|
||||
-----------
|
||||
^^^^^^^^^^^
|
||||
|
||||
The Sane plugin has now been split into its own repo:
|
||||
https://github.com/python-pillow/Sane .
|
||||
|
||||
|
||||
Png text chunk size limits
|
||||
--------------------------
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
To prevent potential denial of service attacks using compressed text
|
||||
chunks, there are now limits to the decompressed size of text chunks
|
||||
|
@ -24,7 +23,7 @@ default. The total decompressed size of all text chunks is limited to
|
|||
know that there are large text blocks that are desired.
|
||||
|
||||
Image resizing filters
|
||||
----------------------
|
||||
^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Image resizing methods :py:meth:`~PIL.Image.Image.resize` and
|
||||
:py:meth:`~PIL.Image.Image.thumbnail` take a ``resample`` argument, which tells
|
||||
|
@ -33,7 +32,7 @@ which filter should be used for resampling. Possible values are:
|
|||
were changed in this version.
|
||||
|
||||
Bicubic and bilinear downscaling
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
++++++++++++++++++++++++++++++++
|
||||
|
||||
From the beginning ``BILINEAR`` and ``BICUBIC`` filters were based on affine
|
||||
transformations and used a fixed number of pixels from the source image for
|
||||
|
@ -50,7 +49,7 @@ If you have previously used any tricks to maintain quality when downscaling with
|
|||
steps), they are unnecessary now.
|
||||
|
||||
Antialias renamed to Lanczos
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
++++++++++++++++++++++++++++
|
||||
|
||||
A new ``LANCZOS`` constant was added instead of ``ANTIALIAS``.
|
||||
|
||||
|
@ -64,19 +63,19 @@ The ``ANTIALIAS`` constant is left for backward compatibility and is an alias
|
|||
for ``LANCZOS``.
|
||||
|
||||
Lanczos upscaling quality
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
+++++++++++++++++++++++++
|
||||
|
||||
The image upscaling quality with ``LANCZOS`` filter was almost the same as
|
||||
``BILINEAR`` due to a bug. This has been fixed.
|
||||
|
||||
Bicubic upscaling quality
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
+++++++++++++++++++++++++
|
||||
|
||||
The ``BICUBIC`` filter for affine transformations produced sharp, slightly
|
||||
pixelated image for upscaling. Bicubic for convolutions is more soft.
|
||||
|
||||
Resize performance
|
||||
^^^^^^^^^^^^^^^^^^
|
||||
++++++++++++++++++
|
||||
|
||||
In most cases, convolution is more a expensive algorithm for downscaling
|
||||
because it takes into account all the pixels of source image. Therefore
|
||||
|
@ -93,7 +92,7 @@ The upscaling performance of the ``LANCZOS`` filter has remained the same. For
|
|||
times.
|
||||
|
||||
Default filter for thumbnails
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
+++++++++++++++++++++++++++++
|
||||
|
||||
In Pillow 2.5 the default filter for :py:meth:`~PIL.Image.Image.thumbnail` was
|
||||
changed from ``NEAREST`` to ``ANTIALIAS``. Antialias was chosen because all the
|
||||
|
@ -103,7 +102,7 @@ other filters gave poor quality for reduction. Starting from Pillow 2.7.0,
|
|||
uses supersampling internally, not convolutions.
|
||||
|
||||
Image transposition
|
||||
-------------------
|
||||
+++++++++++++++++++
|
||||
|
||||
A new method ``TRANSPOSE`` has been added for the
|
||||
:py:meth:`~PIL.Image.Image.transpose` operation in addition to
|
||||
|
@ -115,7 +114,7 @@ The speed of ``ROTATE_90``, ``ROTATE_270`` and ``TRANSPOSE`` has been significan
|
|||
improved for large images which don't fit in the processor cache.
|
||||
|
||||
Gaussian blur and unsharp mask
|
||||
------------------------------
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
The :py:meth:`~PIL.ImageFilter.GaussianBlur` implementation has been replaced
|
||||
with a sequential application of box filters. The new implementation is based on
|
||||
|
@ -125,7 +124,7 @@ implementations use Gaussian blur internally, all changes from this chapter
|
|||
are also applicable to it.
|
||||
|
||||
Blur radius
|
||||
^^^^^^^^^^^
|
||||
+++++++++++
|
||||
|
||||
There was an error in the previous version of Pillow, where blur radius (the
|
||||
standard deviation of Gaussian) actually meant blur diameter. For example, to
|
||||
|
@ -136,7 +135,7 @@ If you used a Gaussian blur with some radius value, you need to divide this
|
|||
value by two.
|
||||
|
||||
Blur performance
|
||||
^^^^^^^^^^^^^^^^
|
||||
++++++++++++++++
|
||||
|
||||
Box filter computation time is constant relative to the radius and depends
|
||||
on source image size only. Because the new Gaussian blur implementation
|
||||
|
@ -148,7 +147,7 @@ second for radius 1, 3.6 seconds for radius 10 and 17 seconds for 50, now blur
|
|||
with any radius on same image is executed for 0.2 seconds.
|
||||
|
||||
Blur quality
|
||||
^^^^^^^^^^^^
|
||||
++++++++++++
|
||||
|
||||
The previous implementation takes into account only source pixels within
|
||||
2 * standard deviation radius for every destination pixel. This was not enough,
|
||||
|
@ -157,7 +156,7 @@ so the quality was worse compared to other Gaussian blur software.
|
|||
The new implementation does not have this drawback.
|
||||
|
||||
TIFF Parameter Changes
|
||||
----------------------
|
||||
^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Several kwarg parameters for saving TIFF images were previously
|
||||
specified as strings with included spaces (e.g. 'x resolution'). This
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
2.8.0
|
||||
=====
|
||||
-----
|
||||
|
||||
Open HTTP response objects with Image.open
|
||||
------------------------------------------
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
HTTP response objects returned from ``urllib2.urlopen(url)`` or
|
||||
``requests.get(url, stream=True).raw`` are 'file-like' but do not support ``.seek()``
|
||||
|
|
|
@ -1,9 +1,28 @@
|
|||
|
||||
3.0.0
|
||||
=====
|
||||
-----
|
||||
|
||||
Backwards Incompatible Changes
|
||||
==============================
|
||||
|
||||
Several methods that have been marked as deprecated for many releases
|
||||
have been removed in this release:
|
||||
|
||||
* ``Image.tostring()``
|
||||
* ``Image.fromstring()``
|
||||
* ``Image.offset()``
|
||||
* ``ImageDraw.setink()``
|
||||
* ``ImageDraw.setfill()``
|
||||
* The ``ImageFileIO`` module
|
||||
* The ``ImageFont.FreeTypeFont`` and ``ImageFont.truetype`` ``file`` keyword arg
|
||||
* The ``ImagePalette`` private ``_make`` functions
|
||||
* ``ImageWin.fromstring()``
|
||||
* ``ImageWin.tostring()``
|
||||
|
||||
Other Changes
|
||||
=============
|
||||
|
||||
Saving Multipage Images
|
||||
-----------------------
|
||||
^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
There is now support for saving multipage images in the ``GIF`` and
|
||||
``PDF`` formats. To enable this functionality, pass in ``save_all=True``
|
||||
|
@ -12,7 +31,7 @@ as a keyword argument to the save::
|
|||
im.save('test.pdf', save_all=True)
|
||||
|
||||
Tiff ImageFileDirectory Rewrite
|
||||
-------------------------------
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
The Tiff ImageFileDirectory metadata code has been rewritten. Where
|
||||
previously it returned a somewhat arbitrary set of values and tuples,
|
||||
|
@ -25,25 +44,8 @@ structures will be deprecated at some point in the future. When
|
|||
saving Tiff metadata, new code should use the
|
||||
TiffImagePlugin.ImageFileDirectory_v2 class.
|
||||
|
||||
Deprecated Methods
|
||||
------------------
|
||||
|
||||
Several methods that have been marked as deprecated for many releases
|
||||
have been removed in this release::
|
||||
|
||||
Image.tostring()
|
||||
Image.fromstring()
|
||||
Image.offset()
|
||||
ImageDraw.setink()
|
||||
ImageDraw.setfill()
|
||||
The ImageFileIO module
|
||||
The ImageFont.FreeTypeFont and ImageFont.truetype ``file`` keyword arg
|
||||
The ImagePalette private _make functions
|
||||
ImageWin.fromstring()
|
||||
ImageWin.tostring()
|
||||
|
||||
LibJpeg and Zlib are Required by Default
|
||||
----------------------------------------
|
||||
LibJpeg and Zlib are required by default
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
The external dependencies on libjpeg and zlib are now required by default.
|
||||
If the headers or libraries are not found, then installation will abort
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
|
||||
3.1.0
|
||||
=====
|
||||
-----
|
||||
|
||||
ImageDraw arc, chord and pieslice can now use floats
|
||||
----------------------------------------------------
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
There is no longer a need to ensure that the start and end arguments for ``arc``,
|
||||
``chord`` and ``pieslice`` are integers.
|
||||
|
@ -12,7 +11,7 @@ Note that these numbers are not simply rounded internally, but are actually
|
|||
utilised in the drawing process.
|
||||
|
||||
Consistent multiline text spacing
|
||||
---------------------------------
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
When using the ``ImageDraw`` multiline methods, the spacing between
|
||||
lines was inconsistent, based on the combination on ascenders and
|
||||
|
@ -24,7 +23,7 @@ not the absolute height of each line.
|
|||
There is also now a default spacing of 4px between lines.
|
||||
|
||||
Exif, Jpeg and Tiff Metadata
|
||||
----------------------------
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
There were major changes in the TIFF ImageFileDirectory support in
|
||||
Pillow 3.0 that led to a number of regressions. Some of them have been
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
|
||||
3.1.1
|
||||
=====
|
||||
-----
|
||||
|
||||
CVE-2016-0740 -- Buffer overflow in TiffDecode.c
|
||||
------------------------------------------------
|
||||
Security
|
||||
========
|
||||
|
||||
:cve:`2016-0740`: Buffer overflow in ``TiffDecode.c``
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Pillow 3.1.0 and earlier when linked against libtiff >= 4.0.0 on x64
|
||||
may overflow a buffer when reading a specially crafted tiff file (:cve:`2016-0740`).
|
||||
may overflow a buffer when reading a specially crafted tiff file.
|
||||
|
||||
Specifically, libtiff >= 4.0.0 changed the return type of
|
||||
``TIFFScanlineSize`` from ``int32`` to machine dependent
|
||||
|
@ -19,9 +21,8 @@ image data over 64k is written over the heap, causing a segfault.
|
|||
|
||||
This issue was found by security researcher FourOne.
|
||||
|
||||
|
||||
CVE-2016-0775 -- Buffer overflow in FliDecode.c
|
||||
-----------------------------------------------
|
||||
:cve:`2016-0775`: Buffer overflow in ``FliDecode.c``
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
In all versions of Pillow, dating back at least to the last PIL 1.1.7
|
||||
release, FliDecode.c has a buffer overflow error (:cve:`2016-0775`).
|
||||
|
@ -49,8 +50,8 @@ off the end of the memory buffer, causing a segfault.
|
|||
|
||||
This issue was found by Alyssa Besseling at Atlassian.
|
||||
|
||||
CVE-2016-2533 -- Buffer overflow in PcdDecode.c
|
||||
-----------------------------------------------
|
||||
:cve:`2016-2533`: Buffer overflow in ``PcdDecode.c``
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
In all versions of Pillow, dating back at least to the last PIL 1.1.7
|
||||
release, ``PcdDecode.c`` has a buffer overflow error (:cve:`2016-2533`).
|
||||
|
@ -61,8 +62,8 @@ assuming 4 bytes per pixel. This writes 768 bytes beyond the end of
|
|||
the buffer into other Python object storage. In some cases, this
|
||||
causes a segfault, in others an internal Python malloc error.
|
||||
|
||||
Integer overflow in Resample.c
|
||||
------------------------------
|
||||
Integer overflow in ``Resample.c``
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
If a large value was passed into the new size for an image, it is
|
||||
possible to overflow an ``int32`` value passed into malloc.
|
||||
|
|
|
@ -1,13 +1,15 @@
|
|||
|
||||
3.1.2
|
||||
=====
|
||||
-----
|
||||
|
||||
CVE-2016-3076 -- Buffer overflow in Jpeg2KEncode.c
|
||||
--------------------------------------------------
|
||||
Security
|
||||
========
|
||||
|
||||
Pillow between 2.5.0 and 3.1.1 may overflow a buffer when writing
|
||||
large Jpeg2000 files, allowing for code execution or other memory
|
||||
corruption (:cve:`2016-3076`).
|
||||
:cve:`2016-3076`: Buffer overflow in Jpeg2KEncode.c
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Pillow between 2.5.0 and 3.1.1 may overflow a buffer
|
||||
when writing large Jpeg2000 files, allowing for code execution or other
|
||||
memory corruption.
|
||||
|
||||
This occurs specifically in the function ``j2k_encode_entry``, at the line:
|
||||
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
|
||||
3.2.0
|
||||
-----
|
||||
|
||||
New DDS and FTEX Image Plugins
|
||||
==============================
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
The ``DdsImagePlugin`` reading DXT1 and DXT5 encoded ``.dds`` images was
|
||||
added. DXT3 images are not currently supported.
|
||||
|
@ -14,13 +13,13 @@ per file, in the ``.ftc`` (compressed) and ``.ftu`` (uncompressed)
|
|||
formats.
|
||||
|
||||
Updates to the GbrImagePlugin
|
||||
=============================
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
The ``GbrImagePlugin`` (GIMP brush format) has been updated to fix
|
||||
support for version 1 files and add support for version 2 files.
|
||||
|
||||
Passthrough Parameters for ImageDraw.text
|
||||
=========================================
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
``ImageDraw.multiline_text`` and ``ImageDraw.multiline_size`` take extra
|
||||
spacing parameters above what are used in ``ImageDraw.text`` and
|
||||
|
@ -29,7 +28,7 @@ spacing parameters above what are used in ``ImageDraw.text`` and
|
|||
to the corresponding multiline functions.
|
||||
|
||||
ImageSequence.Iterator changes
|
||||
==============================
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
``ImageSequence.Iterator`` is now an actual iterator implementing the
|
||||
Iterator protocol. It is also now possible to seek to the first image
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
-----
|
||||
|
||||
Libimagequant support
|
||||
=====================
|
||||
^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
There is now support for using libimagequant as a higher quality
|
||||
quantization option in ``Image.quantize()`` on Unix-like
|
||||
|
@ -12,21 +12,20 @@ differences.
|
|||
|
||||
|
||||
New Setup.py options
|
||||
====================
|
||||
^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
There are two new options to control the ``build_ext`` task in ``setup.py``:
|
||||
|
||||
* ``--debug`` dumps all of the directories and files that are
|
||||
checked when searching for libraries or headers when building the
|
||||
extensions.
|
||||
* ``--disable-platform-guessing`` removes many of the directories
|
||||
that are checked for libraries and headers for build systems or
|
||||
cross compilers that specify that information in via environment
|
||||
variables.
|
||||
|
||||
* ``--debug`` dumps all of the directories and files that are
|
||||
checked when searching for libraries or headers when building the
|
||||
extensions.
|
||||
* ``--disable-platform-guessing`` removes many of the directories
|
||||
that are checked for libraries and headers for build systems or
|
||||
cross compilers that specify that information in via environment
|
||||
variables.
|
||||
|
||||
Resizing
|
||||
========
|
||||
^^^^^^^^
|
||||
|
||||
Image resampling for 8-bit per channel images was rewritten using only integer
|
||||
computings. This is faster on most platforms and doesn't introduce precision
|
||||
|
@ -36,19 +35,17 @@ makes resampling 60% faster on average.
|
|||
Color calculation for images in the ``LA`` mode on semitransparent pixels
|
||||
was fixed.
|
||||
|
||||
|
||||
Rotation
|
||||
========
|
||||
^^^^^^^^
|
||||
|
||||
Rotation for angles divisible by 90 degrees now always uses transposition.
|
||||
This greatly improves both quality and performance in this case.
|
||||
Also, the bug with wrong image size calculation when rotating by 90 degrees
|
||||
was fixed.
|
||||
|
||||
|
||||
Image Metadata
|
||||
==============
|
||||
^^^^^^^^^^^^^^
|
||||
|
||||
The return type for binary data in version 2 Exif and Tiff metadata
|
||||
has been changed from a tuple of integers to bytes. This is a change
|
||||
from the behavior since ``3.0.0``.
|
||||
from the behavior since 3.0.0.
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
|
||||
3.3.2
|
||||
=====
|
||||
-----
|
||||
|
||||
Security
|
||||
========
|
||||
|
||||
Integer overflow in Map.c
|
||||
-------------------------
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Pillow prior to 3.3.2 may experience integer overflow errors in map.c
|
||||
when reading specially crafted image files. This may lead to memory
|
||||
|
@ -26,7 +28,7 @@ memory without duplicating the image first.
|
|||
This issue was found by Cris Neckar at Divergent Security.
|
||||
|
||||
Sign Extension in Storage.c
|
||||
---------------------------
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Pillow prior to 3.3.2 and PIL 1.1.7 (at least) do not check for
|
||||
negative image sizes in ``ImagingNew`` in ``Storage.c``. A negative
|
||||
|
|
|
@ -1,9 +1,32 @@
|
|||
|
||||
3.4.0
|
||||
-----
|
||||
|
||||
Backwards Incompatible Changes
|
||||
==============================
|
||||
|
||||
Image.core.open_ppm removed
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
The nominally private/debugging function ``Image.core.open_ppm`` has
|
||||
been removed. If you were using this function, please use
|
||||
``Image.open`` instead.
|
||||
|
||||
Deprecations
|
||||
============
|
||||
|
||||
Deprecation Warning when Saving JPEGs
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
JPEG images cannot contain an alpha channel. Pillow prior to 3.4.0
|
||||
silently drops the alpha channel. With this release Pillow will now
|
||||
issue a :py:exc:`DeprecationWarning` when attempting to save a ``RGBA`` mode
|
||||
image as a JPEG. This will become an error in Pillow 4.2.
|
||||
|
||||
API Additions
|
||||
=============
|
||||
|
||||
New resizing filters
|
||||
====================
|
||||
^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Two new filters available for ``Image.resize()`` and ``Image.thumbnail()``
|
||||
functions: ``BOX`` and ``HAMMING``. ``BOX`` is the high-performance filter with
|
||||
|
@ -14,23 +37,15 @@ two times shorter window than ``BILINEAR``. It can be used for image reduction
|
|||
providing the image downscaling quality comparable to ``BICUBIC``.
|
||||
Both new filters don't show good quality for the image upscaling.
|
||||
|
||||
Deprecation Warning when Saving JPEGs
|
||||
=====================================
|
||||
|
||||
JPEG images cannot contain an alpha channel. Pillow prior to 3.4.0
|
||||
silently drops the alpha channel. With this release Pillow will now
|
||||
issue a :py:exc:`DeprecationWarning` when attempting to save a ``RGBA`` mode
|
||||
image as a JPEG. This will become an error in Pillow 4.2.
|
||||
|
||||
New DDS Decoders
|
||||
================
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
Pillow can now decode DXT3 images, as well as the previously supported
|
||||
DXT1 and DXT5 formats. All three formats are now decoded in C code for
|
||||
better performance.
|
||||
|
||||
Append images to GIF
|
||||
====================
|
||||
^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Additional frames can now be appended when saving a GIF file, through the
|
||||
``append_images`` argument. The new frames are passed in as a list of images,
|
||||
|
@ -42,16 +57,9 @@ in effect, e.g.::
|
|||
im.save(out, save_all=True, append_images=[im1, im2, ...])
|
||||
|
||||
Save multiple frame TIFF
|
||||
========================
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Multiple frames can now be saved in a TIFF file by using the ``save_all`` option.
|
||||
e.g.::
|
||||
|
||||
im.save("filename.tiff", format="TIFF", save_all=True)
|
||||
|
||||
Image.core.open_ppm removed
|
||||
===========================
|
||||
|
||||
The nominally private/debugging function ``Image.core.open_ppm`` has
|
||||
been removed. If you were using this function, please use
|
||||
``Image.open`` instead.
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
-----
|
||||
|
||||
Python 2.6 and 3.2 Dropped
|
||||
==========================
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Pillow 4.0 no longer supports Python 2.6 and 3.2. We will not be
|
||||
creating binaries, testing, or retaining compatibility with these
|
||||
|
@ -10,12 +10,12 @@ releases. This release removes some workarounds for those Python
|
|||
releases, so the final working version of Pillow on 2.6 or 3.2 is 3.4.2.
|
||||
|
||||
Support added for Python 3.6
|
||||
============================
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Pillow 4.0 supports Python 3.6.
|
||||
|
||||
OleFileIO.py
|
||||
============
|
||||
^^^^^^^^^^^^
|
||||
|
||||
``OleFileIO.py`` has been removed as a vendored file and is now installed
|
||||
from the upstream :pypi:`olefile` PyPI package. All internal dependencies are
|
||||
|
@ -24,19 +24,19 @@ redirected to the olefile package. Direct accesses to
|
|||
upstream olefile into ``sys.modules`` in its place.
|
||||
|
||||
SGI image save
|
||||
==============
|
||||
^^^^^^^^^^^^^^
|
||||
|
||||
It is now possible to save images in modes ``L``, ``RGB``, and
|
||||
``RGBA`` to the uncompressed SGI image format.
|
||||
|
||||
Zero sized images
|
||||
=================
|
||||
^^^^^^^^^^^^^^^^^
|
||||
|
||||
Pillow 3.4.0 removed support for creating images with (0,0) size. This
|
||||
has been reenabled, restoring pre 3.4 behavior.
|
||||
|
||||
Internal handles_eof flag
|
||||
=========================
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
The ``handles_eof flag`` for decoding images has been removed, as there
|
||||
were no internal users of the flag. Anyone maintaining image decoders
|
||||
|
@ -44,7 +44,7 @@ outside of the Pillow source tree should consider using the cleanup
|
|||
function pointers instead.
|
||||
|
||||
Image.core.stretch removed
|
||||
==========================
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
The stretch function on the core image object has been removed. This
|
||||
used to be for enlarging the image, but has been aliased to resize
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
4.1.0
|
||||
-----
|
||||
|
||||
Removed Deprecated Items
|
||||
========================
|
||||
Deprecations
|
||||
============
|
||||
|
||||
Several deprecated items have been removed.
|
||||
|
||||
|
@ -15,8 +15,11 @@ Several deprecated items have been removed.
|
|||
``PIL.ImageDraw.ImageDraw.setfont`` have been removed.
|
||||
|
||||
|
||||
Other Changes
|
||||
=============
|
||||
|
||||
Closing Files When Opening Images
|
||||
=================================
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
The file handling when opening images has been overhauled. Previously,
|
||||
Pillow would attempt to close some, but not all image formats
|
||||
|
@ -38,9 +41,8 @@ is specified:
|
|||
the underlying file until we are done with the image. The mapping
|
||||
will be closed in the ``close`` or ``__del__`` method.
|
||||
|
||||
|
||||
Changes to GIF Handling When Saving
|
||||
===================================
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
The :py:class:`PIL.GifImagePlugin` code has been refactored to fix the flow when
|
||||
saving images. There are two external changes that arise from this:
|
||||
|
@ -56,14 +58,14 @@ This refactor fixed some bugs with palette handling when saving
|
|||
multiple frame GIFs.
|
||||
|
||||
New Method: Image.remap_palette
|
||||
===============================
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
The method :py:meth:`PIL.Image.Image.remap_palette()` has been
|
||||
added. This method was hoisted from the GifImagePlugin code used to
|
||||
optimize the palette.
|
||||
|
||||
Added Decoder Registry and Support for Python Based Decoders
|
||||
============================================================
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
There is now a decoder registry similar to the image plugin
|
||||
registries. Image plugins can register a decoder, and it will be
|
||||
|
@ -73,7 +75,7 @@ their C based counterparts, they may be easier and quicker to develop
|
|||
or safer to run.
|
||||
|
||||
Tests
|
||||
=====
|
||||
^^^^^
|
||||
|
||||
Many tests have been added, including correctness tests for image
|
||||
formats that have been previously untested.
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
-----
|
||||
|
||||
Fix Regression with reading DPI from EXIF data
|
||||
==============================================
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Some JPEG images don't contain DPI information in the image metadata,
|
||||
but do contain it in the EXIF data. A patch was added in 4.1.0 to read
|
||||
|
@ -10,9 +10,8 @@ from the EXIF data, but it did not accept all possible types that
|
|||
could be included there. This fix adds the ability to read ints as
|
||||
well as rational values.
|
||||
|
||||
|
||||
Incompatibility between 3.6.0 and 3.6.1
|
||||
=======================================
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
CPython 3.6.1 added a new symbol, PySlice_GetIndicesEx, which was not
|
||||
present in 3.6.0. This had the effect of causing binaries compiled on
|
||||
|
|
|
@ -1,37 +1,11 @@
|
|||
4.2.0
|
||||
-----
|
||||
|
||||
Added Complex Text Rendering
|
||||
============================
|
||||
Backwards Incompatible Changes
|
||||
==============================
|
||||
|
||||
Pillow now supports complex text rendering for scripts requiring glyph
|
||||
composition and bidirectional flow. This optional feature adds three
|
||||
dependencies: harfbuzz, fribidi, and raqm. See the :doc:`install documentation
|
||||
<../installation>` for further details. This feature is tested and works on
|
||||
Unix and Mac, but has not yet been built on Windows platforms.
|
||||
|
||||
New Optional Parameters
|
||||
=======================
|
||||
|
||||
* :py:meth:`PIL.ImageDraw.floodfill` has a new optional parameter:
|
||||
threshold. This specifies a tolerance for the color to replace with
|
||||
the flood fill.
|
||||
|
||||
* The TIFF and PDF image writers now support the ``append_images``
|
||||
optional parameter for specifying additional images to create
|
||||
multipage outputs.
|
||||
|
||||
New DecompressionBomb Warning
|
||||
=============================
|
||||
|
||||
:py:meth:`PIL.Image.Image.crop` now may raise a DecompressionBomb
|
||||
warning if the crop region enlarges the image over the threshold
|
||||
specified by :py:data:`PIL.Image.MAX_IMAGE_PIXELS`.
|
||||
|
||||
Removed Deprecated Items
|
||||
========================
|
||||
|
||||
Several deprecated items have been removed.
|
||||
Several deprecated items have been removed
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
* The methods ``PIL.ImageWin.Dib.fromstring``,
|
||||
``PIL.ImageWin.Dib.tostring`` and
|
||||
|
@ -44,8 +18,38 @@ Several deprecated items have been removed.
|
|||
an :py:exc:`IOError` is raised.
|
||||
|
||||
Removed Core Image Function
|
||||
===========================
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
The unused function ``Image.core.new_array`` was removed. This is an
|
||||
internal function that should not have been used by user code, but it
|
||||
was accessible from the python layer.
|
||||
|
||||
Other Changes
|
||||
=============
|
||||
|
||||
Added Complex Text Rendering
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Pillow now supports complex text rendering for scripts requiring glyph
|
||||
composition and bidirectional flow. This optional feature adds three
|
||||
dependencies: harfbuzz, fribidi, and raqm. See the :doc:`install documentation
|
||||
<../installation>` for further details. This feature is tested and works on
|
||||
Unix and Mac, but has not yet been built on Windows platforms.
|
||||
|
||||
New Optional Parameters
|
||||
^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
* :py:meth:`PIL.ImageDraw.floodfill` has a new optional parameter:
|
||||
threshold. This specifies a tolerance for the color to replace with
|
||||
the flood fill.
|
||||
|
||||
* The TIFF and PDF image writers now support the ``append_images``
|
||||
optional parameter for specifying additional images to create
|
||||
multipage outputs.
|
||||
|
||||
New DecompressionBomb Warning
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
:py:meth:`PIL.Image.Image.crop` now may raise a DecompressionBomb
|
||||
warning if the crop region enlarges the image over the threshold
|
||||
specified by :py:data:`PIL.Image.MAX_IMAGE_PIXELS`.
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
There are no functional changes in this release.
|
||||
|
||||
Fixed Windows PyPy Build
|
||||
========================
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
A change in the 4.2.0 cycle broke the Windows PyPy build. This has
|
||||
been fixed, and PyPy is now part of the Windows CI matrix.
|
||||
|
|
|
@ -1,15 +1,6 @@
|
|||
5.1.0
|
||||
-----
|
||||
|
||||
New File Format
|
||||
===============
|
||||
|
||||
BLP File Format
|
||||
^^^^^^^^^^^^^^^
|
||||
|
||||
Pillow now supports reading the BLP "Blizzard Mipmap" file format used
|
||||
for tiles in Blizzard's engine.
|
||||
|
||||
API Changes
|
||||
===========
|
||||
|
||||
|
@ -21,12 +12,21 @@ and ``CMYK`` with up to 6 8-bit channels, discarding any extra
|
|||
channels if the content is tagged as UNSPECIFIED. Pillow still does
|
||||
not store more than 4 8-bit channels of image data.
|
||||
|
||||
API Additions
|
||||
=============
|
||||
|
||||
Append to PDF Files
|
||||
^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Images can now be appended to PDF files in place by passing in
|
||||
``append=True`` when saving the image.
|
||||
|
||||
New BLP File Format
|
||||
^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Pillow now supports reading the BLP "Blizzard Mipmap" file format used
|
||||
for tiles in Blizzard's engine.
|
||||
|
||||
Other Changes
|
||||
=============
|
||||
|
||||
|
|
|
@ -1,6 +1,53 @@
|
|||
6.2.0
|
||||
-----
|
||||
|
||||
Security
|
||||
========
|
||||
|
||||
This release catches several buffer overruns and fixes :cve:`2019-16865`.
|
||||
|
||||
Buffer overruns
|
||||
^^^^^^^^^^^^^^^
|
||||
|
||||
In ``RawDecode.c``, an error is now thrown if skip is calculated to be less than
|
||||
zero. It is intended to skip padding between lines, not to go backwards.
|
||||
|
||||
In ``PsdImagePlugin``, if the combined sizes of the individual parts is larger than
|
||||
the declared size of the extra data field, then it looked for the next layer by
|
||||
seeking backwards. This is now corrected by seeking to (the start of the layer
|
||||
+ the size of the extra data field) instead of (the read parts of the layer +
|
||||
the rest of the layer).
|
||||
|
||||
Decompression bomb checks have been added to GIF and ICO formats.
|
||||
|
||||
An error is now raised if a TIFF dimension is a string, rather than trying to
|
||||
perform operations on it.
|
||||
|
||||
:cve:`2019-16865`: Fix DOS attack
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
The CVE is regarding DOS problems, such as consuming large amounts of memory,
|
||||
or taking a large amount of time to process an image.
|
||||
|
||||
API Changes
|
||||
===========
|
||||
|
||||
Image.getexif
|
||||
^^^^^^^^^^^^^
|
||||
|
||||
To allow for lazy loading of Exif data, ``Image.getexif()`` now returns a
|
||||
shared instance of ``Image.Exif``.
|
||||
|
||||
Deprecations
|
||||
^^^^^^^^^^^^
|
||||
|
||||
Image.frombuffer
|
||||
~~~~~~~~~~~~~~~~
|
||||
|
||||
There has been a longstanding warning that the defaults of ``Image.frombuffer``
|
||||
may change in the future for the "raw" decoder. The change will now take place
|
||||
in Pillow 7.0.
|
||||
|
||||
API Additions
|
||||
=============
|
||||
|
||||
|
@ -46,46 +93,6 @@ ImageGrab on multi-monitor Windows
|
|||
An ``all_screens`` argument has been added to ``ImageGrab.grab``. If ``True``,
|
||||
all monitors will be included in the created image.
|
||||
|
||||
API Changes
|
||||
===========
|
||||
|
||||
Image.getexif
|
||||
^^^^^^^^^^^^^
|
||||
|
||||
To allow for lazy loading of Exif data, ``Image.getexif()`` now returns a
|
||||
shared instance of ``Image.Exif``.
|
||||
|
||||
Deprecations
|
||||
^^^^^^^^^^^^
|
||||
|
||||
Image.frombuffer
|
||||
~~~~~~~~~~~~~~~~
|
||||
|
||||
There has been a longstanding warning that the defaults of ``Image.frombuffer``
|
||||
may change in the future for the "raw" decoder. The change will now take place
|
||||
in Pillow 7.0.
|
||||
|
||||
Security
|
||||
========
|
||||
|
||||
This release catches several buffer overruns, as well as addressing
|
||||
:cve:`2019-16865`. The CVE is regarding DOS problems, such as consuming large
|
||||
amounts of memory, or taking a large amount of time to process an image.
|
||||
|
||||
In RawDecode.c, an error is now thrown if skip is calculated to be less than
|
||||
zero. It is intended to skip padding between lines, not to go backwards.
|
||||
|
||||
In PsdImagePlugin, if the combined sizes of the individual parts is larger than
|
||||
the declared size of the extra data field, then it looked for the next layer by
|
||||
seeking backwards. This is now corrected by seeking to (the start of the layer
|
||||
+ the size of the extra data field) instead of (the read parts of the layer +
|
||||
the rest of the layer).
|
||||
|
||||
Decompression bomb checks have been added to GIF and ICO formats.
|
||||
|
||||
An error is now raised if a TIFF dimension is a string, rather than trying to
|
||||
perform operations on it.
|
||||
|
||||
Other Changes
|
||||
=============
|
||||
|
||||
|
|
|
@ -18,8 +18,6 @@ Pillow 7.0.0 will be released on 2020-01-01 and will drop support for Python
|
|||
Other Changes
|
||||
=============
|
||||
|
||||
|
||||
|
||||
Support added for Python 3.8
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
|
|
|
@ -4,15 +4,17 @@
|
|||
Security
|
||||
========
|
||||
|
||||
This release addresses several security problems.
|
||||
This release fixes several buffer overflow issues and a DOS attack vulnerability.
|
||||
|
||||
:cve:`2019-19911` is regarding FPX images. If an image reports that it has a large
|
||||
number of bands, a large amount of resources will be used when trying to process the
|
||||
image. This is fixed by limiting the number of bands to those usable by Pillow.
|
||||
:cve:`2020-5310`, :cve:`2020-5311`, :cve:`2020-5312`, :cve:`2020-5313`: Overflow checks added
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Buffer overruns were found when processing an SGI (:cve:`2020-5311`),
|
||||
PCX (:cve:`2020-5312`) or FLI image (:cve:`2020-5313`). Checks have been added
|
||||
to prevent this.
|
||||
Overflow checks have been added when calculating the size of a memory block to be reallocated
|
||||
in the processing of TIFF, SGI, PCX and FLI images.
|
||||
|
||||
:cve:`2020-5310`: Overflow checks have been added when calculating the size of a
|
||||
memory block to be reallocated in the processing of a TIFF image.
|
||||
:cve:`2019-19911`: DOS attack vulnerability
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
If an FPX image reports that it has a large number of bands, a large amount of
|
||||
resources will be used when trying to process the image. This is fixed by
|
||||
limiting the number of bands to those usable by Pillow.
|
||||
|
|
|
@ -1,6 +1,40 @@
|
|||
7.1.0
|
||||
-----
|
||||
|
||||
Security
|
||||
========
|
||||
|
||||
This release includes many security fixes.
|
||||
|
||||
:cve:`2020-10177`: Multiple out-of-bounds reads in FLI decoding
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Pillow before 7.1.0 has multiple out-of-bounds reads in ``libImaging/FliDecode.c``.
|
||||
|
||||
:cve:`2020-10378`: Bounds overflow in PCX decoding
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
In ``libImaging/PcxDecode.c`` in Pillow before 7.1.0, an out-of-bounds read can occur
|
||||
when reading PCX files where ``state->shuffle`` is instructed to read beyond
|
||||
``state->buffer``.
|
||||
|
||||
:cve:`2020-10379`: Two buffer overflows in TIFF decoding
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
In Pillow before 7.1.0, there are two buffer overflows in ``libImaging/TiffDecode.c``.
|
||||
|
||||
:cve:`2020-10994`: Bounds overflow in JPEG 2000 decoding
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
In ``libImaging/Jpeg2KDecode.c`` in Pillow before 7.1.0, there are multiple
|
||||
out-of-bounds reads via a crafted JP2 file.
|
||||
|
||||
:cve:`2020-11538`: Buffer overflow in SGI-RLE decoding
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
In ``libImaging/SgiRleDecode.c`` in Pillow through 7.0.0, a number of out-of-bounds
|
||||
reads exist in the parsing of SGI image files, a different issue than :cve:`2020-5311`.
|
||||
|
||||
API Changes
|
||||
===========
|
||||
|
||||
|
@ -67,17 +101,6 @@ Passing a different value on Windows or macOS will force taking a snapshot
|
|||
using the selected X server; pass an empty string to use the default X server.
|
||||
XCB support is not included in pre-compiled wheels for Windows and macOS.
|
||||
|
||||
Security
|
||||
========
|
||||
|
||||
This release includes security fixes.
|
||||
|
||||
* :cve:`2020-10177` Fix multiple out-of-bounds reads in FLI decoding
|
||||
* :cve:`2020-10378` Fix bounds overflow in PCX decoding
|
||||
* :cve:`2020-10379` Fix two buffer overflows in TIFF decoding
|
||||
* :cve:`2020-10994` Fix bounds overflow in JPEG 2000 decoding
|
||||
* :cve:`2020-11538` Fix buffer overflow in SGI-RLE decoding
|
||||
|
||||
Other Changes
|
||||
=============
|
||||
|
||||
|
|