Skip to content

Commit

Permalink
Merge branch 'main' into context_manager
Browse files Browse the repository at this point in the history
  • Loading branch information
radarhere committed Sep 25, 2024
2 parents 6af0425 + 5d16eb7 commit 956dd77
Show file tree
Hide file tree
Showing 17 changed files with 91 additions and 29 deletions.
9 changes: 4 additions & 5 deletions .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ install:
- xcopy /S /Y c:\test-images-main\* c:\pillow\tests\images
- curl -fsSL -o nasm-win64.zip https://raw.githubusercontent.com/python-pillow/pillow-depends/main/nasm-2.16.03-win64.zip
- 7z x nasm-win64.zip -oc:\
- choco install ghostscript --version=10.3.1
- path c:\nasm-2.16.03;C:\Program Files\gs\gs10.03.1\bin;%PATH%
- choco install ghostscript --version=10.4.0
- path c:\nasm-2.16.03;C:\Program Files\gs\gs10.04.0\bin;%PATH%
- cd c:\pillow\winbuild\
- ps: |
c:\python39\python.exe c:\pillow\winbuild\build_prepare.py -v --depends=C:\pillow-depends\
Expand All @@ -53,9 +53,8 @@ test_script:
- cd c:\pillow
- '%PYTHON%\%EXECUTABLE% -m pip install pytest pytest-cov pytest-timeout defusedxml ipython numpy olefile pyroma'
- c:\"Program Files (x86)"\"Windows Kits"\10\Debuggers\x86\gflags.exe /p /enable %PYTHON%\%EXECUTABLE%
- '%PYTHON%\%EXECUTABLE% -c "from PIL import Image"'
- '%PYTHON%\%EXECUTABLE% -m pytest -vx --cov PIL --cov Tests --cov-report term --cov-report xml Tests'
#- '%PYTHON%\%EXECUTABLE% test-installed.py -v -s %TEST_OPTIONS%' TODO TEST_OPTIONS with pytest?
- path %PYTHON%;%PATH%
- .ci\test.cmd

after_test:
- curl -Os https://uploader.codecov.io/latest/windows/codecov.exe
Expand Down
3 changes: 3 additions & 0 deletions .ci/test.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
python.exe -c "from PIL import Image"
IF ERRORLEVEL 1 EXIT /B
python.exe -bb -m pytest -v -x -W always --cov PIL --cov Tests --cov-report term --cov-report xml Tests
2 changes: 1 addition & 1 deletion .ci/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ set -e

python3 -c "from PIL import Image"

python3 -bb -m pytest -v -x -W always --cov PIL --cov Tests --cov-report term Tests $REVERSE
python3 -bb -m pytest -v -x -W always --cov PIL --cov Tests --cov-report term --cov-report xml Tests $REVERSE
3 changes: 1 addition & 2 deletions .github/workflows/test-mingw.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@ jobs:
- name: Test Pillow
run: |
python3 selftest.py --installed
python3 -c "from PIL import Image"
python3 -m pytest -vx --cov PIL --cov Tests --cov-report term --cov-report xml Tests
.ci/test.sh
- name: Upload coverage
uses: codecov/codecov-action@v4
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/test-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ jobs:
choco install nasm --no-progress
echo "C:\Program Files\NASM" >> $env:GITHUB_PATH
choco install ghostscript --version=10.3.1 --no-progress
echo "C:\Program Files\gs\gs10.03.1\bin" >> $env:GITHUB_PATH
choco install ghostscript --version=10.4.0 --no-progress
echo "C:\Program Files\gs\gs10.04.0\bin" >> $env:GITHUB_PATH
# Install extra test images
xcopy /S /Y Tests\test-images\* Tests\images
Expand Down Expand Up @@ -190,8 +190,8 @@ jobs:
- name: Test Pillow
run: |
path %GITHUB_WORKSPACE%\\winbuild\\build\\bin;%PATH%
python.exe -m pytest -vx -W always --cov PIL --cov Tests --cov-report term --cov-report xml Tests
path %GITHUB_WORKSPACE%\winbuild\build\bin;%PATH%
.ci\test.cmd
shell: cmd

