Merge branch 'main' into context_manager
|
@ -18,7 +18,7 @@ environment:
|
||||||
TEST_OPTIONS:
|
TEST_OPTIONS:
|
||||||
DEPLOY: YES
|
DEPLOY: YES
|
||||||
matrix:
|
matrix:
|
||||||
- PYTHON: C:/Python312
|
- PYTHON: C:/Python313
|
||||||
ARCHITECTURE: x86
|
ARCHITECTURE: x86
|
||||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2022
|
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2022
|
||||||
- PYTHON: C:/Python39-x64
|
- PYTHON: C:/Python39-x64
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
cibuildwheel==2.21.1
|
cibuildwheel==2.21.2
|
||||||
|
|
4
.github/workflows/cifuzz.yml
vendored
|
@ -6,11 +6,13 @@ on:
|
||||||
- "**"
|
- "**"
|
||||||
paths:
|
paths:
|
||||||
- ".github/workflows/cifuzz.yml"
|
- ".github/workflows/cifuzz.yml"
|
||||||
|
- ".github/workflows/wheels-dependencies.sh"
|
||||||
- "**.c"
|
- "**.c"
|
||||||
- "**.h"
|
- "**.h"
|
||||||
pull_request:
|
pull_request:
|
||||||
paths:
|
paths:
|
||||||
- ".github/workflows/cifuzz.yml"
|
- ".github/workflows/cifuzz.yml"
|
||||||
|
- ".github/workflows/wheels-dependencies.sh"
|
||||||
- "**.c"
|
- "**.c"
|
||||||
- "**.h"
|
- "**.h"
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
@ -24,8 +26,6 @@ concurrency:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
Fuzzing:
|
Fuzzing:
|
||||||
# Disabled until google/oss-fuzz#11419 upgrades Python to 3.9+
|
|
||||||
if: false
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Build Fuzzers
|
- name: Build Fuzzers
|
||||||
|
|
40
.github/workflows/wheels-dependencies.sh
vendored
|
@ -16,15 +16,11 @@ ARCHIVE_SDIR=pillow-depends-main
|
||||||
|
|
||||||
# Package versions for fresh source builds
|
# Package versions for fresh source builds
|
||||||
FREETYPE_VERSION=2.13.2
|
FREETYPE_VERSION=2.13.2
|
||||||
if [[ "$MB_ML_VER" != 2014 ]]; then
|
HARFBUZZ_VERSION=10.0.1
|
||||||
HARFBUZZ_VERSION=10.0.1
|
|
||||||
else
|
|
||||||
HARFBUZZ_VERSION=8.5.0
|
|
||||||
fi
|
|
||||||
LIBPNG_VERSION=1.6.44
|
LIBPNG_VERSION=1.6.44
|
||||||
JPEGTURBO_VERSION=3.0.4
|
JPEGTURBO_VERSION=3.0.4
|
||||||
OPENJPEG_VERSION=2.5.2
|
OPENJPEG_VERSION=2.5.2
|
||||||
XZ_VERSION=5.6.2
|
XZ_VERSION=5.6.3
|
||||||
TIFF_VERSION=4.6.0
|
TIFF_VERSION=4.6.0
|
||||||
LCMS2_VERSION=2.16
|
LCMS2_VERSION=2.16
|
||||||
if [[ -n "$IS_MACOS" ]]; then
|
if [[ -n "$IS_MACOS" ]]; then
|
||||||
|
@ -65,21 +61,15 @@ function build_brotli {
|
||||||
}
|
}
|
||||||
|
|
||||||
function build_harfbuzz {
|
function build_harfbuzz {
|
||||||
if [[ "$HARFBUZZ_VERSION" == 8.5.0 ]]; then
|
python3 -m pip install meson ninja
|
||||||
export FREETYPE_LIBS=-lfreetype
|
|
||||||
export FREETYPE_CFLAGS=-I/usr/local/include/freetype2/
|
local out_dir=$(fetch_unpack https://github.com/harfbuzz/harfbuzz/releases/download/$HARFBUZZ_VERSION/$HARFBUZZ_VERSION.tar.xz harfbuzz-$HARFBUZZ_VERSION.tar.xz)
|
||||||
build_simple harfbuzz $HARFBUZZ_VERSION https://github.com/harfbuzz/harfbuzz/releases/download/$HARFBUZZ_VERSION tar.xz --with-freetype=yes --with-glib=no
|
(cd $out_dir \
|
||||||
export FREETYPE_LIBS=""
|
&& meson setup build --buildtype=release -Dfreetype=enabled -Dglib=disabled)
|
||||||
export FREETYPE_CFLAGS=""
|
(cd $out_dir/build \
|
||||||
else
|
&& meson install)
|
||||||
local out_dir=$(fetch_unpack https://github.com/harfbuzz/harfbuzz/releases/download/$HARFBUZZ_VERSION/$HARFBUZZ_VERSION.tar.xz harfbuzz-$HARFBUZZ_VERSION.tar.xz)
|
if [[ "$MB_ML_LIBC" == "manylinux" ]]; then
|
||||||
(cd $out_dir \
|
cp /usr/local/lib64/libharfbuzz* /usr/local/lib
|
||||||
&& meson setup build --buildtype=release -Dfreetype=enabled -Dglib=disabled)
|
|
||||||
(cd $out_dir/build \
|
|
||||||
&& meson install)
|
|
||||||
if [[ "$MB_ML_LIBC" == "manylinux" ]]; then
|
|
||||||
cp /usr/local/lib64/libharfbuzz* /usr/local/lib
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,13 +145,7 @@ if [[ -n "$IS_MACOS" ]]; then
|
||||||
brew remove --ignore-dependencies webp
|
brew remove --ignore-dependencies webp
|
||||||
fi
|
fi
|
||||||
|
|
||||||
brew install meson pkg-config
|
brew install pkg-config
|
||||||
elif [[ "$MB_ML_LIBC" == "manylinux" ]]; then
|
|
||||||
if [[ "$HARFBUZZ_VERSION" != 8.5.0 ]]; then
|
|
||||||
yum install -y meson
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
apk add meson
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
wrap_wheel_builder build
|
wrap_wheel_builder build
|
||||||
|
|
4
.github/workflows/wheels.yml
vendored
|
@ -278,7 +278,7 @@ jobs:
|
||||||
path: dist
|
path: dist
|
||||||
merge-multiple: true
|
merge-multiple: true
|
||||||
- name: Upload wheels to scientific-python-nightly-wheels
|
- name: Upload wheels to scientific-python-nightly-wheels
|
||||||
uses: scientific-python/upload-nightly-action@b67d7fcc0396e1128a474d1ab2b48aa94680f9fc # 0.5.0
|
uses: scientific-python/upload-nightly-action@82396a2ed4269ba06c6b2988bb4fd568ef3c3d6b # 0.6.1
|
||||||
with:
|
with:
|
||||||
artifacts_path: dist
|
artifacts_path: dist
|
||||||
anaconda_nightly_upload_token: ${{ secrets.ANACONDA_ORG_UPLOAD_TOKEN }}
|
anaconda_nightly_upload_token: ${{ secrets.ANACONDA_ORG_UPLOAD_TOKEN }}
|
||||||
|
@ -301,3 +301,5 @@ jobs:
|
||||||
merge-multiple: true
|
merge-multiple: true
|
||||||
- name: Publish to PyPI
|
- name: Publish to PyPI
|
||||||
uses: pypa/gh-action-pypi-publish@release/v1
|
uses: pypa/gh-action-pypi-publish@release/v1
|
||||||
|
with:
|
||||||
|
attestations: true
|
||||||
|
|
25
CHANGES.rst
|
@ -5,12 +5,33 @@ Changelog (Pillow)
|
||||||
11.0.0 (unreleased)
|
11.0.0 (unreleased)
|
||||||
-------------------
|
-------------------
|
||||||
|
|
||||||
- Fixed writing multiple StripOffsets to TIFF #8317
|
- Updated EPS mode when opening images without transparency #8281
|
||||||
[Yay295, radarhere]
|
[Yay295, radarhere]
|
||||||
|
|
||||||
- Shared imagequant libraries may be located within usr/lib64 #8407
|
- Use transparency when combining P frames from APNGs #8443
|
||||||
[radarhere]
|
[radarhere]
|
||||||
|
|
||||||
|
- Support all resampling filters when resizing I;16* images #8422
|
||||||
|
[radarhere]
|
||||||
|
|
||||||
|
- Free memory on early return #8413
|
||||||
|
[radarhere]
|
||||||
|
|
||||||
|
- Cast int before potentially exceeding INT_MAX #8402
|
||||||
|
[radarhere]
|
||||||
|
|
||||||
|
- Check image value before use #8400
|
||||||
|
[radarhere]
|
||||||
|
|
||||||
|
- Improved copying imagequant libraries #8420
|
||||||
|
[radarhere]
|
||||||
|
|
||||||
|
- Use Capsule for WebP saving #8386
|
||||||
|
[homm, radarhere]
|
||||||
|
|
||||||
|
- Fixed writing multiple StripOffsets to TIFF #8317
|
||||||
|
[Yay295, radarhere]
|
||||||
|
|
||||||
- Fix dereference before checking for NULL in ImagingTransformAffine #8398
|
- Fix dereference before checking for NULL in ImagingTransformAffine #8398
|
||||||
[PavlNekrasov]
|
[PavlNekrasov]
|
||||||
|
|
||||||
|
|
2
Makefile
|
@ -117,7 +117,7 @@ lint-fix:
|
||||||
python3 -c "import black" > /dev/null 2>&1 || python3 -m pip install black
|
python3 -c "import black" > /dev/null 2>&1 || python3 -m pip install black
|
||||||
python3 -m black .
|
python3 -m black .
|
||||||
python3 -c "import ruff" > /dev/null 2>&1 || python3 -m pip install ruff
|
python3 -c "import ruff" > /dev/null 2>&1 || python3 -m pip install ruff
|
||||||
python3 -m ruff --fix .
|
python3 -m ruff check --fix .
|
||||||
|
|
||||||
.PHONY: mypy
|
.PHONY: mypy
|
||||||
mypy:
|
mypy:
|
||||||
|
|
BIN
Tests/images/eps/1.bmp
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
Tests/images/eps/1_boundingbox_after_imagedata.eps
Normal file
BIN
Tests/images/eps/1_second_imagedata.eps
Normal file
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 2.5 KiB |
Before Width: | Height: | Size: 5.4 KiB After Width: | Height: | Size: 5.4 KiB |
Before Width: | Height: | Size: 5.9 KiB After Width: | Height: | Size: 5.9 KiB |
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 17 KiB |
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.7 KiB |
Before Width: | Height: | Size: 5.8 KiB After Width: | Height: | Size: 5.8 KiB |
|
@ -283,8 +283,8 @@ def test_apng_mode() -> None:
|
||||||
assert im.mode == "P"
|
assert im.mode == "P"
|
||||||
im.seek(im.n_frames - 1)
|
im.seek(im.n_frames - 1)
|
||||||
rgb_im = im.convert("RGBA")
|
rgb_im = im.convert("RGBA")
|
||||||
assert rgb_im.getpixel((0, 0)) == (255, 0, 0, 0)
|
assert rgb_im.getpixel((0, 0)) == (0, 255, 0, 255)
|
||||||
assert rgb_im.getpixel((64, 32)) == (255, 0, 0, 0)
|
assert rgb_im.getpixel((64, 32)) == (0, 255, 0, 255)
|
||||||
|
|
||||||
with Image.open("Tests/images/apng/mode_palette_1bit_alpha.png") as im:
|
with Image.open("Tests/images/apng/mode_palette_1bit_alpha.png") as im:
|
||||||
assert isinstance(im, PngImagePlugin.PngImageFile)
|
assert isinstance(im, PngImagePlugin.PngImageFile)
|
||||||
|
|
|
@ -8,6 +8,7 @@ import pytest
|
||||||
from PIL import EpsImagePlugin, Image, UnidentifiedImageError, features
|
from PIL import EpsImagePlugin, Image, UnidentifiedImageError, features
|
||||||
|
|
||||||
from .helper import (
|
from .helper import (
|
||||||
|
assert_image_equal_tofile,
|
||||||
assert_image_similar,
|
assert_image_similar,
|
||||||
assert_image_similar_tofile,
|
assert_image_similar_tofile,
|
||||||
hopper,
|
hopper,
|
||||||
|
@ -19,18 +20,18 @@ from .helper import (
|
||||||
HAS_GHOSTSCRIPT = EpsImagePlugin.has_ghostscript()
|
HAS_GHOSTSCRIPT = EpsImagePlugin.has_ghostscript()
|
||||||
|
|
||||||
# Our two EPS test files (they are identical except for their bounding boxes)
|
# Our two EPS test files (they are identical except for their bounding boxes)
|
||||||
FILE1 = "Tests/images/zero_bb.eps"
|
FILE1 = "Tests/images/eps/zero_bb.eps"
|
||||||
FILE2 = "Tests/images/non_zero_bb.eps"
|
FILE2 = "Tests/images/eps/non_zero_bb.eps"
|
||||||
|
|
||||||
# Due to palletization, we'll need to convert these to RGB after load
|
# Due to palletization, we'll need to convert these to RGB after load
|
||||||
FILE1_COMPARE = "Tests/images/zero_bb.png"
|
FILE1_COMPARE = "Tests/images/eps/zero_bb.png"
|
||||||
FILE1_COMPARE_SCALE2 = "Tests/images/zero_bb_scale2.png"
|
FILE1_COMPARE_SCALE2 = "Tests/images/eps/zero_bb_scale2.png"
|
||||||
|
|
||||||
FILE2_COMPARE = "Tests/images/non_zero_bb.png"
|
FILE2_COMPARE = "Tests/images/eps/non_zero_bb.png"
|
||||||
FILE2_COMPARE_SCALE2 = "Tests/images/non_zero_bb_scale2.png"
|
FILE2_COMPARE_SCALE2 = "Tests/images/eps/non_zero_bb_scale2.png"
|
||||||
|
|
||||||
# EPS test files with binary preview
|
# EPS test files with binary preview
|
||||||
FILE3 = "Tests/images/binary_preview_map.eps"
|
FILE3 = "Tests/images/eps/binary_preview_map.eps"
|
||||||
|
|
||||||
# Three unsigned 32bit little-endian values:
|
# Three unsigned 32bit little-endian values:
|
||||||
# 0xC6D3D0C5 magic number
|
# 0xC6D3D0C5 magic number
|
||||||
|
@ -130,6 +131,15 @@ def test_binary_header_only() -> None:
|
||||||
EpsImagePlugin.EpsImageFile(data)
|
EpsImagePlugin.EpsImageFile(data)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize("prefix", (b"", simple_binary_header))
|
||||||
|
def test_simple_eps_file(prefix: bytes) -> None:
|
||||||
|
data = io.BytesIO(prefix + b"\n".join(simple_eps_file))
|
||||||
|
with Image.open(data) as img:
|
||||||
|
assert img.mode == "RGB"
|
||||||
|
assert img.size == (100, 100)
|
||||||
|
assert img.format == "EPS"
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("prefix", (b"", simple_binary_header))
|
@pytest.mark.parametrize("prefix", (b"", simple_binary_header))
|
||||||
def test_missing_version_comment(prefix: bytes) -> None:
|
def test_missing_version_comment(prefix: bytes) -> None:
|
||||||
data = io.BytesIO(prefix + b"\n".join(simple_eps_file_without_version))
|
data = io.BytesIO(prefix + b"\n".join(simple_eps_file_without_version))
|
||||||
|
@ -145,23 +155,21 @@ def test_missing_boundingbox_comment(prefix: bytes) -> None:
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("prefix", (b"", simple_binary_header))
|
@pytest.mark.parametrize("prefix", (b"", simple_binary_header))
|
||||||
def test_invalid_boundingbox_comment(prefix: bytes) -> None:
|
@pytest.mark.parametrize(
|
||||||
data = io.BytesIO(prefix + b"\n".join(simple_eps_file_with_invalid_boundingbox))
|
"file_lines",
|
||||||
|
(
|
||||||
|
simple_eps_file_with_invalid_boundingbox,
|
||||||
|
simple_eps_file_with_invalid_boundingbox_valid_imagedata,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
def test_invalid_boundingbox_comment(
|
||||||
|
prefix: bytes, file_lines: tuple[bytes, ...]
|
||||||
|
) -> None:
|
||||||
|
data = io.BytesIO(prefix + b"\n".join(file_lines))
|
||||||
with pytest.raises(OSError, match="cannot determine EPS bounding box"):
|
with pytest.raises(OSError, match="cannot determine EPS bounding box"):
|
||||||
EpsImagePlugin.EpsImageFile(data)
|
EpsImagePlugin.EpsImageFile(data)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("prefix", (b"", simple_binary_header))
|
|
||||||
def test_invalid_boundingbox_comment_valid_imagedata_comment(prefix: bytes) -> None:
|
|
||||||
data = io.BytesIO(
|
|
||||||
prefix + b"\n".join(simple_eps_file_with_invalid_boundingbox_valid_imagedata)
|
|
||||||
)
|
|
||||||
with Image.open(data) as img:
|
|
||||||
assert img.mode == "RGB"
|
|
||||||
assert img.size == (100, 100)
|
|
||||||
assert img.format == "EPS"
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("prefix", (b"", simple_binary_header))
|
@pytest.mark.parametrize("prefix", (b"", simple_binary_header))
|
||||||
def test_ascii_comment_too_long(prefix: bytes) -> None:
|
def test_ascii_comment_too_long(prefix: bytes) -> None:
|
||||||
data = io.BytesIO(prefix + b"\n".join(simple_eps_file_with_long_ascii_comment))
|
data = io.BytesIO(prefix + b"\n".join(simple_eps_file_with_long_ascii_comment))
|
||||||
|
@ -181,7 +189,7 @@ def test_load_long_binary_data(prefix: bytes) -> None:
|
||||||
data = io.BytesIO(prefix + b"\n".join(simple_eps_file_with_long_binary_data))
|
data = io.BytesIO(prefix + b"\n".join(simple_eps_file_with_long_binary_data))
|
||||||
with Image.open(data) as img:
|
with Image.open(data) as img:
|
||||||
img.load()
|
img.load()
|
||||||
assert img.mode == "RGB"
|
assert img.mode == "1"
|
||||||
assert img.size == (100, 100)
|
assert img.size == (100, 100)
|
||||||
assert img.format == "EPS"
|
assert img.format == "EPS"
|
||||||
|
|
||||||
|
@ -191,7 +199,7 @@ def test_load_long_binary_data(prefix: bytes) -> None:
|
||||||
)
|
)
|
||||||
@pytest.mark.skipif(not HAS_GHOSTSCRIPT, reason="Ghostscript not available")
|
@pytest.mark.skipif(not HAS_GHOSTSCRIPT, reason="Ghostscript not available")
|
||||||
def test_cmyk() -> None:
|
def test_cmyk() -> None:
|
||||||
with Image.open("Tests/images/pil_sample_cmyk.eps") as cmyk_image:
|
with Image.open("Tests/images/eps/pil_sample_cmyk.eps") as cmyk_image:
|
||||||
assert cmyk_image.mode == "CMYK"
|
assert cmyk_image.mode == "CMYK"
|
||||||
assert cmyk_image.size == (100, 100)
|
assert cmyk_image.size == (100, 100)
|
||||||
assert cmyk_image.format == "EPS"
|
assert cmyk_image.format == "EPS"
|
||||||
|
@ -208,8 +216,8 @@ def test_cmyk() -> None:
|
||||||
@pytest.mark.skipif(not HAS_GHOSTSCRIPT, reason="Ghostscript not available")
|
@pytest.mark.skipif(not HAS_GHOSTSCRIPT, reason="Ghostscript not available")
|
||||||
def test_showpage() -> None:
|
def test_showpage() -> None:
|
||||||
# See https://github.com/python-pillow/Pillow/issues/2615
|
# See https://github.com/python-pillow/Pillow/issues/2615
|
||||||
with Image.open("Tests/images/reqd_showpage.eps") as plot_image:
|
with Image.open("Tests/images/eps/reqd_showpage.eps") as plot_image:
|
||||||
with Image.open("Tests/images/reqd_showpage.png") as target:
|
with Image.open("Tests/images/eps/reqd_showpage.png") as target:
|
||||||
# should not crash/hang
|
# should not crash/hang
|
||||||
plot_image.load()
|
plot_image.load()
|
||||||
# fonts could be slightly different
|
# fonts could be slightly different
|
||||||
|
@ -218,13 +226,13 @@ def test_showpage() -> None:
|
||||||
|
|
||||||
@pytest.mark.skipif(not HAS_GHOSTSCRIPT, reason="Ghostscript not available")
|
@pytest.mark.skipif(not HAS_GHOSTSCRIPT, reason="Ghostscript not available")
|
||||||
def test_transparency() -> None:
|
def test_transparency() -> None:
|
||||||
with Image.open("Tests/images/reqd_showpage.eps") as plot_image:
|
with Image.open("Tests/images/eps/reqd_showpage.eps") as plot_image:
|
||||||
assert isinstance(plot_image, EpsImagePlugin.EpsImageFile)
|
assert isinstance(plot_image, EpsImagePlugin.EpsImageFile)
|
||||||
|
|
||||||
plot_image.load(transparency=True)
|
plot_image.load(transparency=True)
|
||||||
assert plot_image.mode == "RGBA"
|
assert plot_image.mode == "RGBA"
|
||||||
|
|
||||||
with Image.open("Tests/images/reqd_showpage_transparency.png") as target:
|
with Image.open("Tests/images/eps/reqd_showpage_transparency.png") as target:
|
||||||
# fonts could be slightly different
|
# fonts could be slightly different
|
||||||
assert_image_similar(plot_image, target, 6)
|
assert_image_similar(plot_image, target, 6)
|
||||||
|
|
||||||
|
@ -251,9 +259,19 @@ def test_bytesio_object() -> None:
|
||||||
assert_image_similar(img, image1_scale1_compare, 5)
|
assert_image_similar(img, image1_scale1_compare, 5)
|
||||||
|
|
||||||
|
|
||||||
def test_1_mode() -> None:
|
@pytest.mark.skipif(not HAS_GHOSTSCRIPT, reason="Ghostscript not available")
|
||||||
with Image.open("Tests/images/1.eps") as im:
|
@pytest.mark.parametrize(
|
||||||
assert im.mode == "1"
|
# These images have an "ImageData" descriptor.
|
||||||
|
"filename",
|
||||||
|
(
|
||||||
|
"Tests/images/eps/1.eps",
|
||||||
|
"Tests/images/eps/1_boundingbox_after_imagedata.eps",
|
||||||
|
"Tests/images/eps/1_second_imagedata.eps",
|
||||||
|
),
|
||||||
|
)
|
||||||
|
def test_1(filename: str) -> None:
|
||||||
|
with Image.open(filename) as im:
|
||||||
|
assert_image_equal_tofile(im, "Tests/images/eps/1.bmp")
|
||||||
|
|
||||||
|
|
||||||
def test_image_mode_not_supported(tmp_path: Path) -> None:
|
def test_image_mode_not_supported(tmp_path: Path) -> None:
|
||||||
|
@ -310,7 +328,9 @@ def test_render_scale2() -> None:
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.skipif(not HAS_GHOSTSCRIPT, reason="Ghostscript not available")
|
@pytest.mark.skipif(not HAS_GHOSTSCRIPT, reason="Ghostscript not available")
|
||||||
@pytest.mark.parametrize("filename", (FILE1, FILE2, "Tests/images/illu10_preview.eps"))
|
@pytest.mark.parametrize(
|
||||||
|
"filename", (FILE1, FILE2, "Tests/images/eps/illu10_preview.eps")
|
||||||
|
)
|
||||||
def test_resize(filename: str) -> None:
|
def test_resize(filename: str) -> None:
|
||||||
with Image.open(filename) as img:
|
with Image.open(filename) as img:
|
||||||
new_size = (100, 100)
|
new_size = (100, 100)
|
||||||
|
@ -352,10 +372,10 @@ def test_readline(prefix: bytes, line_ending: bytes) -> None:
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
"filename",
|
"filename",
|
||||||
(
|
(
|
||||||
"Tests/images/illu10_no_preview.eps",
|
"Tests/images/eps/illu10_no_preview.eps",
|
||||||
"Tests/images/illu10_preview.eps",
|
"Tests/images/eps/illu10_preview.eps",
|
||||||
"Tests/images/illuCS6_no_preview.eps",
|
"Tests/images/eps/illuCS6_no_preview.eps",
|
||||||
"Tests/images/illuCS6_preview.eps",
|
"Tests/images/eps/illuCS6_preview.eps",
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
def test_open_eps(filename: str) -> None:
|
def test_open_eps(filename: str) -> None:
|
||||||
|
@ -367,7 +387,7 @@ def test_open_eps(filename: str) -> None:
|
||||||
@pytest.mark.skipif(not HAS_GHOSTSCRIPT, reason="Ghostscript not available")
|
@pytest.mark.skipif(not HAS_GHOSTSCRIPT, reason="Ghostscript not available")
|
||||||
def test_emptyline() -> None:
|
def test_emptyline() -> None:
|
||||||
# Test file includes an empty line in the header data
|
# Test file includes an empty line in the header data
|
||||||
emptyline_file = "Tests/images/zero_bb_emptyline.eps"
|
emptyline_file = "Tests/images/eps/zero_bb_emptyline.eps"
|
||||||
|
|
||||||
with Image.open(emptyline_file) as image:
|
with Image.open(emptyline_file) as image:
|
||||||
image.load()
|
image.load()
|
||||||
|
@ -379,7 +399,7 @@ def test_emptyline() -> None:
|
||||||
@pytest.mark.timeout(timeout=5)
|
@pytest.mark.timeout(timeout=5)
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
"test_file",
|
"test_file",
|
||||||
["Tests/images/timeout-d675703545fee17acab56e5fec644c19979175de.eps"],
|
["Tests/images/eps/timeout-d675703545fee17acab56e5fec644c19979175de.eps"],
|
||||||
)
|
)
|
||||||
def test_timeout(test_file: str) -> None:
|
def test_timeout(test_file: str) -> None:
|
||||||
with open(test_file, "rb") as f:
|
with open(test_file, "rb") as f:
|
||||||
|
@ -392,7 +412,7 @@ def test_bounding_box_in_trailer() -> None:
|
||||||
# Check bounding boxes are parsed in the same way
|
# Check bounding boxes are parsed in the same way
|
||||||
# when specified in the header and the trailer
|
# when specified in the header and the trailer
|
||||||
with (
|
with (
|
||||||
Image.open("Tests/images/zero_bb_trailer.eps") as trailer_image,
|
Image.open("Tests/images/eps/zero_bb_trailer.eps") as trailer_image,
|
||||||
Image.open(FILE1) as header_image,
|
Image.open(FILE1) as header_image,
|
||||||
):
|
):
|
||||||
assert trailer_image.size == header_image.size
|
assert trailer_image.size == header_image.size
|
||||||
|
@ -400,12 +420,12 @@ def test_bounding_box_in_trailer() -> None:
|
||||||
|
|
||||||
def test_eof_before_bounding_box() -> None:
|
def test_eof_before_bounding_box() -> None:
|
||||||
with pytest.raises(OSError):
|
with pytest.raises(OSError):
|
||||||
with Image.open("Tests/images/zero_bb_eof_before_boundingbox.eps"):
|
with Image.open("Tests/images/eps/zero_bb_eof_before_boundingbox.eps"):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def test_invalid_data_after_eof() -> None:
|
def test_invalid_data_after_eof() -> None:
|
||||||
with open("Tests/images/illuCS6_preview.eps", "rb") as f:
|
with open("Tests/images/eps/illuCS6_preview.eps", "rb") as f:
|
||||||
img_bytes = io.BytesIO(f.read() + b"\r\n%" + (b" " * 255))
|
img_bytes = io.BytesIO(f.read() + b"\r\n%" + (b" " * 255))
|
||||||
|
|
||||||
with Image.open(img_bytes) as img:
|
with Image.open(img_bytes) as img:
|
||||||
|
|
|
@ -72,7 +72,7 @@ class TestFileWebp:
|
||||||
def _roundtrip(
|
def _roundtrip(
|
||||||
self, tmp_path: Path, mode: str, epsilon: float, args: dict[str, Any] = {}
|
self, tmp_path: Path, mode: str, epsilon: float, args: dict[str, Any] = {}
|
||||||
) -> None:
|
) -> None:
|
||||||
temp_file = str(tmp_path / "temp.webp")
|
temp_file = tmp_path / "temp.webp"
|
||||||
|
|
||||||
hopper(mode).save(temp_file, **args)
|
hopper(mode).save(temp_file, **args)
|
||||||
with Image.open(temp_file) as image:
|
with Image.open(temp_file) as image:
|
||||||
|
@ -116,7 +116,7 @@ class TestFileWebp:
|
||||||
assert buffer_no_args.getbuffer() != buffer_method.getbuffer()
|
assert buffer_no_args.getbuffer() != buffer_method.getbuffer()
|
||||||
|
|
||||||
def test_save_all(self, tmp_path: Path) -> None:
|
def test_save_all(self, tmp_path: Path) -> None:
|
||||||
temp_file = str(tmp_path / "temp.webp")
|
temp_file = tmp_path / "temp.webp"
|
||||||
im = Image.new("RGB", (1, 1))
|
im = Image.new("RGB", (1, 1))
|
||||||
im2 = Image.new("RGB", (1, 1), "#f00")
|
im2 = Image.new("RGB", (1, 1), "#f00")
|
||||||
im.save(temp_file, save_all=True, append_images=[im2])
|
im.save(temp_file, save_all=True, append_images=[im2])
|
||||||
|
@ -127,6 +127,11 @@ class TestFileWebp:
|
||||||
reloaded.seek(1)
|
reloaded.seek(1)
|
||||||
assert_image_similar(im2, reloaded, 1)
|
assert_image_similar(im2, reloaded, 1)
|
||||||
|
|
||||||
|
def test_unsupported_image_mode(self) -> None:
|
||||||
|
im = Image.new("1", (1, 1))
|
||||||
|
with pytest.raises(ValueError):
|
||||||
|
_webp.WebPEncode(im.getim(), False, 0, 0, "", 4, 0, b"", "")
|
||||||
|
|
||||||
def test_icc_profile(self, tmp_path: Path) -> None:
|
def test_icc_profile(self, tmp_path: Path) -> None:
|
||||||
self._roundtrip(tmp_path, self.rgb_mode, 12.5, {"icc_profile": None})
|
self._roundtrip(tmp_path, self.rgb_mode, 12.5, {"icc_profile": None})
|
||||||
self._roundtrip(
|
self._roundtrip(
|
||||||
|
@ -151,18 +156,16 @@ class TestFileWebp:
|
||||||
|
|
||||||
@pytest.mark.skipif(sys.maxsize <= 2**32, reason="Requires 64-bit system")
|
@pytest.mark.skipif(sys.maxsize <= 2**32, reason="Requires 64-bit system")
|
||||||
def test_write_encoding_error_message(self, tmp_path: Path) -> None:
|
def test_write_encoding_error_message(self, tmp_path: Path) -> None:
|
||||||
temp_file = str(tmp_path / "temp.webp")
|
|
||||||
im = Image.new("RGB", (15000, 15000))
|
im = Image.new("RGB", (15000, 15000))
|
||||||
with pytest.raises(ValueError) as e:
|
with pytest.raises(ValueError) as e:
|
||||||
im.save(temp_file, method=0)
|
im.save(tmp_path / "temp.webp", method=0)
|
||||||
assert str(e.value) == "encoding error 6"
|
assert str(e.value) == "encoding error 6"
|
||||||
|
|
||||||
@pytest.mark.skipif(sys.maxsize <= 2**32, reason="Requires 64-bit system")
|
@pytest.mark.skipif(sys.maxsize <= 2**32, reason="Requires 64-bit system")
|
||||||
def test_write_encoding_error_bad_dimension(self, tmp_path: Path) -> None:
|
def test_write_encoding_error_bad_dimension(self, tmp_path: Path) -> None:
|
||||||
temp_file = str(tmp_path / "temp.webp")
|
|
||||||
im = Image.new("L", (16384, 16384))
|
im = Image.new("L", (16384, 16384))
|
||||||
with pytest.raises(ValueError) as e:
|
with pytest.raises(ValueError) as e:
|
||||||
im.save(temp_file)
|
im.save(tmp_path / "temp.webp")
|
||||||
assert (
|
assert (
|
||||||
str(e.value)
|
str(e.value)
|
||||||
== "encoding error 5: Image size exceeds WebP limit of 16383 pixels"
|
== "encoding error 5: Image size exceeds WebP limit of 16383 pixels"
|
||||||
|
@ -187,9 +190,8 @@ class TestFileWebp:
|
||||||
def test_no_resource_warning(self, tmp_path: Path) -> None:
|
def test_no_resource_warning(self, tmp_path: Path) -> None:
|
||||||
file_path = "Tests/images/hopper.webp"
|
file_path = "Tests/images/hopper.webp"
|
||||||
with Image.open(file_path) as image:
|
with Image.open(file_path) as image:
|
||||||
temp_file = str(tmp_path / "temp.webp")
|
|
||||||
with warnings.catch_warnings():
|
with warnings.catch_warnings():
|
||||||
image.save(temp_file)
|
image.save(tmp_path / "temp.webp")
|
||||||
|
|
||||||
def test_file_pointer_could_be_reused(self) -> None:
|
def test_file_pointer_could_be_reused(self) -> None:
|
||||||
file_path = "Tests/images/hopper.webp"
|
file_path = "Tests/images/hopper.webp"
|
||||||
|
@ -204,15 +206,16 @@ class TestFileWebp:
|
||||||
def test_invalid_background(
|
def test_invalid_background(
|
||||||
self, background: int | tuple[int, ...], tmp_path: Path
|
self, background: int | tuple[int, ...], tmp_path: Path
|
||||||
) -> None:
|
) -> None:
|
||||||
temp_file = str(tmp_path / "temp.webp")
|
temp_file = tmp_path / "temp.webp"
|
||||||
im = hopper()
|
im = hopper()
|
||||||
with pytest.raises(OSError):
|
with pytest.raises(OSError):
|
||||||
im.save(temp_file, save_all=True, append_images=[im], background=background)
|
im.save(temp_file, save_all=True, append_images=[im], background=background)
|
||||||
|
|
||||||
def test_background_from_gif(self, tmp_path: Path) -> None:
|
def test_background_from_gif(self, tmp_path: Path) -> None:
|
||||||
|
out_webp = tmp_path / "temp.webp"
|
||||||
|
|
||||||
# Save L mode GIF with background
|
# Save L mode GIF with background
|
||||||
with Image.open("Tests/images/no_palette_with_background.gif") as im:
|
with Image.open("Tests/images/no_palette_with_background.gif") as im:
|
||||||
out_webp = str(tmp_path / "temp.webp")
|
|
||||||
im.save(out_webp, save_all=True)
|
im.save(out_webp, save_all=True)
|
||||||
|
|
||||||
# Save P mode GIF with background
|
# Save P mode GIF with background
|
||||||
|
@ -221,11 +224,10 @@ class TestFileWebp:
|
||||||
assert isinstance(original_value, tuple)
|
assert isinstance(original_value, tuple)
|
||||||
|
|
||||||
# Save as WEBP
|
# Save as WEBP
|
||||||
out_webp = str(tmp_path / "temp.webp")
|
|
||||||
im.save(out_webp, save_all=True)
|
im.save(out_webp, save_all=True)
|
||||||
|
|
||||||
# Save as GIF
|
# Save as GIF
|
||||||
out_gif = str(tmp_path / "temp.gif")
|
out_gif = tmp_path / "temp.gif"
|
||||||
with Image.open(out_webp) as im:
|
with Image.open(out_webp) as im:
|
||||||
im.save(out_gif)
|
im.save(out_gif)
|
||||||
|
|
||||||
|
@ -236,10 +238,10 @@ class TestFileWebp:
|
||||||
assert difference < 5
|
assert difference < 5
|
||||||
|
|
||||||
def test_duration(self, tmp_path: Path) -> None:
|
def test_duration(self, tmp_path: Path) -> None:
|
||||||
|
out_webp = tmp_path / "temp.webp"
|
||||||
|
|
||||||
with Image.open("Tests/images/dispose_bgnd.gif") as im:
|
with Image.open("Tests/images/dispose_bgnd.gif") as im:
|
||||||
assert im.info["duration"] == 1000
|
assert im.info["duration"] == 1000
|
||||||
|
|
||||||
out_webp = str(tmp_path / "temp.webp")
|
|
||||||
im.save(out_webp, save_all=True)
|
im.save(out_webp, save_all=True)
|
||||||
|
|
||||||
with Image.open(out_webp) as reloaded:
|
with Image.open(out_webp) as reloaded:
|
||||||
|
@ -247,7 +249,7 @@ class TestFileWebp:
|
||||||
assert reloaded.info["duration"] == 1000
|
assert reloaded.info["duration"] == 1000
|
||||||
|
|
||||||
def test_roundtrip_rgba_palette(self, tmp_path: Path) -> None:
|
def test_roundtrip_rgba_palette(self, tmp_path: Path) -> None:
|
||||||
temp_file = str(tmp_path / "temp.webp")
|
temp_file = tmp_path / "temp.webp"
|
||||||
im = Image.new("RGBA", (1, 1)).convert("P")
|
im = Image.new("RGBA", (1, 1)).convert("P")
|
||||||
assert im.mode == "P"
|
assert im.mode == "P"
|
||||||
assert im.palette is not None
|
assert im.palette is not None
|
||||||
|
|
|
@ -44,9 +44,19 @@ class TestImagingCoreResize:
|
||||||
self.resize(hopper("1"), (15, 12), Image.Resampling.BILINEAR)
|
self.resize(hopper("1"), (15, 12), Image.Resampling.BILINEAR)
|
||||||
with pytest.raises(ValueError):
|
with pytest.raises(ValueError):
|
||||||
self.resize(hopper("P"), (15, 12), Image.Resampling.BILINEAR)
|
self.resize(hopper("P"), (15, 12), Image.Resampling.BILINEAR)
|
||||||
with pytest.raises(ValueError):
|
for mode in [
|
||||||
self.resize(hopper("I;16"), (15, 12), Image.Resampling.BILINEAR)
|
"L",
|
||||||
for mode in ["L", "I", "F", "RGB", "RGBA", "CMYK", "YCbCr"]:
|
"I",
|
||||||
|
"I;16",
|
||||||
|
"I;16L",
|
||||||
|
"I;16B",
|
||||||
|
"I;16N",
|
||||||
|
"F",
|
||||||
|
"RGB",
|
||||||
|
"RGBA",
|
||||||
|
"CMYK",
|
||||||
|
"YCbCr",
|
||||||
|
]:
|
||||||
im = hopper(mode)
|
im = hopper(mode)
|
||||||
r = self.resize(im, (15, 12), Image.Resampling.BILINEAR)
|
r = self.resize(im, (15, 12), Image.Resampling.BILINEAR)
|
||||||
assert r.mode == mode
|
assert r.mode == mode
|
||||||
|
@ -305,14 +315,14 @@ class TestImageResize:
|
||||||
im = img.resize((64, 64))
|
im = img.resize((64, 64))
|
||||||
assert im.size == (64, 64)
|
assert im.size == (64, 64)
|
||||||
|
|
||||||
@pytest.mark.parametrize("mode", ("L", "RGB", "I", "F"))
|
@pytest.mark.parametrize(
|
||||||
|
"mode", ("L", "RGB", "I", "I;16", "I;16L", "I;16B", "I;16N", "F")
|
||||||
|
)
|
||||||
def test_default_filter_bicubic(self, mode: str) -> None:
|
def test_default_filter_bicubic(self, mode: str) -> None:
|
||||||
im = hopper(mode)
|
im = hopper(mode)
|
||||||
assert im.resize((20, 20), Image.Resampling.BICUBIC) == im.resize((20, 20))
|
assert im.resize((20, 20), Image.Resampling.BICUBIC) == im.resize((20, 20))
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize("mode", ("1", "P", "BGR;15", "BGR;16"))
|
||||||
"mode", ("1", "P", "I;16", "I;16L", "I;16B", "BGR;15", "BGR;16")
|
|
||||||
)
|
|
||||||
def test_default_filter_nearest(self, mode: str) -> None:
|
def test_default_filter_nearest(self, mode: str) -> None:
|
||||||
im = hopper(mode)
|
im = hopper(mode)
|
||||||
assert im.resize((20, 20), Image.Resampling.NEAREST) == im.resize((20, 20))
|
assert im.resize((20, 20), Image.Resampling.NEAREST) == im.resize((20, 20))
|
||||||
|
|
|
@ -204,6 +204,17 @@ def test_overflow_segfault() -> None:
|
||||||
x[i] = b"0" * 16
|
x[i] = b"0" * 16
|
||||||
|
|
||||||
|
|
||||||
|
def test_compact_within_map() -> None:
|
||||||
|
p = ImagePath.Path([0, 1])
|
||||||
|
|
||||||
|
def map_func(x: float, y: float) -> tuple[float, float]:
|
||||||
|
p.compact()
|
||||||
|
return 0, 0
|
||||||
|
|
||||||
|
with pytest.raises(ValueError):
|
||||||
|
p.map(map_func)
|
||||||
|
|
||||||
|
|
||||||
class Evil:
|
class Evil:
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
self.corrupt = Image.core.path(0x4000000000000000)
|
self.corrupt = Image.core.path(0x4000000000000000)
|
||||||
|
|
|
@ -58,10 +58,10 @@ def helper_pickle_string(protocol: int, test_file: str, mode: str | None) -> Non
|
||||||
),
|
),
|
||||||
("Tests/images/hopper.tif", None),
|
("Tests/images/hopper.tif", None),
|
||||||
("Tests/images/test-card.png", None),
|
("Tests/images/test-card.png", None),
|
||||||
("Tests/images/zero_bb.png", None),
|
("Tests/images/eps/zero_bb.png", None),
|
||||||
("Tests/images/zero_bb_scale2.png", None),
|
("Tests/images/eps/zero_bb_scale2.png", None),
|
||||||
("Tests/images/non_zero_bb.png", None),
|
("Tests/images/eps/non_zero_bb.png", None),
|
||||||
("Tests/images/non_zero_bb_scale2.png", None),
|
("Tests/images/eps/non_zero_bb_scale2.png", None),
|
||||||
("Tests/images/p_trns_single.png", None),
|
("Tests/images/p_trns_single.png", None),
|
||||||
("Tests/images/pil123p.png", None),
|
("Tests/images/pil123p.png", None),
|
||||||
("Tests/images/itxt_chunks.png", None),
|
("Tests/images/itxt_chunks.png", None),
|
||||||
|
|
|
@ -23,19 +23,14 @@ else
|
||||||
cargo cinstall --prefix=/usr --destdir=.
|
cargo cinstall --prefix=/usr --destdir=.
|
||||||
|
|
||||||
# Copy into place
|
# Copy into place
|
||||||
if [ -d "usr/lib64" ]; then
|
sudo find usr -name libimagequant.so* -exec cp {} /usr/lib/ \;
|
||||||
lib="lib64"
|
|
||||||
else
|
|
||||||
lib="lib"
|
|
||||||
fi
|
|
||||||
sudo cp usr/$lib/libimagequant.so* /usr/lib/
|
|
||||||
sudo cp usr/include/libimagequant.h /usr/include/
|
sudo cp usr/include/libimagequant.h /usr/include/
|
||||||
|
|
||||||
if [ -n "$GITHUB_ACTIONS" ]; then
|
if [ -n "$GITHUB_ACTIONS" ]; then
|
||||||
# Copy to cache
|
# Copy to cache
|
||||||
rm -rf ~/cache-$archive_name
|
rm -rf ~/cache-$archive_name
|
||||||
mkdir ~/cache-$archive_name
|
mkdir ~/cache-$archive_name
|
||||||
cp usr/lib/libimagequant.so* ~/cache-$archive_name/
|
find usr -name libimagequant.so* -exec cp {} ~/cache-$archive_name/ \;
|
||||||
cp usr/include/libimagequant.h ~/cache-$archive_name/
|
cp usr/include/libimagequant.h ~/cache-$archive_name/
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -17,13 +17,13 @@ These platforms are built and tested for every change.
|
||||||
+----------------------------------+----------------------------+---------------------+
|
+----------------------------------+----------------------------+---------------------+
|
||||||
| Operating system | Tested Python versions | Tested architecture |
|
| Operating system | Tested Python versions | Tested architecture |
|
||||||
+==================================+============================+=====================+
|
+==================================+============================+=====================+
|
||||||
| Alpine | 3.9 | x86-64 |
|
| Alpine | 3.12 | x86-64 |
|
||||||
+----------------------------------+----------------------------+---------------------+
|
+----------------------------------+----------------------------+---------------------+
|
||||||
| Amazon Linux 2 | 3.9 | x86-64 |
|
| Amazon Linux 2 | 3.9 | x86-64 |
|
||||||
+----------------------------------+----------------------------+---------------------+
|
+----------------------------------+----------------------------+---------------------+
|
||||||
| Amazon Linux 2023 | 3.9 | x86-64 |
|
| Amazon Linux 2023 | 3.9 | x86-64 |
|
||||||
+----------------------------------+----------------------------+---------------------+
|
+----------------------------------+----------------------------+---------------------+
|
||||||
| Arch | 3.9 | x86-64 |
|
| Arch | 3.12 | x86-64 |
|
||||||
+----------------------------------+----------------------------+---------------------+
|
+----------------------------------+----------------------------+---------------------+
|
||||||
| CentOS Stream 9 | 3.9 | x86-64 |
|
| CentOS Stream 9 | 3.9 | x86-64 |
|
||||||
+----------------------------------+----------------------------+---------------------+
|
+----------------------------------+----------------------------+---------------------+
|
||||||
|
@ -33,7 +33,7 @@ These platforms are built and tested for every change.
|
||||||
+----------------------------------+----------------------------+---------------------+
|
+----------------------------------+----------------------------+---------------------+
|
||||||
| Fedora 40 | 3.12 | x86-64 |
|
| Fedora 40 | 3.12 | x86-64 |
|
||||||
+----------------------------------+----------------------------+---------------------+
|
+----------------------------------+----------------------------+---------------------+
|
||||||
| Gentoo | 3.9 | x86-64 |
|
| Gentoo | 3.12 | x86-64 |
|
||||||
+----------------------------------+----------------------------+---------------------+
|
+----------------------------------+----------------------------+---------------------+
|
||||||
| macOS 13 Ventura | 3.9 | x86-64 |
|
| macOS 13 Ventura | 3.9 | x86-64 |
|
||||||
+----------------------------------+----------------------------+---------------------+
|
+----------------------------------+----------------------------+---------------------+
|
||||||
|
@ -48,12 +48,12 @@ These platforms are built and tested for every change.
|
||||||
| Ubuntu Linux 24.04 LTS (Noble) | 3.12 | x86-64, ppc64le, |
|
| Ubuntu Linux 24.04 LTS (Noble) | 3.12 | x86-64, ppc64le, |
|
||||||
| | | s390x |
|
| | | s390x |
|
||||||
+----------------------------------+----------------------------+---------------------+
|
+----------------------------------+----------------------------+---------------------+
|
||||||
| Windows Server 2016 | 3.9 | x86-64 |
|
| Windows Server 2019 | 3.9 | x86-64 |
|
||||||
+----------------------------------+----------------------------+---------------------+
|
+----------------------------------+----------------------------+---------------------+
|
||||||
| Windows Server 2022 | 3.9, 3.10, 3.11, | x86-64 |
|
| Windows Server 2022 | 3.9, 3.10, 3.11, | x86-64 |
|
||||||
| | 3.12, 3.13, PyPy3 | |
|
| | 3.12, 3.13, PyPy3 | |
|
||||||
| +----------------------------+---------------------+
|
| +----------------------------+---------------------+
|
||||||
| | 3.12 | x86 |
|
| | 3.13 | x86 |
|
||||||
| +----------------------------+---------------------+
|
| +----------------------------+---------------------+
|
||||||
| | 3.9 (MinGW) | x86-64 |
|
| | 3.9 (MinGW) | x86-64 |
|
||||||
| +----------------------------+---------------------+
|
| +----------------------------+---------------------+
|
||||||
|
@ -75,6 +75,8 @@ These platforms have been reported to work at the versions mentioned.
|
||||||
| Operating system | | Tested Python | | Latest tested | | Tested |
|
| Operating system | | Tested Python | | Latest tested | | Tested |
|
||||||
| | | versions | | Pillow version | | processors |
|
| | | versions | | Pillow version | | processors |
|
||||||
+==================================+============================+==================+==============+
|
+==================================+============================+==================+==============+
|
||||||
|
| macOS 15 Sequoia | 3.8, 3.9, 3.10, 3.11, 3.12 | 10.4.0 |arm |
|
||||||
|
+----------------------------------+----------------------------+------------------+--------------+
|
||||||
| macOS 14 Sonoma | 3.8, 3.9, 3.10, 3.11, 3.12 | 10.4.0 |arm |
|
| macOS 14 Sonoma | 3.8, 3.9, 3.10, 3.11, 3.12 | 10.4.0 |arm |
|
||||||
+----------------------------------+----------------------------+------------------+--------------+
|
+----------------------------------+----------------------------+------------------+--------------+
|
||||||
| macOS 13 Ventura | 3.8, 3.9, 3.10, 3.11 | 10.0.1 |arm |
|
| macOS 13 Ventura | 3.8, 3.9, 3.10, 3.11 | 10.0.1 |arm |
|
||||||
|
|
|
@ -119,10 +119,11 @@ Specific WebP Feature Checks
|
||||||
API Changes
|
API Changes
|
||||||
===========
|
===========
|
||||||
|
|
||||||
TODO
|
Default resampling filter for I;16* image modes
|
||||||
^^^^
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
TODO
|
The default resampling filter for I;16, I;16L, I;16B and I;16N has been changed from
|
||||||
|
``Image.NEAREST`` to ``Image.BICUBIC``, to match the majority of modes.
|
||||||
|
|
||||||
API Additions
|
API Additions
|
||||||
=============
|
=============
|
||||||
|
|
|
@ -97,9 +97,13 @@ config-settings = "raqm=enable raqm=vendor fribidi=vendor imagequant=disable"
|
||||||
test-command = "cd {project} && .github/workflows/wheels-test.sh"
|
test-command = "cd {project} && .github/workflows/wheels-test.sh"
|
||||||
test-extras = "tests"
|
test-extras = "tests"
|
||||||
|
|
||||||
[tool.ruff]
|
[tool.black]
|
||||||
fix = true
|
exclude = "wheels/multibuild"
|
||||||
|
|
||||||
|
[tool.ruff]
|
||||||
|
exclude = [ "wheels/multibuild" ]
|
||||||
|
|
||||||
|
fix = true
|
||||||
lint.select = [
|
lint.select = [
|
||||||
"C4", # flake8-comprehensions
|
"C4", # flake8-comprehensions
|
||||||
"E", # pycodestyle errors
|
"E", # pycodestyle errors
|
||||||
|
|
|
@ -121,7 +121,13 @@ def Ghostscript(
|
||||||
lengthfile -= len(s)
|
lengthfile -= len(s)
|
||||||
f.write(s)
|
f.write(s)
|
||||||
|
|
||||||
device = "pngalpha" if transparency else "ppmraw"
|
if transparency:
|
||||||
|
# "RGBA"
|
||||||
|
device = "pngalpha"
|
||||||
|
else:
|
||||||
|
# "pnmraw" automatically chooses between
|
||||||
|
# PBM ("1"), PGM ("L"), and PPM ("RGB").
|
||||||
|
device = "pnmraw"
|
||||||
|
|
||||||
# Build Ghostscript command
|
# Build Ghostscript command
|
||||||
command = [
|
command = [
|
||||||
|
@ -151,8 +157,9 @@ def Ghostscript(
|
||||||
startupinfo = subprocess.STARTUPINFO()
|
startupinfo = subprocess.STARTUPINFO()
|
||||||
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
|
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
|
||||||
subprocess.check_call(command, startupinfo=startupinfo)
|
subprocess.check_call(command, startupinfo=startupinfo)
|
||||||
out_im = Image.open(outfile)
|
with Image.open(outfile) as out_im:
|
||||||
out_im.load()
|
out_im.load()
|
||||||
|
return out_im.im.copy()
|
||||||
finally:
|
finally:
|
||||||
try:
|
try:
|
||||||
os.unlink(outfile)
|
os.unlink(outfile)
|
||||||
|
@ -161,10 +168,6 @@ def Ghostscript(
|
||||||
except OSError:
|
except OSError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
im = out_im.im.copy()
|
|
||||||
out_im.close()
|
|
||||||
return im
|
|
||||||
|
|
||||||
|
|
||||||
def _accept(prefix: bytes) -> bool:
|
def _accept(prefix: bytes) -> bool:
|
||||||
return prefix[:4] == b"%!PS" or (len(prefix) >= 4 and i32(prefix) == 0xC6D3D0C5)
|
return prefix[:4] == b"%!PS" or (len(prefix) >= 4 and i32(prefix) == 0xC6D3D0C5)
|
||||||
|
@ -192,6 +195,11 @@ class EpsImageFile(ImageFile.ImageFile):
|
||||||
|
|
||||||
self._mode = "RGB"
|
self._mode = "RGB"
|
||||||
|
|
||||||
|
# When reading header comments, the first comment is used.
|
||||||
|
# When reading trailer comments, the last comment is used.
|
||||||
|
bounding_box: list[int] | None = None
|
||||||
|
imagedata_size: tuple[int, int] | None = None
|
||||||
|
|
||||||
byte_arr = bytearray(255)
|
byte_arr = bytearray(255)
|
||||||
bytes_mv = memoryview(byte_arr)
|
bytes_mv = memoryview(byte_arr)
|
||||||
bytes_read = 0
|
bytes_read = 0
|
||||||
|
@ -212,8 +220,8 @@ class EpsImageFile(ImageFile.ImageFile):
|
||||||
msg = 'EPS header missing "%%BoundingBox" comment'
|
msg = 'EPS header missing "%%BoundingBox" comment'
|
||||||
raise SyntaxError(msg)
|
raise SyntaxError(msg)
|
||||||
|
|
||||||
def _read_comment(s: str) -> bool:
|
def read_comment(s: str) -> bool:
|
||||||
nonlocal reading_trailer_comments
|
nonlocal bounding_box, reading_trailer_comments
|
||||||
try:
|
try:
|
||||||
m = split.match(s)
|
m = split.match(s)
|
||||||
except re.error as e:
|
except re.error as e:
|
||||||
|
@ -228,18 +236,12 @@ class EpsImageFile(ImageFile.ImageFile):
|
||||||
if k == "BoundingBox":
|
if k == "BoundingBox":
|
||||||
if v == "(atend)":
|
if v == "(atend)":
|
||||||
reading_trailer_comments = True
|
reading_trailer_comments = True
|
||||||
elif not self.tile or (trailer_reached and reading_trailer_comments):
|
elif not bounding_box or (trailer_reached and reading_trailer_comments):
|
||||||
try:
|
try:
|
||||||
# Note: The DSC spec says that BoundingBox
|
# Note: The DSC spec says that BoundingBox
|
||||||
# fields should be integers, but some drivers
|
# fields should be integers, but some drivers
|
||||||
# put floating point values there anyway.
|
# put floating point values there anyway.
|
||||||
box = [int(float(i)) for i in v.split()]
|
bounding_box = [int(float(i)) for i in v.split()]
|
||||||
self._size = box[2] - box[0], box[3] - box[1]
|
|
||||||
self.tile = [
|
|
||||||
ImageFile._Tile(
|
|
||||||
"eps", (0, 0) + self.size, offset, (length, box)
|
|
||||||
)
|
|
||||||
]
|
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
return True
|
return True
|
||||||
|
@ -290,7 +292,7 @@ class EpsImageFile(ImageFile.ImageFile):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
s = str(bytes_mv[:bytes_read], "latin-1")
|
s = str(bytes_mv[:bytes_read], "latin-1")
|
||||||
if not _read_comment(s):
|
if not read_comment(s):
|
||||||
m = field.match(s)
|
m = field.match(s)
|
||||||
if m:
|
if m:
|
||||||
k = m.group(1)
|
k = m.group(1)
|
||||||
|
@ -309,6 +311,12 @@ class EpsImageFile(ImageFile.ImageFile):
|
||||||
# Check for an "ImageData" descriptor
|
# Check for an "ImageData" descriptor
|
||||||
# https://www.adobe.com/devnet-apps/photoshop/fileformatashtml/#50577413_pgfId-1035096
|
# https://www.adobe.com/devnet-apps/photoshop/fileformatashtml/#50577413_pgfId-1035096
|
||||||
|
|
||||||
|
# If we've already read an "ImageData" descriptor,
|
||||||
|
# don't read another one.
|
||||||
|
if imagedata_size:
|
||||||
|
bytes_read = 0
|
||||||
|
continue
|
||||||
|
|
||||||
# Values:
|
# Values:
|
||||||
# columns
|
# columns
|
||||||
# rows
|
# rows
|
||||||
|
@ -334,22 +342,35 @@ class EpsImageFile(ImageFile.ImageFile):
|
||||||
else:
|
else:
|
||||||
break
|
break
|
||||||
|
|
||||||
self._size = columns, rows
|
# Parse the columns and rows after checking the bit depth and mode
|
||||||
return
|
# in case the bit depth and/or mode are invalid.
|
||||||
|
imagedata_size = columns, rows
|
||||||
elif bytes_mv[:5] == b"%%EOF":
|
elif bytes_mv[:5] == b"%%EOF":
|
||||||
break
|
break
|
||||||
elif trailer_reached and reading_trailer_comments:
|
elif trailer_reached and reading_trailer_comments:
|
||||||
# Load EPS trailer
|
# Load EPS trailer
|
||||||
s = str(bytes_mv[:bytes_read], "latin-1")
|
s = str(bytes_mv[:bytes_read], "latin-1")
|
||||||
_read_comment(s)
|
read_comment(s)
|
||||||
elif bytes_mv[:9] == b"%%Trailer":
|
elif bytes_mv[:9] == b"%%Trailer":
|
||||||
trailer_reached = True
|
trailer_reached = True
|
||||||
bytes_read = 0
|
bytes_read = 0
|
||||||
|
|
||||||
if not self.tile:
|
# A "BoundingBox" is always required,
|
||||||
|
# even if an "ImageData" descriptor size exists.
|
||||||
|
if not bounding_box:
|
||||||
msg = "cannot determine EPS bounding box"
|
msg = "cannot determine EPS bounding box"
|
||||||
raise OSError(msg)
|
raise OSError(msg)
|
||||||
|
|
||||||
|
# An "ImageData" size takes precedence over the "BoundingBox".
|
||||||
|
self._size = imagedata_size or (
|
||||||
|
bounding_box[2] - bounding_box[0],
|
||||||
|
bounding_box[3] - bounding_box[1],
|
||||||
|
)
|
||||||
|
|
||||||
|
self.tile = [
|
||||||
|
ImageFile._Tile("eps", (0, 0) + self.size, offset, (length, bounding_box))
|
||||||
|
]
|
||||||
|
|
||||||
def _find_offset(self, fp: IO[bytes]) -> tuple[int, int]:
|
def _find_offset(self, fp: IO[bytes]) -> tuple[int, int]:
|
||||||
s = fp.read(4)
|
s = fp.read(4)
|
||||||
|
|
||||||
|
|
|
@ -2218,8 +2218,8 @@ class Image:
|
||||||
:py:data:`Resampling.BILINEAR`, :py:data:`Resampling.HAMMING`,
|
:py:data:`Resampling.BILINEAR`, :py:data:`Resampling.HAMMING`,
|
||||||
:py:data:`Resampling.BICUBIC` or :py:data:`Resampling.LANCZOS`.
|
:py:data:`Resampling.BICUBIC` or :py:data:`Resampling.LANCZOS`.
|
||||||
If the image has mode "1" or "P", it is always set to
|
If the image has mode "1" or "P", it is always set to
|
||||||
:py:data:`Resampling.NEAREST`. If the image mode specifies a number
|
:py:data:`Resampling.NEAREST`. If the image mode is "BGR;15",
|
||||||
of bits, such as "I;16", then the default filter is
|
"BGR;16" or "BGR;24", then the default filter is
|
||||||
:py:data:`Resampling.NEAREST`. Otherwise, the default filter is
|
:py:data:`Resampling.NEAREST`. Otherwise, the default filter is
|
||||||
:py:data:`Resampling.BICUBIC`. See: :ref:`concept-filters`.
|
:py:data:`Resampling.BICUBIC`. See: :ref:`concept-filters`.
|
||||||
:param box: An optional 4-tuple of floats providing
|
:param box: An optional 4-tuple of floats providing
|
||||||
|
@ -2242,8 +2242,8 @@ class Image:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if resample is None:
|
if resample is None:
|
||||||
type_special = ";" in self.mode
|
bgr = self.mode.startswith("BGR;")
|
||||||
resample = Resampling.NEAREST if type_special else Resampling.BICUBIC
|
resample = Resampling.NEAREST if bgr else Resampling.BICUBIC
|
||||||
elif resample not in (
|
elif resample not in (
|
||||||
Resampling.NEAREST,
|
Resampling.NEAREST,
|
||||||
Resampling.BILINEAR,
|
Resampling.BILINEAR,
|
||||||
|
|
|
@ -55,7 +55,9 @@ class Color(_Enhance):
|
||||||
if "A" in image.getbands():
|
if "A" in image.getbands():
|
||||||
self.intermediate_mode = "LA"
|
self.intermediate_mode = "LA"
|
||||||
|
|
||||||
self.degenerate = image.convert(self.intermediate_mode).convert(image.mode)
|
if self.intermediate_mode != image.mode:
|
||||||
|
image = image.convert(self.intermediate_mode).convert(image.mode)
|
||||||
|
self.degenerate = image
|
||||||
|
|
||||||
|
|
||||||
class Contrast(_Enhance):
|
class Contrast(_Enhance):
|
||||||
|
@ -68,11 +70,15 @@ class Contrast(_Enhance):
|
||||||
|
|
||||||
def __init__(self, image: Image.Image) -> None:
|
def __init__(self, image: Image.Image) -> None:
|
||||||
self.image = image
|
self.image = image
|
||||||
mean = int(ImageStat.Stat(image.convert("L")).mean[0] + 0.5)
|
if image.mode != "L":
|
||||||
self.degenerate = Image.new("L", image.size, mean).convert(image.mode)
|
image = image.convert("L")
|
||||||
|
mean = int(ImageStat.Stat(image).mean[0] + 0.5)
|
||||||
|
self.degenerate = Image.new("L", image.size, mean)
|
||||||
|
if self.degenerate.mode != self.image.mode:
|
||||||
|
self.degenerate = self.degenerate.convert(self.image.mode)
|
||||||
|
|
||||||
if "A" in image.getbands():
|
if "A" in self.image.getbands():
|
||||||
self.degenerate.putalpha(image.getchannel("A"))
|
self.degenerate.putalpha(self.image.getchannel("A"))
|
||||||
|
|
||||||
|
|
||||||
class Brightness(_Enhance):
|
class Brightness(_Enhance):
|
||||||
|
|
|
@ -1069,6 +1069,12 @@ class PngImageFile(ImageFile.ImageFile):
|
||||||
"RGBA", self.info["transparency"]
|
"RGBA", self.info["transparency"]
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
|
if self.im.mode == "P" and "transparency" in self.info:
|
||||||
|
t = self.info["transparency"]
|
||||||
|
if isinstance(t, bytes):
|
||||||
|
updated.putpalettealphas(t)
|
||||||
|
elif isinstance(t, int):
|
||||||
|
updated.putpalettealpha(t)
|
||||||
mask = updated.convert("RGBA")
|
mask = updated.convert("RGBA")
|
||||||
self._prev_im.paste(updated, self.dispose_extent, mask)
|
self._prev_im.paste(updated, self.dispose_extent, mask)
|
||||||
self.im = self._prev_im
|
self.im = self._prev_im
|
||||||
|
|
|
@ -13,10 +13,6 @@ except ImportError:
|
||||||
SUPPORTED = False
|
SUPPORTED = False
|
||||||
|
|
||||||
|
|
||||||
_VALID_WEBP_MODES = {"RGBX": True, "RGBA": True, "RGB": True}
|
|
||||||
|
|
||||||
_VALID_WEBP_LEGACY_MODES = {"RGB": True, "RGBA": True}
|
|
||||||
|
|
||||||
_VP8_MODES_BY_IDENTIFIER = {
|
_VP8_MODES_BY_IDENTIFIER = {
|
||||||
b"VP8 ": "RGB",
|
b"VP8 ": "RGB",
|
||||||
b"VP8X": "RGBA",
|
b"VP8X": "RGBA",
|
||||||
|
@ -154,6 +150,13 @@ class WebPImageFile(ImageFile.ImageFile):
|
||||||
return self.__logical_frame
|
return self.__logical_frame
|
||||||
|
|
||||||
|
|
||||||
|
def _convert_frame(im: Image.Image) -> Image.Image:
|
||||||
|
# Make sure image mode is supported
|
||||||
|
if im.mode not in ("RGBX", "RGBA", "RGB"):
|
||||||
|
im = im.convert("RGBA" if im.has_transparency_data else "RGB")
|
||||||
|
return im
|
||||||
|
|
||||||
|
|
||||||
def _save_all(im: Image.Image, fp: IO[bytes], filename: str | bytes) -> None:
|
def _save_all(im: Image.Image, fp: IO[bytes], filename: str | bytes) -> None:
|
||||||
encoderinfo = im.encoderinfo.copy()
|
encoderinfo = im.encoderinfo.copy()
|
||||||
append_images = list(encoderinfo.get("append_images", []))
|
append_images = list(encoderinfo.get("append_images", []))
|
||||||
|
@ -244,31 +247,13 @@ def _save_all(im: Image.Image, fp: IO[bytes], filename: str | bytes) -> None:
|
||||||
|
|
||||||
for idx in range(nfr):
|
for idx in range(nfr):
|
||||||
ims.seek(idx)
|
ims.seek(idx)
|
||||||
ims.load()
|
|
||||||
|
|
||||||
# Make sure image mode is supported
|
frame = _convert_frame(ims)
|
||||||
frame = ims
|
|
||||||
rawmode = ims.mode
|
|
||||||
if ims.mode not in _VALID_WEBP_MODES:
|
|
||||||
alpha = (
|
|
||||||
"A" in ims.mode
|
|
||||||
or "a" in ims.mode
|
|
||||||
or (ims.mode == "P" and "A" in ims.im.getpalettemode())
|
|
||||||
)
|
|
||||||
rawmode = "RGBA" if alpha else "RGB"
|
|
||||||
frame = ims.convert(rawmode)
|
|
||||||
|
|
||||||
if rawmode == "RGB":
|
|
||||||
# For faster conversion, use RGBX
|
|
||||||
rawmode = "RGBX"
|
|
||||||
|
|
||||||
# Append the frame to the animation encoder
|
# Append the frame to the animation encoder
|
||||||
enc.add(
|
enc.add(
|
||||||
frame.tobytes("raw", rawmode),
|
frame.getim(),
|
||||||
round(timestamp),
|
round(timestamp),
|
||||||
frame.size[0],
|
|
||||||
frame.size[1],
|
|
||||||
rawmode,
|
|
||||||
lossless,
|
lossless,
|
||||||
quality,
|
quality,
|
||||||
alpha_quality,
|
alpha_quality,
|
||||||
|
@ -286,7 +271,7 @@ def _save_all(im: Image.Image, fp: IO[bytes], filename: str | bytes) -> None:
|
||||||
im.seek(cur_idx)
|
im.seek(cur_idx)
|
||||||
|
|
||||||
# Force encoder to flush frames
|
# Force encoder to flush frames
|
||||||
enc.add(None, round(timestamp), 0, 0, "", lossless, quality, alpha_quality, 0)
|
enc.add(None, round(timestamp), lossless, quality, alpha_quality, 0)
|
||||||
|
|
||||||
# Get the final output from the encoder
|
# Get the final output from the encoder
|
||||||
data = enc.assemble(icc_profile, exif, xmp)
|
data = enc.assemble(icc_profile, exif, xmp)
|
||||||
|
@ -311,17 +296,13 @@ def _save(im: Image.Image, fp: IO[bytes], filename: str | bytes) -> None:
|
||||||
method = im.encoderinfo.get("method", 4)
|
method = im.encoderinfo.get("method", 4)
|
||||||
exact = 1 if im.encoderinfo.get("exact") else 0
|
exact = 1 if im.encoderinfo.get("exact") else 0
|
||||||
|
|
||||||
if im.mode not in _VALID_WEBP_LEGACY_MODES:
|
im = _convert_frame(im)
|
||||||
im = im.convert("RGBA" if im.has_transparency_data else "RGB")
|
|
||||||
|
|
||||||
data = _webp.WebPEncode(
|
data = _webp.WebPEncode(
|
||||||
im.tobytes(),
|
im.getim(),
|
||||||
im.size[0],
|
|
||||||
im.size[1],
|
|
||||||
lossless,
|
lossless,
|
||||||
float(quality),
|
float(quality),
|
||||||
float(alpha_quality),
|
float(alpha_quality),
|
||||||
im.mode,
|
|
||||||
icc_profile,
|
icc_profile,
|
||||||
method,
|
method,
|
||||||
exact,
|
exact,
|
||||||
|
|
|
@ -1579,16 +1579,12 @@ _putdata(ImagingObject *self, PyObject *args) {
|
||||||
int bigendian = 0;
|
int bigendian = 0;
|
||||||
if (image->type == IMAGING_TYPE_SPECIAL) {
|
if (image->type == IMAGING_TYPE_SPECIAL) {
|
||||||
// I;16*
|
// I;16*
|
||||||
if (strcmp(image->mode, "I;16N") == 0) {
|
if (strcmp(image->mode, "I;16B") == 0
|
||||||
#ifdef WORDS_BIGENDIAN
|
#ifdef WORDS_BIGENDIAN
|
||||||
bigendian = 1;
|
|| strcmp(image->mode, "I;16N") == 0
|
||||||
#else
|
|
||||||
bigendian = 0;
|
|
||||||
#endif
|
#endif
|
||||||
} else if (strcmp(image->mode, "I;16B") == 0) {
|
) {
|
||||||
bigendian = 1;
|
bigendian = 1;
|
||||||
} else {
|
|
||||||
bigendian = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (i = x = y = 0; i < n; i++) {
|
for (i = x = y = 0; i < n; i++) {
|
||||||
|
|
124
src/_webp.c
|
@ -83,6 +83,49 @@ HandleMuxError(WebPMuxError err, char *chunk) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------------- */
|
||||||
|
/* Frame import */
|
||||||
|
/* -------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
static int
|
||||||
|
import_frame_libwebp(WebPPicture *frame, Imaging im) {
|
||||||
|
if (strcmp(im->mode, "RGBA") && strcmp(im->mode, "RGB") &&
|
||||||
|
strcmp(im->mode, "RGBX")) {
|
||||||
|
PyErr_SetString(PyExc_ValueError, "unsupported image mode");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
frame->width = im->xsize;
|
||||||
|
frame->height = im->ysize;
|
||||||
|
frame->use_argb = 1; // Don't convert RGB pixels to YUV
|
||||||
|
|
||||||
|
if (!WebPPictureAlloc(frame)) {
|
||||||
|
PyErr_SetString(PyExc_MemoryError, "can't allocate picture frame");
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ignore_fourth_channel = strcmp(im->mode, "RGBA");
|
||||||
|
for (int y = 0; y < im->ysize; ++y) {
|
||||||
|
UINT8 *src = (UINT8 *)im->image32[y];
|
||||||
|
UINT32 *dst = frame->argb + frame->argb_stride * y;
|
||||||
|
if (ignore_fourth_channel) {
|
||||||
|
for (int x = 0; x < im->xsize; ++x) {
|
||||||
|
dst[x] =
|
||||||
|
((UINT32)(src[x * 4 + 2]) | ((UINT32)(src[x * 4 + 1]) << 8) |
|
||||||
|
((UINT32)(src[x * 4]) << 16) | (0xff << 24));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (int x = 0; x < im->xsize; ++x) {
|
||||||
|
dst[x] =
|
||||||
|
((UINT32)(src[x * 4 + 2]) | ((UINT32)(src[x * 4 + 1]) << 8) |
|
||||||
|
((UINT32)(src[x * 4]) << 16) | ((UINT32)(src[x * 4 + 3]) << 24));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* -------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------- */
|
||||||
/* WebP Animation Support */
|
/* WebP Animation Support */
|
||||||
/* -------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------- */
|
||||||
|
@ -180,16 +223,14 @@ _anim_encoder_dealloc(PyObject *self) {
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
_anim_encoder_add(PyObject *self, PyObject *args) {
|
_anim_encoder_add(PyObject *self, PyObject *args) {
|
||||||
uint8_t *rgb;
|
PyObject *i0;
|
||||||
Py_ssize_t size;
|
Imaging im;
|
||||||
int timestamp;
|
int timestamp;
|
||||||
int width;
|
|
||||||
int height;
|
|
||||||
char *mode;
|
|
||||||
int lossless;
|
int lossless;
|
||||||
float quality_factor;
|
float quality_factor;
|
||||||
float alpha_quality_factor;
|
float alpha_quality_factor;
|
||||||
int method;
|
int method;
|
||||||
|
ImagingSectionCookie cookie;
|
||||||
WebPConfig config;
|
WebPConfig config;
|
||||||
WebPAnimEncoderObject *encp = (WebPAnimEncoderObject *)self;
|
WebPAnimEncoderObject *encp = (WebPAnimEncoderObject *)self;
|
||||||
WebPAnimEncoder *enc = encp->enc;
|
WebPAnimEncoder *enc = encp->enc;
|
||||||
|
@ -197,13 +238,9 @@ _anim_encoder_add(PyObject *self, PyObject *args) {
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(
|
if (!PyArg_ParseTuple(
|
||||||
args,
|
args,
|
||||||
"z#iiisiffi",
|
"Oiiffi",
|
||||||
(char **)&rgb,
|
&i0,
|
||||||
&size,
|
|
||||||
×tamp,
|
×tamp,
|
||||||
&width,
|
|
||||||
&height,
|
|
||||||
&mode,
|
|
||||||
&lossless,
|
&lossless,
|
||||||
&quality_factor,
|
&quality_factor,
|
||||||
&alpha_quality_factor,
|
&alpha_quality_factor,
|
||||||
|
@ -213,11 +250,18 @@ _anim_encoder_add(PyObject *self, PyObject *args) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for NULL frame, which sets duration of final frame
|
// Check for NULL frame, which sets duration of final frame
|
||||||
if (!rgb) {
|
if (i0 == Py_None) {
|
||||||
WebPAnimEncoderAdd(enc, NULL, timestamp, NULL);
|
WebPAnimEncoderAdd(enc, NULL, timestamp, NULL);
|
||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!PyCapsule_IsValid(i0, IMAGING_MAGIC)) {
|
||||||
|
PyErr_Format(PyExc_TypeError, "Expected '%s' Capsule", IMAGING_MAGIC);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
im = (Imaging)PyCapsule_GetPointer(i0, IMAGING_MAGIC);
|
||||||
|
|
||||||
// Setup config for this frame
|
// Setup config for this frame
|
||||||
if (!WebPConfigInit(&config)) {
|
if (!WebPConfigInit(&config)) {
|
||||||
PyErr_SetString(PyExc_RuntimeError, "failed to initialize config!");
|
PyErr_SetString(PyExc_RuntimeError, "failed to initialize config!");
|
||||||
|
@ -234,20 +278,15 @@ _anim_encoder_add(PyObject *self, PyObject *args) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Populate the frame with raw bytes passed to us
|
if (import_frame_libwebp(frame, im)) {
|
||||||
frame->width = width;
|
return NULL;
|
||||||
frame->height = height;
|
|
||||||
frame->use_argb = 1; // Don't convert RGB pixels to YUV
|
|
||||||
if (strcmp(mode, "RGBA") == 0) {
|
|
||||||
WebPPictureImportRGBA(frame, rgb, 4 * width);
|
|
||||||
} else if (strcmp(mode, "RGBX") == 0) {
|
|
||||||
WebPPictureImportRGBX(frame, rgb, 4 * width);
|
|
||||||
} else {
|
|
||||||
WebPPictureImportRGB(frame, rgb, 3 * width);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the frame to the encoder
|
ImagingSectionEnter(&cookie);
|
||||||
if (!WebPAnimEncoderAdd(enc, frame, timestamp, &config)) {
|
int ok = WebPAnimEncoderAdd(enc, frame, timestamp, &config);
|
||||||
|
ImagingSectionLeave(&cookie);
|
||||||
|
|
||||||
|
if (!ok) {
|
||||||
PyErr_SetString(PyExc_RuntimeError, WebPAnimEncoderGetError(enc));
|
PyErr_SetString(PyExc_RuntimeError, WebPAnimEncoderGetError(enc));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -572,26 +611,21 @@ static PyTypeObject WebPAnimDecoder_Type = {
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
WebPEncode_wrapper(PyObject *self, PyObject *args) {
|
WebPEncode_wrapper(PyObject *self, PyObject *args) {
|
||||||
int width;
|
|
||||||
int height;
|
|
||||||
int lossless;
|
int lossless;
|
||||||
float quality_factor;
|
float quality_factor;
|
||||||
float alpha_quality_factor;
|
float alpha_quality_factor;
|
||||||
int method;
|
int method;
|
||||||
int exact;
|
int exact;
|
||||||
uint8_t *rgb;
|
Imaging im;
|
||||||
|
PyObject *i0;
|
||||||
uint8_t *icc_bytes;
|
uint8_t *icc_bytes;
|
||||||
uint8_t *exif_bytes;
|
uint8_t *exif_bytes;
|
||||||
uint8_t *xmp_bytes;
|
uint8_t *xmp_bytes;
|
||||||
uint8_t *output;
|
uint8_t *output;
|
||||||
char *mode;
|
|
||||||
Py_ssize_t size;
|
|
||||||
Py_ssize_t icc_size;
|
Py_ssize_t icc_size;
|
||||||
Py_ssize_t exif_size;
|
Py_ssize_t exif_size;
|
||||||
Py_ssize_t xmp_size;
|
Py_ssize_t xmp_size;
|
||||||
size_t ret_size;
|
size_t ret_size;
|
||||||
int rgba_mode;
|
|
||||||
int channels;
|
|
||||||
int ok;
|
int ok;
|
||||||
ImagingSectionCookie cookie;
|
ImagingSectionCookie cookie;
|
||||||
WebPConfig config;
|
WebPConfig config;
|
||||||
|
@ -600,15 +634,11 @@ WebPEncode_wrapper(PyObject *self, PyObject *args) {
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(
|
if (!PyArg_ParseTuple(
|
||||||
args,
|
args,
|
||||||
"y#iiiffss#iis#s#",
|
"Oiffs#iis#s#",
|
||||||
(char **)&rgb,
|
&i0,
|
||||||
&size,
|
|
||||||
&width,
|
|
||||||
&height,
|
|
||||||
&lossless,
|
&lossless,
|
||||||
&quality_factor,
|
&quality_factor,
|
||||||
&alpha_quality_factor,
|
&alpha_quality_factor,
|
||||||
&mode,
|
|
||||||
&icc_bytes,
|
&icc_bytes,
|
||||||
&icc_size,
|
&icc_size,
|
||||||
&method,
|
&method,
|
||||||
|
@ -621,15 +651,12 @@ WebPEncode_wrapper(PyObject *self, PyObject *args) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
rgba_mode = strcmp(mode, "RGBA") == 0;
|
if (!PyCapsule_IsValid(i0, IMAGING_MAGIC)) {
|
||||||
if (!rgba_mode && strcmp(mode, "RGB") != 0) {
|
PyErr_Format(PyExc_TypeError, "Expected '%s' Capsule", IMAGING_MAGIC);
|
||||||
Py_RETURN_NONE;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
channels = rgba_mode ? 4 : 3;
|
im = (Imaging)PyCapsule_GetPointer(i0, IMAGING_MAGIC);
|
||||||
if (size < width * height * channels) {
|
|
||||||
Py_RETURN_NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Setup config for this frame
|
// Setup config for this frame
|
||||||
if (!WebPConfigInit(&config)) {
|
if (!WebPConfigInit(&config)) {
|
||||||
|
@ -652,14 +679,9 @@ WebPEncode_wrapper(PyObject *self, PyObject *args) {
|
||||||
PyErr_SetString(PyExc_ValueError, "could not initialise picture");
|
PyErr_SetString(PyExc_ValueError, "could not initialise picture");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
pic.width = width;
|
|
||||||
pic.height = height;
|
|
||||||
pic.use_argb = 1; // Don't convert RGB pixels to YUV
|
|
||||||
|
|
||||||
if (rgba_mode) {
|
if (import_frame_libwebp(&pic, im)) {
|
||||||
WebPPictureImportRGBA(&pic, rgb, channels * width);
|
return NULL;
|
||||||
} else {
|
|
||||||
WebPPictureImportRGB(&pic, rgb, channels * width);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
WebPMemoryWriterInit(&writer);
|
WebPMemoryWriterInit(&writer);
|
||||||
|
|
|
@ -224,7 +224,7 @@ ImagingFliDecode(Imaging im, ImagingCodecState state, UINT8 *buf, Py_ssize_t byt
|
||||||
break;
|
break;
|
||||||
case 16:
|
case 16:
|
||||||
/* COPY chunk */
|
/* COPY chunk */
|
||||||
if (INT32_MAX / state->xsize < state->ysize) {
|
if (INT32_MAX < (uint64_t)state->xsize * state->ysize) {
|
||||||
/* Integer overflow, bail */
|
/* Integer overflow, bail */
|
||||||
state->errcode = IMAGING_CODEC_OVERRUN;
|
state->errcode = IMAGING_CODEC_OVERRUN;
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -791,15 +791,15 @@ ImagingGenericTransform(
|
||||||
char *out;
|
char *out;
|
||||||
double xx, yy;
|
double xx, yy;
|
||||||
|
|
||||||
|
if (!imOut || !imIn || strcmp(imIn->mode, imOut->mode) != 0) {
|
||||||
|
return (Imaging)ImagingError_ModeError();
|
||||||
|
}
|
||||||
|
|
||||||
ImagingTransformFilter filter = getfilter(imIn, filterid);
|
ImagingTransformFilter filter = getfilter(imIn, filterid);
|
||||||
if (!filter) {
|
if (!filter) {
|
||||||
return (Imaging)ImagingError_ValueError("bad filter number");
|
return (Imaging)ImagingError_ValueError("bad filter number");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!imOut || !imIn || strcmp(imIn->mode, imOut->mode) != 0) {
|
|
||||||
return (Imaging)ImagingError_ModeError();
|
|
||||||
}
|
|
||||||
|
|
||||||
ImagingCopyPalette(imOut, imIn);
|
ImagingCopyPalette(imOut, imIn);
|
||||||
|
|
||||||
ImagingSectionEnter(&cookie);
|
ImagingSectionEnter(&cookie);
|
||||||
|
|
|
@ -460,6 +460,83 @@ ImagingResampleVertical_8bpc(
|
||||||
ImagingSectionLeave(&cookie);
|
ImagingSectionLeave(&cookie);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ImagingResampleHorizontal_16bpc(
|
||||||
|
Imaging imOut, Imaging imIn, int offset, int ksize, int *bounds, double *kk
|
||||||
|
) {
|
||||||
|
ImagingSectionCookie cookie;
|
||||||
|
double ss;
|
||||||
|
int xx, yy, x, xmin, xmax, ss_int;
|
||||||
|
double *k;
|
||||||
|
|
||||||
|
int bigendian = 0;
|
||||||
|
if (strcmp(imIn->mode, "I;16N") == 0
|
||||||
|
#ifdef WORDS_BIGENDIAN
|
||||||
|
|| strcmp(imIn->mode, "I;16B") == 0
|
||||||
|
#endif
|
||||||
|
) {
|
||||||
|
bigendian = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
ImagingSectionEnter(&cookie);
|
||||||
|
for (yy = 0; yy < imOut->ysize; yy++) {
|
||||||
|
for (xx = 0; xx < imOut->xsize; xx++) {
|
||||||
|
xmin = bounds[xx * 2 + 0];
|
||||||
|
xmax = bounds[xx * 2 + 1];
|
||||||
|
k = &kk[xx * ksize];
|
||||||
|
ss = 0.0;
|
||||||
|
for (x = 0; x < xmax; x++) {
|
||||||
|
ss += (imIn->image8[yy + offset][(x + xmin) * 2 + (bigendian ? 1 : 0)] +
|
||||||
|
(imIn->image8[yy + offset][(x + xmin) * 2 + (bigendian ? 0 : 1)]
|
||||||
|
<< 8)) *
|
||||||
|
k[x];
|
||||||
|
}
|
||||||
|
ss_int = ROUND_UP(ss);
|
||||||
|
imOut->image8[yy][xx * 2 + (bigendian ? 1 : 0)] = CLIP8(ss_int % 256);
|
||||||
|
imOut->image8[yy][xx * 2 + (bigendian ? 0 : 1)] = CLIP8(ss_int >> 8);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ImagingSectionLeave(&cookie);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ImagingResampleVertical_16bpc(
|
||||||
|
Imaging imOut, Imaging imIn, int offset, int ksize, int *bounds, double *kk
|
||||||
|
) {
|
||||||
|
ImagingSectionCookie cookie;
|
||||||
|
double ss;
|
||||||
|
int xx, yy, y, ymin, ymax, ss_int;
|
||||||
|
double *k;
|
||||||
|
|
||||||
|
int bigendian = 0;
|
||||||
|
if (strcmp(imIn->mode, "I;16N") == 0
|
||||||
|
#ifdef WORDS_BIGENDIAN
|
||||||
|
|| strcmp(imIn->mode, "I;16B") == 0
|
||||||
|
#endif
|
||||||
|
) {
|
||||||
|
bigendian = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
ImagingSectionEnter(&cookie);
|
||||||
|
for (yy = 0; yy < imOut->ysize; yy++) {
|
||||||
|
ymin = bounds[yy * 2 + 0];
|
||||||
|
ymax = bounds[yy * 2 + 1];
|
||||||
|
k = &kk[yy * ksize];
|
||||||
|
for (xx = 0; xx < imOut->xsize; xx++) {
|
||||||
|
ss = 0.0;
|
||||||
|
for (y = 0; y < ymax; y++) {
|
||||||
|
ss += (imIn->image8[y + ymin][xx * 2 + (bigendian ? 1 : 0)] +
|
||||||
|
(imIn->image8[y + ymin][xx * 2 + (bigendian ? 0 : 1)] << 8)) *
|
||||||
|
k[y];
|
||||||
|
}
|
||||||
|
ss_int = ROUND_UP(ss);
|
||||||
|
imOut->image8[yy][xx * 2 + (bigendian ? 1 : 0)] = CLIP8(ss_int % 256);
|
||||||
|
imOut->image8[yy][xx * 2 + (bigendian ? 0 : 1)] = CLIP8(ss_int >> 8);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ImagingSectionLeave(&cookie);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ImagingResampleHorizontal_32bpc(
|
ImagingResampleHorizontal_32bpc(
|
||||||
Imaging imOut, Imaging imIn, int offset, int ksize, int *bounds, double *kk
|
Imaging imOut, Imaging imIn, int offset, int ksize, int *bounds, double *kk
|
||||||
|
@ -574,7 +651,12 @@ ImagingResample(Imaging imIn, int xsize, int ysize, int filter, float box[4]) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (imIn->type == IMAGING_TYPE_SPECIAL) {
|
if (imIn->type == IMAGING_TYPE_SPECIAL) {
|
||||||
return (Imaging)ImagingError_ModeError();
|
if (strncmp(imIn->mode, "I;16", 4) == 0) {
|
||||||
|
ResampleHorizontal = ImagingResampleHorizontal_16bpc;
|
||||||
|
ResampleVertical = ImagingResampleVertical_16bpc;
|
||||||
|
} else {
|
||||||
|
return (Imaging)ImagingError_ModeError();
|
||||||
|
}
|
||||||
} else if (imIn->image8) {
|
} else if (imIn->image8) {
|
||||||
ResampleHorizontal = ImagingResampleHorizontal_8bpc;
|
ResampleHorizontal = ImagingResampleHorizontal_8bpc;
|
||||||
ResampleVertical = ImagingResampleVertical_8bpc;
|
ResampleVertical = ImagingResampleVertical_8bpc;
|
||||||
|
|
|
@ -183,7 +183,7 @@ ImagingSgiRleDecode(Imaging im, ImagingCodecState state, UINT8 *buf, Py_ssize_t
|
||||||
each with 4 bytes per element of tablen
|
each with 4 bytes per element of tablen
|
||||||
Check here before we allocate any memory
|
Check here before we allocate any memory
|
||||||
*/
|
*/
|
||||||
if (c->bufsize < 8 * c->tablen) {
|
if (c->bufsize < 8 * (int64_t)c->tablen) {
|
||||||
state->errcode = IMAGING_CODEC_OVERRUN;
|
state->errcode = IMAGING_CODEC_OVERRUN;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -195,6 +195,7 @@ ImagingSgiRleDecode(Imaging im, ImagingCodecState state, UINT8 *buf, Py_ssize_t
|
||||||
}
|
}
|
||||||
_imaging_seek_pyFd(state->fd, SGI_HEADER_SIZE, SEEK_SET);
|
_imaging_seek_pyFd(state->fd, SGI_HEADER_SIZE, SEEK_SET);
|
||||||
if (_imaging_read_pyFd(state->fd, (char *)ptr, c->bufsize) != c->bufsize) {
|
if (_imaging_read_pyFd(state->fd, (char *)ptr, c->bufsize) != c->bufsize) {
|
||||||
|
free(ptr);
|
||||||
state->errcode = IMAGING_CODEC_UNKNOWN;
|
state->errcode = IMAGING_CODEC_UNKNOWN;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,6 +44,7 @@ PyImaging_GetBuffer(PyObject *buffer, Py_buffer *view);
|
||||||
typedef struct {
|
typedef struct {
|
||||||
PyObject_HEAD Py_ssize_t count;
|
PyObject_HEAD Py_ssize_t count;
|
||||||
double *xy;
|
double *xy;
|
||||||
|
int mapping;
|
||||||
} PyPathObject;
|
} PyPathObject;
|
||||||
|
|
||||||
static PyTypeObject PyPathType;
|
static PyTypeObject PyPathType;
|
||||||
|
@ -91,6 +92,7 @@ path_new(Py_ssize_t count, double *xy, int duplicate) {
|
||||||
|
|
||||||
path->count = count;
|
path->count = count;
|
||||||
path->xy = xy;
|
path->xy = xy;
|
||||||
|
path->mapping = 0;
|
||||||
|
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
@ -276,6 +278,10 @@ path_compact(PyPathObject *self, PyObject *args) {
|
||||||
|
|
||||||
double cityblock = 2.0;
|
double cityblock = 2.0;
|
||||||
|
|
||||||
|
if (self->mapping) {
|
||||||
|
PyErr_SetString(PyExc_ValueError, "Path compacted during mapping");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
if (!PyArg_ParseTuple(args, "|d:compact", &cityblock)) {
|
if (!PyArg_ParseTuple(args, "|d:compact", &cityblock)) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -393,11 +399,13 @@ path_map(PyPathObject *self, PyObject *args) {
|
||||||
xy = self->xy;
|
xy = self->xy;
|
||||||
|
|
||||||
/* apply function to coordinate set */
|
/* apply function to coordinate set */
|
||||||
|
self->mapping = 1;
|
||||||
for (i = 0; i < self->count; i++) {
|
for (i = 0; i < self->count; i++) {
|
||||||
double x = xy[i + i];
|
double x = xy[i + i];
|
||||||
double y = xy[i + i + 1];
|
double y = xy[i + i + 1];
|
||||||
PyObject *item = PyObject_CallFunction(function, "dd", x, y);
|
PyObject *item = PyObject_CallFunction(function, "dd", x, y);
|
||||||
if (!item || !PyArg_ParseTuple(item, "dd", &x, &y)) {
|
if (!item || !PyArg_ParseTuple(item, "dd", &x, &y)) {
|
||||||
|
self->mapping = 0;
|
||||||
Py_XDECREF(item);
|
Py_XDECREF(item);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -405,6 +413,7 @@ path_map(PyPathObject *self, PyObject *args) {
|
||||||
xy[i + i + 1] = y;
|
xy[i + i + 1] = y;
|
||||||
Py_DECREF(item);
|
Py_DECREF(item);
|
||||||
}
|
}
|
||||||
|
self->mapping = 0;
|
||||||
|
|
||||||
Py_INCREF(Py_None);
|
Py_INCREF(Py_None);
|
||||||
return Py_None;
|
return Py_None;
|
||||||
|
|
|
@ -11,7 +11,7 @@ For more extensive info, see the [Windows build instructions](build.rst).
|
||||||
* Requires Microsoft Visual Studio 2017 or newer with C++ component.
|
* Requires Microsoft Visual Studio 2017 or newer with C++ component.
|
||||||
* Requires NASM for libjpeg-turbo, a required dependency when using this script.
|
* Requires NASM for libjpeg-turbo, a required dependency when using this script.
|
||||||
* Requires CMake 3.15 or newer (available as Visual Studio component).
|
* Requires CMake 3.15 or newer (available as Visual Studio component).
|
||||||
* Tested on Windows Server 2016 with Visual Studio 2017 Community, and Windows Server 2019 with Visual Studio 2022 Community (AppVeyor).
|
* Tested on Windows Server 2019 with Visual Studio 2019 Community and Visual Studio 2022 Community (AppVeyor).
|
||||||
* Tested on Windows Server 2022 with Visual Studio 2022 Enterprise (GitHub Actions).
|
* Tested on Windows Server 2022 with Visual Studio 2022 Enterprise (GitHub Actions).
|
||||||
|
|
||||||
The following is a simplified version of the script used on AppVeyor:
|
The following is a simplified version of the script used on AppVeyor:
|
||||||
|
|
|
@ -111,7 +111,7 @@ ARCHITECTURES = {
|
||||||
V = {
|
V = {
|
||||||
"BROTLI": "1.1.0",
|
"BROTLI": "1.1.0",
|
||||||
"FREETYPE": "2.13.3",
|
"FREETYPE": "2.13.3",
|
||||||
"FRIBIDI": "1.0.15",
|
"FRIBIDI": "1.0.16",
|
||||||
"HARFBUZZ": "10.0.1",
|
"HARFBUZZ": "10.0.1",
|
||||||
"JPEGTURBO": "3.0.4",
|
"JPEGTURBO": "3.0.4",
|
||||||
"LCMS2": "2.16",
|
"LCMS2": "2.16",
|
||||||
|
@ -119,7 +119,7 @@ V = {
|
||||||
"LIBWEBP": "1.4.0",
|
"LIBWEBP": "1.4.0",
|
||||||
"OPENJPEG": "2.5.2",
|
"OPENJPEG": "2.5.2",
|
||||||
"TIFF": "4.6.0",
|
"TIFF": "4.6.0",
|
||||||
"XZ": "5.6.2",
|
"XZ": "5.6.3",
|
||||||
"ZLIB": "1.3.1",
|
"ZLIB": "1.3.1",
|
||||||
}
|
}
|
||||||
V["LIBPNG_DOTLESS"] = V["LIBPNG"].replace(".", "")
|
V["LIBPNG_DOTLESS"] = V["LIBPNG"].replace(".", "")
|
||||||
|
@ -185,7 +185,7 @@ DEPS: dict[str, dict[str, Any]] = {
|
||||||
cmd_copy(r"src\liblzma\api\lzma\*.h", r"{inc_dir}\lzma"),
|
cmd_copy(r"src\liblzma\api\lzma\*.h", r"{inc_dir}\lzma"),
|
||||||
],
|
],
|
||||||
"headers": [r"src\liblzma\api\lzma.h"],
|
"headers": [r"src\liblzma\api\lzma.h"],
|
||||||
"libs": [r"liblzma.lib"],
|
"libs": [r"lzma.lib"],
|
||||||
},
|
},
|
||||||
"libwebp": {
|
"libwebp": {
|
||||||
"url": f"http://downloads.webmproject.org/releases/webp/libwebp-{V['LIBWEBP']}.tar.gz",
|
"url": f"http://downloads.webmproject.org/releases/webp/libwebp-{V['LIBWEBP']}.tar.gz",
|
||||||
|
@ -216,8 +216,8 @@ DEPS: dict[str, dict[str, Any]] = {
|
||||||
"license": "LICENSE.md",
|
"license": "LICENSE.md",
|
||||||
"patch": {
|
"patch": {
|
||||||
r"libtiff\tif_lzma.c": {
|
r"libtiff\tif_lzma.c": {
|
||||||
# link against liblzma.lib
|
# link against lzma.lib
|
||||||
"#ifdef LZMA_SUPPORT": '#ifdef LZMA_SUPPORT\n#pragma comment(lib, "liblzma.lib")', # noqa: E501
|
"#ifdef LZMA_SUPPORT": '#ifdef LZMA_SUPPORT\n#pragma comment(lib, "lzma.lib")', # noqa: E501
|
||||||
},
|
},
|
||||||
r"libtiff\tif_webp.c": {
|
r"libtiff\tif_webp.c": {
|
||||||
# link against libwebp.lib
|
# link against libwebp.lib
|
||||||
|
|