- name: Prepare to upload errors
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/wheels-dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ ARCHIVE_SDIR=pillow-depends-main
# Package versions for fresh source builds
FREETYPE_VERSION=2.13.2
if [[ "$MB_ML_VER" != 2014 ]]; then
HARFBUZZ_VERSION=9.0.0
HARFBUZZ_VERSION=10.0.1
else
HARFBUZZ_VERSION=8.5.0
fi
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,18 @@ jobs:
- name: "macOS 10.10 x86_64"
os: macos-13
cibw_arch: x86_64
build: "pp310* cp3{9,10,11}*"
build: "cp3{9,10,11}*"
macosx_deployment_target: "10.10"
- name: "macOS 10.13 x86_64"
os: macos-13
cibw_arch: x86_64
build: "cp3{12,13}*"
macosx_deployment_target: "10.13"
- name: "macOS 10.15 x86_64"
os: macos-13
cibw_arch: x86_64
build: "pp310*"
macosx_deployment_target: "10.15"
- name: "macOS arm64"
os: macos-latest
cibw_arch: arm64
Expand Down
21 changes: 21 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,27 @@ Changelog (Pillow)
11.0.0 (unreleased)
-------------------

- Fixed writing multiple StripOffsets to TIFF #8317
[Yay295, radarhere]

- Shared imagequant libraries may be located within usr/lib64 #8407
[radarhere]

- Fix dereference before checking for NULL in ImagingTransformAffine #8398
[PavlNekrasov]

- Use transposed size after opening for TIFF images #8390
[radarhere, homm]

- Improve ImageFont error messages #8338
[yngvem, radarhere, hugovk]

- Mention MAX_TEXT_CHUNK limit in PNG error message #8391
[radarhere]

- Cast Dib handle to int #8385
[radarhere]

- Accept float stroke widths #8369
[radarhere]

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ As of 2019, Pillow development is
<a href="https://app.codecov.io/gh/python-pillow/Pillow"><img
alt="Code coverage"
src="https://codecov.io/gh/python-pillow/Pillow/branch/main/graph/badge.svg"></a>
<a href="https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&can=1&q=proj:pillow"><img
<a href="https://issues.oss-fuzz.com/issues?q=title:pillow"><img
alt="Fuzzing Status"
src="https://oss-fuzz-build-logs.storage.googleapis.com/badges/pillow.svg"></a>
</td>
Expand Down
3 changes: 2 additions & 1 deletion Tests/test_file_tiff.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ def test_bigtiff(self, tmp_path: Path) -> None:
with Image.open("Tests/images/hopper_bigtiff.tif") as im:
assert isinstance(im, TiffImagePlugin.TiffImageFile)

# multistrip support not yet implemented
# The data type of this file's StripOffsets tag is LONG8,
# which is not yet supported for offset data when saving multiple frames.
del im.tag_v2[273]

outfile = str(tmp_path / "temp.tif")
Expand Down
23 changes: 23 additions & 0 deletions Tests/test_file_tiff_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,29 @@ def test_change_stripbytecounts_tag_type(tmp_path: Path) -> None:
assert reloaded.tag_v2.tagtype[TiffImagePlugin.STRIPBYTECOUNTS] == TiffTags.LONG


def test_save_multiple_stripoffsets() -> None:
ifd = TiffImagePlugin.ImageFileDirectory_v2()
ifd[TiffImagePlugin.STRIPOFFSETS] = (123, 456)
assert ifd.tagtype[TiffImagePlugin.STRIPOFFSETS] == TiffTags.LONG

# all values are in little-endian
assert ifd.tobytes() == (
# number of tags == 1
b"\x01\x00"
# tag id (2 bytes), type (2 bytes), count (4 bytes), value (4 bytes)
# TiffImagePlugin.STRIPOFFSETS, TiffTags.LONG, 2, 18
# where STRIPOFFSETS is 273, LONG is 4
# and 18 is the offset of the tag data
b"\x11\x01\x04\x00\x02\x00\x00\x00\x12\x00\x00\x00"
# end of entries
b"\x00\x00\x00\x00"
# 26 is the total number of bytes output,
# the offset for any auxiliary strip data that will then be appended
# (123 + 26, 456 + 26) == (149, 482)
b"\x95\x00\x00\x00\xe2\x01\x00\x00"
)


def test_no_duplicate_50741_tag() -> None:
assert TAG_IDS["MakerNoteSafety"] == 50741
assert TAG_IDS["BestQualityScale"] == 50780
Expand Down
7 changes: 6 additions & 1 deletion depends/install_imagequant.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ else
cargo cinstall --prefix=/usr --destdir=.

# Copy into place
sudo cp usr/lib/libimagequant.so* /usr/lib/
if [ -d "usr/lib64" ]; then
lib="lib64"
else
lib="lib"
fi
sudo cp usr/$lib/libimagequant.so* /usr/lib/
sudo cp usr/include/libimagequant.h /usr/include/

if [ -n "$GITHUB_ACTIONS" ]; then
Expand Down
2 changes: 1 addition & 1 deletion depends/install_raqm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# install raqm


archive=libraqm-0.10.1
archive=libraqm-0.10.2

./download-and-extract.sh $archive https://raw.githubusercontent.com/python-pillow/pillow-depends/main/$archive.tar.gz

Expand Down
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Pillow for enterprise is available via the Tidelift Subscription. `Learn more <h
:alt: Tidelift

.. image:: https://oss-fuzz-build-logs.storage.googleapis.com/badges/pillow.svg
:target: https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&can=1&q=proj:pillow
:target: https://issues.oss-fuzz.com/issues?q=title:pillow
:alt: Fuzzing Status

.. image:: https://img.shields.io/pypi/v/pillow.svg
Expand Down
8 changes: 5 additions & 3 deletions src/PIL/TiffImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -991,9 +991,11 @@ def tobytes(self, offset: int = 0) -> bytes:
if stripoffsets is not None:
tag, typ, count, value, data = entries[stripoffsets]
if data:
msg = "multistrip support not yet implemented"
raise NotImplementedError(msg)
value = self._pack("L", self._unpack("L", value)[0] + offset)
size, handler = self._load_dispatch[typ]
values = [val + offset for val in handler(self, data, self.legacy_api)]
data = self._write_dispatch[typ](self, *values)
else:
value = self._pack("L", self._unpack("L", value)[0] + offset)
entries[stripoffsets] = tag, typ, count, value, data

# pass 2: write entries to file
Expand Down
8 changes: 4 additions & 4 deletions src/libImaging/Geometry.c
Original file line number Diff line number Diff line change
Expand Up @@ -1035,6 +1035,10 @@ ImagingTransformAffine(
double xx, yy;
double xo, yo;

if (!imOut || !imIn || strcmp(imIn->mode, imOut->mode) != 0) {
return (Imaging)ImagingError_ModeError();
}

if (filterid || imIn->type == IMAGING_TYPE_SPECIAL) {
return ImagingGenericTransform(
imOut, imIn, x0, y0, x1, y1, affine_transform, a, filterid, fill
Expand All @@ -1046,10 +1050,6 @@ ImagingTransformAffine(
return ImagingScaleAffine(imOut, imIn, x0, y0, x1, y1, a, fill);
}

if (!imOut || !imIn || strcmp(imIn->mode, imOut->mode) != 0) {
return (Imaging)ImagingError_ModeError();
}

if (x0 < 0) {
x0 = 0;
}
Expand Down
10 changes: 7 additions & 3 deletions winbuild/build_prepare.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def cmd_msbuild(
"BROTLI": "1.1.0",
"FREETYPE": "2.13.3",
"FRIBIDI": "1.0.15",
"HARFBUZZ": "9.0.0",
"HARFBUZZ": "10.0.1",
"JPEGTURBO": "3.0.4",
"LCMS2": "2.16",
"LIBPNG": "1.6.44",
Expand Down Expand Up @@ -292,8 +292,12 @@ def cmd_msbuild(
},
"build": [
cmd_rmdir("objs"),
cmd_msbuild("MSBuild.sln", "Release Static", "Clean"),
cmd_msbuild("MSBuild.sln", "Release Static", "Build"),
cmd_msbuild(
r"builds\windows\vc2010\freetype.vcxproj", "Release Static", "Clean"
),
cmd_msbuild(
r"builds\windows\vc2010\freetype.vcxproj", "Release Static", "Build"
),
cmd_xcopy("include", "{inc_dir}"),
],
"libs": [r"objs\{msbuild_arch}\Release Static\freetype.lib"],
Expand Down

0 comments on commit 956dd77

Please sign in to comment.