diff --git a/.ci/after_success.sh b/.ci/after_success.sh index 53832c573..23a6fcd4d 100755 --- a/.ci/after_success.sh +++ b/.ci/after_success.sh @@ -3,7 +3,7 @@ # gather the coverage data python3 -m pip install codecov if [[ $MATRIX_DOCKER ]]; then - coverage xml --ignore-errors + python3 -m coverage xml --ignore-errors else - coverage xml + python3 -m coverage xml fi diff --git a/.ci/build.sh b/.ci/build.sh index a2e3041bd..e678f68ec 100755 --- a/.ci/build.sh +++ b/.ci/build.sh @@ -2,7 +2,7 @@ set -e -coverage erase +python3 -m coverage erase if [ $(uname) == "Darwin" ]; then export CPPFLAGS="-I/usr/local/miniconda/include"; fi diff --git a/.ci/install.sh b/.ci/install.sh index 028d68795..518b66acc 100755 --- a/.ci/install.sh +++ b/.ci/install.sh @@ -13,13 +13,17 @@ aptget_update() return 1 fi } -aptget_update || aptget_update retry || aptget_update retry +if [[ $(uname) != CYGWIN* ]]; then + aptget_update || aptget_update retry || aptget_update retry +fi set -e -sudo apt-get -qq install libfreetype6-dev liblcms2-dev python3-tk\ - ghostscript libffi-dev libjpeg-turbo-progs libopenjp2-7-dev\ - cmake meson imagemagick libharfbuzz-dev libfribidi-dev +if [[ $(uname) != CYGWIN* ]]; then + sudo apt-get -qq install libfreetype6-dev liblcms2-dev python3-tk\ + ghostscript libffi-dev libjpeg-turbo-progs libopenjp2-7-dev\ + cmake meson imagemagick libharfbuzz-dev libfribidi-dev +fi python3 -m pip install --upgrade pip python3 -m pip install --upgrade wheel @@ -31,24 +35,27 @@ python3 -m pip install -U pytest python3 -m pip install -U pytest-cov python3 -m pip install -U pytest-timeout python3 -m pip install pyroma -python3 -m pip install test-image-results -# TODO Remove condition when NumPy supports 3.11 -if ! [ "$GHA_PYTHON_VERSION" == "3.11-dev" ]; then python3 -m pip install numpy ; fi -# PyQt6 doesn't support PyPy3 -if [[ $GHA_PYTHON_VERSION == 3.* ]]; then - sudo apt-get -qq install libegl1 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxkbcommon-x11-0 - python3 -m pip install pyqt6 +if [[ $(uname) != CYGWIN* ]]; then + python3 -m pip install numpy + + # PyQt6 doesn't support PyPy3 + if [[ $GHA_PYTHON_VERSION == 3.* ]]; then + sudo apt-get -qq install libegl1 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-shape0 libxkbcommon-x11-0 + python3 -m pip install pyqt6 + fi + + # webp + pushd depends && ./install_webp.sh && popd + + # libimagequant + pushd depends && ./install_imagequant.sh && popd + + # raqm + pushd depends && ./install_raqm.sh && popd + + # extra test images + pushd depends && ./install_extra_test_images.sh && popd +else + cd depends && ./install_extra_test_images.sh && cd .. fi - -# webp -pushd depends && ./install_webp.sh && popd - -# libimagequant -pushd depends && ./install_imagequant.sh && popd - -# raqm -pushd depends && ./install_raqm.sh && popd - -# extra test images -pushd depends && ./install_extra_test_images.sh && popd diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index bc9587744..ba2b7d8ed 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -4,7 +4,7 @@ Bug fixes, feature additions, tests, documentation and more can be contributed v ## Bug fixes, feature additions, etc. -Please send a pull request to the `main` branch. Please include [documentation](https://pillow.readthedocs.io) and [tests](../Tests/README.rst) for new features. Tests or documentation without bug fixes or feature additions are welcome too. Feel free to ask questions [via issues](https://github.com/python-pillow/Pillow/issues/new), [Gitter](https://gitter.im/python-pillow/Pillow) or irc://irc.freenode.net#pil +Please send a pull request to the `main` branch. Please include [documentation](https://pillow.readthedocs.io) and [tests](../Tests/README.rst) for new features. Tests or documentation without bug fixes or feature additions are welcome too. Feel free to ask questions [via issues](https://github.com/python-pillow/Pillow/issues/new), [discussions](https://github.com/python-pillow/Pillow/discussions/new), [Gitter](https://gitter.im/python-pillow/Pillow) or irc://irc.freenode.net#pil - Fork the Pillow repository. - Create a branch from `main`. diff --git a/.github/mergify.yml b/.github/mergify.yml index 8b289bda6..8dfa07f4e 100644 --- a/.github/mergify.yml +++ b/.github/mergify.yml @@ -8,6 +8,7 @@ pull_request_rules: - status-success=Docker Test Successful - status-success=Windows Test Successful - status-success=MinGW Test Successful + - status-success=Cygwin Test Successful - status-success=continuous-integration/appveyor/pr actions: merge: diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 4540fb5af..527f26d35 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -2,6 +2,9 @@ name: Lint on: [push, pull_request, workflow_dispatch] +permissions: + contents: read + jobs: build: diff --git a/.github/workflows/macos-install.sh b/.github/workflows/macos-install.sh index 06b829645..65f2b81d5 100755 --- a/.github/workflows/macos-install.sh +++ b/.github/workflows/macos-install.sh @@ -12,11 +12,9 @@ python3 -m pip install -U pytest python3 -m pip install -U pytest-cov python3 -m pip install -U pytest-timeout python3 -m pip install pyroma -python3 -m pip install test-image-results echo -e "[openblas]\nlibraries = openblas\nlibrary_dirs = /usr/local/opt/openblas/lib" >> ~/.numpy-site.cfg -# TODO Remove condition when NumPy supports 3.11 -if ! [ "$GHA_PYTHON_VERSION" == "3.11-dev" ]; then python3 -m pip install numpy ; fi +python3 -m pip install numpy # extra test images pushd depends && ./install_extra_test_images.sh && popd diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml index ad66117b1..7ee76c4ac 100644 --- a/.github/workflows/release-drafter.yml +++ b/.github/workflows/release-drafter.yml @@ -7,8 +7,14 @@ on: - main workflow_dispatch: +permissions: + contents: read + jobs: update_release_draft: + permissions: + contents: write # for release-drafter/release-drafter to create a github release + pull-requests: write # for release-drafter/release-drafter to add label to PR if: github.repository == 'python-pillow/Pillow' runs-on: ubuntu-latest steps: diff --git a/.github/workflows/test-cygwin.yml b/.github/workflows/test-cygwin.yml new file mode 100644 index 000000000..417b1f212 --- /dev/null +++ b/.github/workflows/test-cygwin.yml @@ -0,0 +1,109 @@ +name: Test Cygwin + +on: [push, pull_request, workflow_dispatch] + +jobs: + build: + runs-on: windows-latest + strategy: + fail-fast: false + matrix: + python-minor-version: [7, 8, 9] + + timeout-minutes: 40 + + name: Python 3.${{ matrix.python-minor-version }} + + steps: + - name: Fix line endings + run: | + git config --global core.autocrlf input + + - name: Checkout Pillow + uses: actions/checkout@v3 + + - name: Install Cygwin + uses: cygwin/cygwin-install-action@v2 + with: + platform: x86_64 + packages: > + ImageMagick gcc-g++ ghostscript jpeg libfreetype-devel + libimagequant-devel libjpeg-devel liblapack-devel + liblcms2-devel libopenjp2-devel libraqm-devel + libtiff-devel libwebp-devel libxcb-devel libxcb-xinerama0 + make netpbm perl + python3${{ matrix.python-minor-version }}-cffi + python3${{ matrix.python-minor-version }}-cython + python3${{ matrix.python-minor-version }}-devel + python3${{ matrix.python-minor-version }}-numpy + python3${{ matrix.python-minor-version }}-sip + python3${{ matrix.python-minor-version }}-tkinter + qt5-devel-tools subversion xorg-server-extra zlib-devel + + - name: Add Lapack to PATH + uses: egor-tensin/cleanup-path@v1 + with: + dirs: 'C:\cygwin\bin;C:\cygwin\lib\lapack' + + - name: pip cache + uses: actions/cache@v3 + with: + path: 'C:\cygwin\home\runneradmin\.cache\pip' + key: ${{ runner.os }}-cygwin-pip3.${{ matrix.python-minor-version }}-${{ hashFiles('.ci/install.sh') }} + restore-keys: | + ${{ runner.os }}-cygwin-pip3.${{ matrix.python-minor-version }}- + + - name: Build system information + run: | + dash.exe -c "python3 .github/workflows/system-info.py" + + - name: Install dependencies + run: | + bash.exe .ci/install.sh + + - name: Install a different NumPy + shell: dash.exe -l "{0}" + run: | + python3 -m pip install -U 'numpy!=1.21.*' + + - name: Build + shell: bash.exe -eo pipefail -o igncr "{0}" + run: | + .ci/build.sh + + - name: Test + run: | + bash.exe xvfb-run -s '-screen 0 1024x768x24' .ci/test.sh + + - name: Prepare to upload errors + if: failure() + run: | + dash.exe -c "mkdir -p Tests/errors" + + - name: Upload errors + uses: actions/upload-artifact@v3 + if: failure() + with: + name: errors + path: Tests/errors + + - name: After success + run: | + bash.exe .ci/after_success.sh + + - name: Upload coverage + uses: codecov/codecov-action@v3 + with: + file: ./coverage.xml + flags: GHA_Cygwin + name: Cygwin Python 3.${{ matrix.python-minor-version }} + + success: + permissions: + contents: none + needs: build + runs-on: ubuntu-latest + name: Cygwin Test Successful + steps: + - name: Success + run: echo Cygwin Test Successful diff --git a/.github/workflows/test-docker.yml b/.github/workflows/test-docker.yml index 7cd892219..5376791e9 100644 --- a/.github/workflows/test-docker.yml +++ b/.github/workflows/test-docker.yml @@ -2,6 +2,9 @@ name: Test Docker on: [push, pull_request, workflow_dispatch] +permissions: + contents: read + jobs: build: @@ -11,9 +14,9 @@ jobs: matrix: docker: [ # Run slower jobs first to give them a headstart and reduce waiting time - ubuntu-20.04-focal-arm64v8, - ubuntu-20.04-focal-ppc64le, - ubuntu-20.04-focal-s390x, + ubuntu-22.04-jammy-arm64v8, + ubuntu-22.04-jammy-ppc64le, + ubuntu-22.04-jammy-s390x, # Then run the remainder alpine, amazon-2-amd64, @@ -24,6 +27,7 @@ jobs: debian-10-buster-x86, debian-11-bullseye-x86, fedora-35-amd64, + fedora-36-amd64, gentoo, ubuntu-18.04-bionic-amd64, ubuntu-20.04-focal-amd64, @@ -31,11 +35,11 @@ jobs: ] dockerTag: [main] include: - - docker: "ubuntu-20.04-focal-arm64v8" + - docker: "ubuntu-22.04-jammy-arm64v8" qemu-arch: "aarch64" - - docker: "ubuntu-20.04-focal-ppc64le" + - docker: "ubuntu-22.04-jammy-ppc64le" qemu-arch: "ppc64le" - - docker: "ubuntu-20.04-focal-s390x" + - docker: "ubuntu-22.04-jammy-s390x" qemu-arch: "s390x" name: ${{ matrix.docker }} @@ -81,6 +85,8 @@ jobs: name: ${{ matrix.docker }} success: + permissions: + contents: none needs: build runs-on: ubuntu-latest name: Docker Test Successful diff --git a/.github/workflows/test-mingw.yml b/.github/workflows/test-mingw.yml index 7b5cc8a97..7ddb71e1f 100644 --- a/.github/workflows/test-mingw.yml +++ b/.github/workflows/test-mingw.yml @@ -2,6 +2,9 @@ name: Test MinGW on: [push, pull_request, workflow_dispatch] +permissions: + contents: read + jobs: build: runs-on: windows-latest @@ -77,6 +80,8 @@ jobs: CODECOV_NAME: ${{ matrix.name }} success: + permissions: + contents: none needs: build runs-on: ubuntu-latest name: MinGW Test Successful diff --git a/.github/workflows/test-valgrind.yml b/.github/workflows/test-valgrind.yml index 21a2b469e..dda1b3577 100644 --- a/.github/workflows/test-valgrind.yml +++ b/.github/workflows/test-valgrind.yml @@ -13,6 +13,9 @@ on: - "**.h" workflow_dispatch: +permissions: + contents: read + jobs: build: @@ -21,7 +24,7 @@ jobs: fail-fast: false matrix: docker: [ - ubuntu-20.04-focal-amd64-valgrind, + ubuntu-22.04-jammy-amd64-valgrind, ] dockerTag: [main] diff --git a/.github/workflows/test-windows.yml b/.github/workflows/test-windows.yml index c2456d218..ca608e127 100644 --- a/.github/workflows/test-windows.yml +++ b/.github/workflows/test-windows.yml @@ -2,6 +2,9 @@ name: Test Windows on: [push, pull_request, workflow_dispatch] +permissions: + contents: read + jobs: build: runs-on: windows-latest @@ -41,10 +44,10 @@ jobs: cache-dependency-path: ".github/workflows/test-windows.yml" - name: Print build system information - run: python .github/workflows/system-info.py + run: python3 .github/workflows/system-info.py - - name: python -m pip install wheel pytest pytest-cov pytest-timeout defusedxml - run: python -m pip install wheel pytest pytest-cov pytest-timeout defusedxml + - name: python3 -m pip install wheel pytest pytest-cov pytest-timeout defusedxml + run: python3 -m pip install wheel pytest pytest-cov pytest-timeout defusedxml - name: Install dependencies id: install @@ -189,6 +192,8 @@ jobs: path: dist\*.whl success: + permissions: + contents: none needs: build runs-on: ubuntu-latest name: Windows Test Successful diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 77d0dcc24..7efd46515 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -2,6 +2,9 @@ name: Test on: [push, pull_request, workflow_dispatch] +permissions: + contents: read + jobs: build: @@ -106,6 +109,8 @@ jobs: name: ${{ matrix.os }} Python ${{ matrix.python-version }} success: + permissions: + contents: none needs: build runs-on: ubuntu-latest name: Test Successful diff --git a/.github/workflows/tidelift.yml b/.github/workflows/tidelift.yml index 9a3192f9d..c73f25431 100644 --- a/.github/workflows/tidelift.yml +++ b/.github/workflows/tidelift.yml @@ -12,6 +12,9 @@ on: - ".github/workflows/tidelift.yml" workflow_dispatch: +permissions: + contents: read + jobs: build: if: github.repository_owner == 'python-pillow' diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 353dd0c19..1bb71bd72 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/psf/black - rev: 22.3.0 + rev: 22.6.0 hooks: - id: black args: ["--target-version", "py37"] @@ -19,13 +19,13 @@ repos: - id: yesqa - repo: https://github.com/Lucas-C/pre-commit-hooks - rev: v1.1.13 + rev: v1.3.0 hooks: - id: remove-tabs exclude: (Makefile$|\.bat$|\.cmake$|\.eps$|\.fits$|\.opt$) - repo: https://github.com/PyCQA/flake8 - rev: 4.0.1 + rev: 5.0.2 hooks: - id: flake8 additional_dependencies: [flake8-2020, flake8-implicit-str-concat] @@ -37,10 +37,15 @@ repos: - id: rst-backticks - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.1.0 + rev: v4.3.0 hooks: - id: check-merge-conflict - id: check-yaml + - repo: https://github.com/sphinx-contrib/sphinx-lint + rev: v0.6.1 + hooks: + - id: sphinx-lint + ci: - autoupdate_schedule: quarterly + autoupdate_schedule: monthly diff --git a/CHANGES.rst b/CHANGES.rst index de5bd8b8d..fb634eaba 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -2,9 +2,144 @@ Changelog (Pillow) ================== -9.2.0 (unreleased) +9.3.0 (unreleased) ------------------ +- Allow default ImageDraw font to be set #6484 + [radarhere, hugovk] + +- Save 1 mode PDF using CCITTFaxDecode filter #6470 + [radarhere] + +- Added support for RGBA PSD images #6481 + [radarhere] + +- Parse orientation from XMP tag contents #6463 + [bigcat88, radarhere] + +- Added support for reading ATI1/ATI2 (BC4/BC5) DDS images #6457 + [REDxEYE, radarhere] + +- Do not clear GIF tile when checking number of frames #6455 + [radarhere] + +- Support saving multiple MPO frames #6444 + [radarhere] + +- Do not double quote Pillow version for setuptools >= 60 #6450 + [radarhere] + +- Added ABGR BMP mask mode #6436 + [radarhere] + +- Fixed PSDraw rectangle #6429 + [radarhere] + +- Raise ValueError if PNG sRGB chunk is truncated #6431 + [radarhere] + +- Handle missing Python executable in ImageShow on macOS #6416 + [bryant1410, radarhere] + +9.2.0 (2022-07-01) +------------------ + +- Deprecate ImageFont.getsize and related functions #6381 + [nulano, radarhere] + +- Fixed null check for fribidi_version_info in FriBiDi shim #6376 + [nulano] + +- Added GIF decompression bomb check #6402 + [radarhere] + +- Handle PCF fonts files with less than 256 characters #6386 + [dawidcrivelli, radarhere] + +- Improved GIF optimize condition #6378 + [raygard, radarhere] + +- Reverted to __array_interface__ with the release of NumPy 1.23 #6394 + [radarhere] + +- Pad PCX palette to 768 bytes when saving #6391 + [radarhere] + +- Fixed bug with rounding pixels to palette colors #6377 + [btrekkie, radarhere] + +- Use gnome-screenshot on Linux if available #6361 + [radarhere, nulano] + +- Fixed loading L mode BMP RLE8 images #6384 + [radarhere] + +- Fixed incorrect operator in ImageCms error #6370 + [LostBenjamin, hugovk, radarhere] + +- Limit FPX tile size to avoid extending outside image #6368 + [radarhere] + +- Added support for decoding plain PPM formats #5242 + [Piolie, radarhere] + +- Added apply_transparency() #6352 + [radarhere] + +- Fixed behaviour change from endian fix #6197 + [radarhere] + +- Allow remapping P images with RGBA palettes #6350 + [radarhere] + +- Fixed drawing translucent 1px high polygons #6278 + [radarhere] + +- Pad COLORMAP to 768 items when saving TIFF #6232 + [radarhere] + +- Fix P -> PA conversion #6337 + [RedShy, radarhere] + +- Once exif data is parsed, do not reload unless it changes #6335 + [radarhere] + +- Only try to connect discontiguous corners at the end of edges #6303 + [radarhere] + +- Improve transparency handling when saving GIF images #6176 + [radarhere] + +- Do not update GIF frame position until local image is found #6219 + [radarhere] + +- Netscape GIF extension belongs after the global color table #6211 + [radarhere] + +- Only write GIF comments at the beginning of the file #6300 + [raygard, radarhere] + +- Separate multiple GIF comment blocks with newlines #6294 + [raygard, radarhere] + +- Always use GIF89a for comments #6292 + [raygard, radarhere] + +- Ignore compression value from BMP info dictionary when saving as TIFF #6231 + [radarhere] + +- If font is file-like object, do not re-read from object to get variant #6234 + [radarhere] + +- Raise ValueError when trying to access internal fp after close #6213 + [radarhere] + +- Support more affine expression forms in im.point() #6254 + [benrg, radarhere] + +- Populate Python palette in fromarray() #6283 + [radarhere] + - Raise ValueError if PNG chunks are truncated #6253 [radarhere] @@ -14,9 +149,6 @@ Changelog (Pillow) - Adjust BITSPERSAMPLE to match SAMPLESPERPIXEL when opening TIFFs #6270 [radarhere] -- Do not open images with zero or negative height #6269 - [radarhere] - - Search pkgconf system libs/cflags #6138 [jameshilliard, radarhere] @@ -47,6 +179,15 @@ Changelog (Pillow) - Deprecated PhotoImage.paste() box parameter #6178 [radarhere] +9.1.1 (2022-05-17) +------------------ + +- When reading past the end of a TGA scan line, reduce bytes left. CVE-2022-30595 + [radarhere] + +- Do not open images with zero or negative height #6269 + [radarhere] + 9.1.0 (2022-04-01) ------------------ diff --git a/Makefile b/Makefile index 437050ed4..219dda1de 100644 --- a/Makefile +++ b/Makefile @@ -85,6 +85,8 @@ release-test: sdist: python3 -m build --help > /dev/null 2>&1 || python3 -m pip install build python3 -m build --sdist + python3 -m twine --help > /dev/null 2>&1 || python3 -m pip install twine + python3 -m twine check --strict dist/* .PHONY: test test: diff --git a/README.md b/README.md index 7bff737a2..5e9adaf7e 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,9 @@ As of 2019, Pillow development is GitHub Actions build status (Test MinGW) + GitHub Actions build status (Test Cygwin) GitHub Actions build status (Test Docker) diff --git a/RELEASING.md b/RELEASING.md index a6049b685..b05067484 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -24,7 +24,6 @@ Released quarterly on January 2nd, April 1st, July 1st and October 15th. * [ ] Create and check source distribution: ```bash make sdist - python3 -m twine check --strict dist/* ``` * [ ] Create [binary distributions](https://github.com/python-pillow/Pillow/blob/main/RELEASING.md#binary-distributions) * [ ] Check and upload all binaries and source distributions e.g.: @@ -61,7 +60,6 @@ Released as needed for security, installation or critical bug fixes. * [ ] Create and check source distribution: ```bash make sdist - python3 -m twine check --strict dist/* ``` * [ ] Create [binary distributions](https://github.com/python-pillow/Pillow/blob/main/RELEASING.md#binary-distributions) * [ ] Check and upload all binaries and source distributions e.g.: @@ -91,7 +89,6 @@ Released as needed privately to individual vendors for critical security-related * [ ] Create and check source distribution: ```bash make sdist - python3 -m twine check --strict dist/* ``` * [ ] Create [binary distributions](https://github.com/python-pillow/Pillow/blob/main/RELEASING.md#binary-distributions) * [ ] Publish the [release on GitHub](https://github.com/python-pillow/Pillow/releases) @@ -99,8 +96,8 @@ Released as needed privately to individual vendors for critical security-related ## Binary Distributions ### Windows -* [ ] Contact `@cgohlke` for Windows binaries via release ticket e.g. https://github.com/python-pillow/Pillow/issues/1174. -* [ ] Download and extract tarball from `@cgohlke` and copy into `dist/` +* [ ] Download the artifacts from the [GitHub Actions "Test Windows" workflow](https://github.com/python-pillow/Pillow/actions/workflows/test-windows.yml) + and copy into `dist/` ### Mac and Linux * [ ] Use the [Pillow Wheel Builder](https://github.com/python-pillow/pillow-wheels): diff --git a/Tests/README.rst b/Tests/README.rst index 554645787..2d014e5a4 100644 --- a/Tests/README.rst +++ b/Tests/README.rst @@ -8,7 +8,7 @@ Dependencies Install:: - python3 -m pip install pytest pytest-cov + python3 -m pip install pytest pytest-cov pytest-timeout Execution --------- diff --git a/Tests/fonts/10x20-ISO8859-1-fewer-characters.pcf b/Tests/fonts/10x20-ISO8859-1-fewer-characters.pcf new file mode 100644 index 000000000..c065f59a9 Binary files /dev/null and b/Tests/fonts/10x20-ISO8859-1-fewer-characters.pcf differ diff --git a/Tests/images/ati1.dds b/Tests/images/ati1.dds new file mode 100644 index 000000000..747e4b1b9 Binary files /dev/null and b/Tests/images/ati1.dds differ diff --git a/Tests/images/ati1.png b/Tests/images/ati1.png new file mode 100644 index 000000000..790d7d7db Binary files /dev/null and b/Tests/images/ati1.png differ diff --git a/Tests/images/ati2.dds b/Tests/images/ati2.dds new file mode 100644 index 000000000..3ac5f7956 Binary files /dev/null and b/Tests/images/ati2.dds differ diff --git a/Tests/images/comment_after_last_frame.gif b/Tests/images/comment_after_last_frame.gif new file mode 100644 index 000000000..9f5c7b8da Binary files /dev/null and b/Tests/images/comment_after_last_frame.gif differ diff --git a/Tests/images/comment_after_only_frame.gif b/Tests/images/comment_after_only_frame.gif new file mode 100644 index 000000000..8188b6847 Binary files /dev/null and b/Tests/images/comment_after_only_frame.gif differ diff --git a/Tests/images/cross_scan_line_truncated.tga b/Tests/images/cross_scan_line_truncated.tga new file mode 100644 index 000000000..cec4357e3 Binary files /dev/null and b/Tests/images/cross_scan_line_truncated.tga differ diff --git a/Tests/images/decompression_bomb.ico b/Tests/images/decompression_bomb.ico index 0efc9eaf7..2ecfa8586 100644 Binary files a/Tests/images/decompression_bomb.ico and b/Tests/images/decompression_bomb.ico differ diff --git a/Tests/images/decompression_bomb_extents.gif b/Tests/images/decompression_bomb_extents.gif new file mode 100644 index 000000000..0d5ff03f5 Binary files /dev/null and b/Tests/images/decompression_bomb_extents.gif differ diff --git a/Tests/images/duplicate_number_of_loops.gif b/Tests/images/duplicate_number_of_loops.gif new file mode 100644 index 000000000..ac315ee99 Binary files /dev/null and b/Tests/images/duplicate_number_of_loops.gif differ diff --git a/Tests/images/hopper_16bit.pgm b/Tests/images/hopper_16bit.pgm new file mode 100644 index 000000000..e482493dd Binary files /dev/null and b/Tests/images/hopper_16bit.pgm differ diff --git a/Tests/images/hopper_16bit_plain.pgm b/Tests/images/hopper_16bit_plain.pgm new file mode 100644 index 000000000..a48ab5544 --- /dev/null +++ b/Tests/images/hopper_16bit_plain.pgm @@ -0,0 +1,4 @@ +P2 +128 128 +65535 +6425 5654 3598 6682 7453 7453 4626 5654 8738 8995 6939 5911 7710 7710 6682 7710 9252 9509 8224 6168 5654 5911 6168 7967 8481 7710 5397 7967 5654 28270 58853 41634 46517 42405 47031 30069 5654 10023 9252 4626 13107 44461 18247 5140 9766 31097 52685 60395 63479 62194 61680 61423 60395 50629 11822 14906 26471 23387 23901 24158 25700 25186 26985 26214 25700 22873 25700 24158 23901 25700 25700 25186 24929 24415 24415 24415 24415 24672 25443 25957 25700 25443 24929 24929 25700 25700 25957 26214 25700 25700 25700 25443 25186 25443 25443 25186 25186 25186 25186 25443 25443 25443 25443 25443 25443 25443 25186 25186 25443 25700 25957 25957 25443 25186 25443 26214 27756 28784 29555 29555 29812 29812 29812 29555 28784 28527 28527 28784 6425 5654 4112 6939 7196 7196 4369 5140 8224 8481 6425 5397 7453 7453 6939 8224 8738 9509 7967 5654 5397 5397 5911 7453 6425 8224 6682 6939 7710 33667 45489 23644 44718 15163 12336 22616 16191 7967 5140 6939 14392 43176 18761 7453 4369 7967 20560 37265 51657 61937 62451 61937 60652 52685 10794 9766 23644 24415 25443 21331 18761 20817 23644 25186 25186 25957 25186 25186 26471 24672 23644 25443 25443 24415 24415 26214 26471 24929 24415 24929 25700 25443 25186 25443 25957 25957 26471 26214 26214 25957 26214 25700 25443 25443 25443 25186 25700 25186 25186 25186 25186 25443 25443 25700 25700 25700 25443 25443 25186 25186 25186 25443 26214 25957 25700 25957 27242 28013 29298 29555 30069 30069 30326 29812 29298 29041 29041 29298 6425 6168 4369 7196 7196 6939 3855 4883 7967 8224 5911 5140 7196 7453 6682 8224 7967 8995 7967 5911 5654 5911 6168 7453 8995 7453 5654 7196 8738 30583 25186 15934 43433 17219 7453 7710 6168 8481 11565 5397 18504 44461 14649 4626 7196 8995 6168 10023 13364 51657 60652 61680 60909 57568 35466 7453 9252 10537 9509 7453 13364 9766 10537 13364 11565 16448 21331 26214 25700 29041 24929 27756 25443 25443 25186 25186 24929 24929 25957 27242 25957 25700 25700 25957 26214 26214 26214 26214 26985 26471 26471 26214 26214 25700 25443 25443 25957 25700 25186 25186 25186 25443 25700 25957 25700 25443 25443 25443 25443 25186 25186 25186 26471 26214 25957 25957 26471 27499 28784 30069 30069 30326 30326 30069 29555 29298 29555 29812 5911 5654 4626 7453 7453 6682 3598 4883 8224 8738 5911 5397 7196 7710 6682 8481 7967 9509 7967 5911 5654 6168 6425 7196 9766 6939 5397 7453 7453 17990 10537 20817 46003 15420 6168 6425 7710 6939 9252 5397 14392 45232 15934 5654 5654 7710 7967 8481 7967 48830 63222 37265 32896 44204 14649 6682 10023 7453 6682 20303 32382 31354 19018 13621 12079 12079 12079 10537 20560 24672 27499 23901 25186 25700 25186 24929 26471 28013 26471 23644 26214 26214 26214 26471 26728 26728 26471 25957 26728 26471 26471 26214 26214 25957 25957 25957 25957 25700 25700 25443 25443 25700 25957 25957 25186 25443 25443 25443 25700 25700 25443 25443 25700 25957 25957 25700 25957 26985 28527 29812 29298 29555 29555 29298 29298 29298 29555 29812 5397 5654 4883 7196 7196 6425 3855 5397 8481 8738 6425 5397 7196 7710 6939 8224 7967 9252 8481 5911 5654 6168 6425 6939 5911 7967 7196 5911 5654 9252 5397 21845 42662 12336 7453 6168 9252 9252 7967 4883 22616 43433 8481 6682 7453 6168 8995 8224 11565 52685 51914 12079 6939 4626 8224 7967 10280 39064 35723 18761 34952 61166 29041 8224 31354 43176 20303 12079 10794 13621 24672 28527 25957 26471 26985 26728 25957 25957 26728 27499 26471 26471 26728 26728 27242 26985 26471 26214 26214 26214 26471 26471 26214 26214 26214 26214 26214 26214 26214 26214 26214 26214 26214 25957 25957 25957 25957 25957 25957 25957 25957 25700 25186 25700 26214 25957 25957 26471 27499 28527 28013 28270 28527 28527 28527 28527 28784 29041 5397 5654 5140 7710 7196 6425 3855 5654 8481 8738 6425 5397 7453 7453 6425 7710 7710 9252 8224 5397 4883 5654 5911 6425 6682 8738 6682 5397 6682 6425 5654 21331 45232 13107 8738 7710 8738 6939 5654 8738 23130 44975 10280 7710 5911 6425 7967 5140 12079 55512 21845 11051 5140 5397 6682 22616 60138 64250 64764 53970 35723 65021 43690 40863 63993 65021 62451 43690 10537 12079 13878 24415 27499 24672 24415 27756 28270 25957 24929 26471 27242 26728 26985 27242 27242 27242 26728 26214 25700 25700 25957 25957 26471 26214 26471 26471 26214 26471 26471 26728 26471 26471 26214 25957 26728 26471 26214 25957 25700 25700 25700 25700 25700 25957 25957 25957 25957 26214 26471 26985 27242 27242 27499 27756 27756 28013 28270 28527 5140 6168 5654 8224 7196 6168 3855 5397 7710 8224 6168 5654 7710 7967 6682 7967 7710 9252 7967 5397 4626 5654 5654 6168 8995 7967 5397 5911 6425 6168 6682 21588 42919 13878 6425 6425 9766 9509 7453 4883 21588 43433 10280 5140 5140 9509 7967 10280 11822 47288 42148 38036 7196 5911 31868 63736 57054 40349 59881 62708 65278 63993 62194 65021 63222 53713 52685 59110 49858 12850 11051 34952 49601 39578 30069 26471 26728 26985 27242 27499 27242 26985 26985 26985 26985 26985 26728 26471 25700 25957 25957 25957 26471 26214 26214 26214 26728 26728 26728 26471 26471 26471 26471 26471 26985 26471 26214 25700 25443 25443 25700 25957 26214 25957 25700 25957 26214 26214 26214 25957 26471 26985 27499 27756 27756 27756 28013 28270 5654 6425 5654 8481 7453 6168 3341 5140 6939 7710 6168 5397 7710 7967 6682 7967 8224 10023 8481 5140 4626 5397 5911 6168 6168 6939 6425 6682 4626 7196 6939 19789 43690 15420 5397 7967 9509 6682 7710 7196 28013 40349 7710 5911 7967 7967 7453 27756 55512 64507 65278 34695 6168 16962 31354 22102 31097 24415 19018 26214 42662 57825 57054 42148 25957 22616 33410 31611 18761 25957 8995 13107 60395 64764 63222 51657 36751 27756 26471 27499 27499 27242 27242 26728 26985 26985 26985 26471 25957 25957 25957 25957 26214 26214 26214 26214 27242 26985 26471 26214 26214 26471 26728 26728 26471 26214 25700 25186 25186 25443 25957 26214 26214 25957 25443 25700 26214 26728 26728 26728 26728 27242 27499 27756 28013 28013 28270 28270 5911 6939 29555 10280 6168 5654 4112 4369 7196 8995 5654 4626 10794 8738 5911 7453 6939 10023 6682 6168 4626 5654 4369 5397 7453 7196 7453 5140 4883 6425 7710 20303 44204 13621 6682 8224 8738 8995 7710 6682 25186 41634 7967 8995 6425 11308 49858 63479 65535 64250 65278 26985 7710 7196 7453 34952 48830 62194 59624 36751 59881 50886 54484 51400 37779 62965 55769 54484 21331 6682 12079 9509 47288 65278 63736 64764 64507 53713 32639 27242 28270 27756 25700 29298 24672 28784 27499 26214 26471 26471 26728 26471 26728 26471 26471 26728 26985 26471 26214 26471 26471 26214 26471 26985 25957 25957 25700 25443 25443 25700 26214 26728 25700 26214 26728 26471 26214 25957 26214 26471 26471 26471 26471 26471 26728 26985 27499 27499 5654 9509 52428 23130 9252 3855 5397 4369 9509 6682 3341 5140 10280 5654 7453 7710 9252 8738 6682 6682 5397 4112 4626 6939 7196 6939 6168 6168 7967 6939 7196 19018 43690 13621 6425 8481 8995 8738 7196 6168 25700 41634 8224 3598 20046 58339 63736 65021 62965 65021 63993 22102 6682 8481 8481 30840 47802 56026 57311 62965 64250 62965 64507 64250 63993 58596 58339 54484 22359 13364 7196 8481 37779 65021 65021 62194 65021 64764 60652 46774 29555 25700 27242 28270 27756 27242 25186 28013 26728 26471 26471 26471 26471 26728 26471 26728 26471 26214 25957 26471 26471 26214 26471 26985 26214 26214 25957 25957 25700 25957 26471 26728 25957 25957 26214 26214 25957 25957 25957 25957 26471 26471 26471 26471 26728 26985 27499 27499 4112 8995 54741 57311 11308 6425 4112 8995 6425 7710 6168 6682 6939 11051 6168 6682 6682 7196 8481 5654 3855 5911 7710 4369 8481 8224 6168 5397 7196 6425 7967 19018 43690 14392 6939 8481 8995 8224 6939 5654 29041 41634 7967 23130 64250 65278 63993 63736 63736 62194 56797 16191 10280 6425 7967 13878 54741 52428 54741 58082 56283 56026 53456 56026 59624 56540 46003 55769 18247 10023 13364 12336 39321 65278 63993 65278 64764 65278 65278 63736 53970 32125 27242 28784 28270 24929 29812 25186 26214 26214 26214 26214 26214 26471 26214 26471 26214 25957 25957 26214 26214 26214 26471 26985 26471 26471 26471 26214 26214 26214 26728 26985 26728 26471 26471 26471 26471 26471 26471 26214 26728 26471 26728 26728 26985 27242 27499 27756 5140 10023 50886 61680 32896 20817 44204 23387 6939 7453 5397 5911 8481 32125 9766 6168 8738 8738 8738 6425 3084 4369 4369 5911 6939 7453 7453 5911 5140 6168 7967 18504 43690 15420 6939 8224 9509 8224 7196 6168 30583 38036 15163 62965 62194 64764 63222 57825 44461 44461 53199 15163 3084 5911 5654 9766 27756 55769 52171 63222 64250 64250 64507 62965 64250 63479 53456 42148 10794 5911 7453 6682 29812 60652 64764 65021 62451 65021 64764 65021 65021 56540 29555 26985 26985 28527 25957 26728 25700 25957 25700 25700 25700 25700 25700 25700 26214 25700 25700 26214 26471 26214 26214 26728 26728 26728 26728 26471 26471 26471 26728 26985 27242 26728 26471 26471 26728 26728 26471 25957 26728 26728 26985 26985 26985 27242 27499 27756 6682 7453 50115 64507 60652 58853 50115 18761 7967 6682 5397 6682 9252 46774 24158 8224 6168 8738 6682 6168 6168 7710 1799 5911 5397 6425 6425 7196 5654 6682 6425 16448 44204 16705 6425 7453 8995 7710 7453 6682 28013 40092 54998 63222 64764 61937 40606 35209 29298 15420 8481 6168 5397 8224 6682 9766 47288 56540 39321 54998 63736 65021 65278 65535 63736 61423 39835 55769 27242 10280 8481 10023 15163 32125 48830 55769 64507 64764 63222 64507 62451 64507 48830 26985 26471 26471 26985 26214 25700 25700 25700 25957 25700 25700 25700 25700 26214 25443 25700 25957 26214 25957 25957 26471 26214 26471 26471 26471 26214 25957 26214 26471 26728 26214 25957 25700 26214 26214 25957 25700 26728 26728 26728 26728 26985 27242 27756 28013 8995 34438 58339 61937 61166 60652 41634 9766 6939 7710 7196 6425 7967 50886 42148 6939 8738 9252 24415 26214 6168 3598 6939 4626 7710 14649 5140 6682 6425 6682 6168 16448 43690 17733 6168 6939 8995 7196 7453 6682 25700 50372 61166 63479 58853 31354 25700 12079 4112 5397 3598 5911 3855 4112 8224 6425 33667 42148 51914 58339 57825 64764 63222 64250 54741 53970 49087 51400 23644 8481 12079 7967 8995 6168 8481 25443 43433 56283 62965 64764 64764 65021 61680 32896 29298 25700 25443 28013 26214 26214 26214 26471 26214 26214 26214 26471 25957 25700 25700 26214 26214 25957 25957 26471 25957 26214 26471 26471 26214 25957 25957 25957 26728 26471 26214 25957 26214 26214 26214 26214 26471 26471 26728 26728 27242 27499 28270 28270 43947 59110 61937 64507 62451 59110 29555 4112 8738 8738 4626 5140 10537 54484 54741 21845 20560 48830 53456 20817 5654 6168 5140 4883 12593 35466 9766 5397 6168 5911 7453 16191 43176 18247 6168 6939 9252 6939 7453 6682 24929 56026 62451 60395 27242 13878 3598 4626 3341 3084 23901 28784 8224 6682 4369 10023 32125 61166 59624 53713 41634 58339 63993 63479 49344 54484 60395 60909 22359 10537 10023 8224 8995 26728 8738 10280 6939 20817 39578 49344 63736 61166 59624 53713 23901 29298 27499 26728 26471 26471 26471 26471 26471 26471 26471 26471 26214 25957 25957 26471 26471 25957 25957 26214 25957 26214 26471 26471 26214 25957 25700 25957 26985 26985 26728 26471 26471 26471 26728 26985 26471 26728 26471 26728 27242 27756 28527 28784 46003 57568 61937 63479 63736 63736 44204 15934 6939 8738 5911 9509 11822 51400 59110 57568 61680 59110 41377 7710 7710 5140 3084 5654 13878 54741 18247 6168 6939 6168 8738 13621 43176 18504 6168 7196 9766 7196 7710 6939 23130 58596 59881 34695 6682 3084 5140 27242 25186 11822 8481 38293 7196 16191 19789 9766 25186 48573 49601 49087 54227 39835 24672 27499 43433 48316 49601 52685 25443 11822 16191 8995 19275 35466 7196 25700 28527 6939 8738 19532 41891 61166 60909 57825 31611 26471 27242 27499 26471 26728 26471 26471 26471 26471 26728 26471 26471 25957 25957 26471 26471 25957 25957 26214 25957 26214 26471 26471 26214 25957 25700 25700 26471 26471 26728 26471 25957 25957 26471 26985 26214 26214 26471 26728 27242 27756 28527 28784 6939 12850 30840 63479 62708 52428 49344 23130 7710 9252 6425 19532 42662 60909 60138 59624 60652 55255 14906 8481 6425 7453 2056 5397 17990 58853 37008 6682 14649 30326 12336 14906 43947 20046 5911 5911 9252 8481 6425 7453 21588 47545 36237 6425 5911 6682 6939 44975 52428 49344 47031 37522 49601 57054 60138 54998 55255 31097 25186 9252 8224 12593 9766 9509 9766 12593 21074 45746 49858 59367 62194 44718 47288 35466 55512 56026 45232 13621 24929 14906 12079 42148 62708 57054 40863 27242 28013 26985 27242 25957 27499 25957 27756 26214 26471 26471 26985 26471 26214 26214 26471 26728 26471 26214 26471 26214 26214 25957 25957 25957 26214 26471 26728 26985 27242 27499 27242 27242 27499 27499 27756 27499 27499 27499 27756 28013 28527 28784 6682 6939 21588 62708 49087 16448 14649 10794 6939 13364 37779 56283 62965 60909 62451 61680 60138 27242 8224 7710 6939 2570 8738 4883 19275 58339 53456 36751 50115 32639 8224 10537 43176 20817 6425 5911 9252 8481 6425 6425 5654 1285 4112 4626 2570 6425 5654 11822 34952 38550 14135 44975 58339 46003 44975 57568 61423 60395 62451 49344 29298 20046 7967 13878 27242 50629 63222 60138 61166 58596 51400 60909 59367 35980 47545 51657 48573 57311 51914 11822 5911 11051 48573 47288 28013 13878 10794 24158 27242 26214 26985 25700 27499 26471 26214 26214 26985 26214 25957 25957 26214 26214 26214 25957 26471 26471 26214 26214 26214 26471 26728 26985 27242 27499 27756 27756 27499 27499 28013 28270 28013 28013 28013 28013 28270 28527 28784 29041 4112 9509 20303 60395 32639 7196 7196 5654 7710 10537 24415 45489 56797 63736 62451 61423 57825 43690 11308 8481 4112 4626 6168 7196 28270 60909 56540 46260 44461 13107 6939 12593 41891 22102 6425 5911 8738 8481 5654 4883 6425 4112 4112 4883 3855 4112 2570 5654 3341 8995 15420 27242 13364 8738 46260 50629 44204 37265 25700 19275 16191 20046 12850 19532 17990 20817 37008 40863 54741 55769 33667 19789 28527 28784 4626 9509 25700 49344 44461 40863 41891 12593 13878 7453 4626 3855 7196 12079 26728 26985 26985 25700 27756 26728 26985 26728 26985 26728 26214 26214 26471 26471 26214 26214 26728 26728 26471 26471 26728 26985 27242 27499 27242 27499 27756 28013 27756 27756 28013 28270 28013 28013 28270 28527 28527 28784 29041 29041 5140 8481 15934 53199 16705 7967 7453 3598 5397 9766 5140 9509 19018 50629 63479 63222 61937 59110 27756 7710 6939 12079 24158 35980 53456 60909 50372 46774 24158 5397 5911 9252 40863 23130 5654 6425 8481 6682 4883 3598 1799 4626 4626 3855 1799 3598 5654 4883 6682 3341 2827 6682 14392 7967 7967 8481 8224 8738 7710 5140 7710 6682 4883 9252 7453 6168 11565 8738 11822 12593 15677 17990 44461 46260 48316 16448 6425 6168 24415 35209 14392 8738 6425 4626 6682 2827 6168 3598 23644 27242 26985 25957 27242 26728 27242 27242 27499 27499 27242 27242 27242 26985 26985 26728 26985 26985 26985 26985 26985 27242 27242 27499 27242 27499 27756 27756 27756 27756 28013 28270 27756 28013 28270 28527 28784 28784 29041 29041 7453 8738 15420 38036 8224 7967 7196 4883 4883 6168 6425 4883 9766 50372 61166 29812 33410 50629 52428 14906 6682 12336 21845 38550 51657 56797 56283 45489 11308 6168 6682 9766 40092 23901 4626 6939 7710 4883 3341 3341 4369 3084 3598 5911 4883 3084 4369 771 5397 4112 3598 6939 4112 6682 6168 3341 5140 4626 6682 5654 9252 6168 7710 6168 7967 7453 5911 7196 9509 6168 6425 9509 25186 33410 56797 54227 20560 8481 5654 3855 3341 4369 3855 2313 4112 3598 1542 4626 19018 25957 25957 26214 26471 25957 26728 27499 27756 28013 28013 28013 28013 27756 27499 27499 27499 27499 27499 27242 27242 27242 27242 27242 27756 27756 28013 28013 27756 28013 28270 28527 28013 28270 28527 28784 29041 29041 29041 29041 3598 7967 11051 15420 6682 8738 6682 4626 7453 7453 7967 8995 6939 51400 48316 11308 7967 9766 23644 21845 5140 6168 5140 8224 33153 57311 57825 47802 28527 7196 6939 7453 38807 25700 4883 6682 6425 3598 3084 3341 2570 4626 2827 1799 5911 3084 3341 6168 2827 4626 3598 1799 4883 3855 3598 8481 8224 5654 4883 5140 3598 3855 5911 4112 5654 2827 5140 7196 4369 7710 6939 7196 10794 23644 12336 7196 4626 6168 2056 4369 3084 2056 3341 4626 2570 4369 2827 5397 15934 25957 26214 26985 26985 26471 26985 28270 28013 28270 28527 28527 28270 28013 27756 27756 28013 28013 27756 27756 27499 27499 27242 27242 28270 28270 28270 28270 28013 28013 28527 28784 28527 28784 28784 29041 29298 29555 29555 29555 6939 8738 7196 8224 12336 9252 5654 5654 6682 7967 2827 7967 10280 51914 26214 8995 8481 11308 9509 10280 6682 3341 4626 3598 25186 61166 49344 48830 50115 13107 3598 8224 37522 28527 5397 5140 4369 3084 4369 2827 4369 3341 4883 2827 3855 4112 4626 1028 3598 1799 4369 4369 514 5140 3855 1285 2827 3855 4883 6682 4369 5140 4883 4883 4369 5140 6168 5140 5654 7196 2570 4112 3084 2313 4626 2056 4112 2570 0 3598 3084 3084 3341 3855 1028 2056 4883 4112 15934 27756 26985 28013 27756 27499 28013 28270 28013 28270 28784 28784 28270 28013 28013 28270 28527 28527 28270 28013 28013 28013 27756 27756 28527 28527 28527 28270 28013 28013 28270 28527 28527 28527 28784 28784 29041 29298 29812 29812 5140 10537 6682 7453 10023 10280 7710 3855 4883 6682 6168 5654 11565 42405 8481 9509 7967 8995 8224 6939 5397 5397 3855 4626 32382 57311 20560 10023 37265 32382 6939 5911 36494 30326 6425 4626 2827 3084 5140 3084 3855 2313 4883 3084 4626 4112 3598 3855 3084 3341 1799 4112 4883 257 4369 2313 3341 2827 2827 2056 2827 3341 2313 3084 3855 2827 2313 3084 1799 1799 4112 2827 3084 4369 1285 2313 3084 1799 6168 2313 3598 1028 4112 2570 4626 4369 2570 3341 16448 28270 27242 28013 27756 28013 27499 27756 28270 28527 29041 29041 28527 28270 28270 28527 28527 28527 28270 28270 28270 28270 28270 28270 28270 28270 28270 28013 27499 27499 28013 28270 28527 28270 28527 28527 28784 29041 29555 29812 5911 8224 7196 8738 9509 10280 6939 5140 7196 6168 4626 7710 11308 14649 9252 6939 8995 8738 8738 7710 5654 3855 3855 4626 37779 42662 6425 3598 7453 13107 7196 5140 33410 30583 5654 3598 3341 4112 4112 3855 3598 4112 3341 3084 3598 3084 2827 3341 2056 3084 3341 3084 2827 3341 3084 1799 2570 3341 2827 2570 3598 3084 2313 2827 3598 3084 2827 2827 3084 3084 2827 2570 2570 3084 3084 2570 2570 3341 3084 2056 3341 2570 3084 3341 3341 4369 4369 2827 16448 28784 27756 28013 26728 29041 27756 29812 28784 28784 29041 29041 28527 28270 28270 28270 28270 28527 28784 28784 28784 28784 28527 28527 28270 28270 28013 28013 28270 28784 28784 29041 29041 28527 28013 28013 28527 28784 28527 28527 6168 8224 7196 8738 9252 10023 6425 4369 5654 6939 6168 8224 8224 10023 7196 8224 8224 8481 8738 7967 5911 4369 4112 4626 33924 16448 5654 6425 4112 4369 5140 6939 31868 31611 4883 3598 3084 4112 3855 3598 2313 4626 4112 2570 2570 3855 3855 4626 3855 3855 3341 2827 2313 2570 3598 4883 3084 3598 3341 3084 3598 3341 2313 2570 2313 2570 2570 2570 3084 3341 3598 3341 2313 3341 3598 3084 2313 2313 2570 2827 2056 1028 1799 2570 2056 2570 3855 4369 14392 28270 28527 29041 28013 29555 28013 29812 29041 29041 29298 29298 29041 28784 28784 28784 29041 29041 29298 29298 29041 29041 28784 28784 29041 28784 28527 28527 28527 28784 28784 29041 29041 28527 28013 28013 28270 28527 28527 28527 5911 8224 7453 8995 8995 9766 5911 4112 5397 6682 6425 7453 6168 6168 6168 9509 7967 8224 8738 8224 6168 4626 4112 4626 14906 5911 9252 3341 2570 5911 5654 5397 30583 33924 4112 4112 3084 3855 3598 3598 5397 4112 2313 2827 4883 4112 1542 1542 2827 2056 2570 4369 4112 2827 2313 3084 2827 2827 2827 2827 3084 3341 2827 3084 3598 3598 3598 3341 3084 2827 2827 2570 3598 3084 3084 3341 3598 3598 3341 3598 3598 2313 3084 4369 3598 2570 3084 3084 12336 28527 29041 29812 28527 29812 28270 29812 29298 29298 29555 29812 29555 29298 29298 29298 29555 29555 29812 29812 29555 29298 29298 29041 29555 29555 29298 29041 28784 29041 29041 29298 28784 28527 28270 28013 28270 28527 28527 28527 5911 8224 7196 8995 8995 9509 5654 3598 6682 6425 4626 6425 7453 6425 7453 9509 8481 8481 8738 7967 6168 4112 3855 4369 4369 8224 7196 4626 5397 6168 3598 6425 30069 36237 4112 4626 3084 3855 3341 3341 3341 3598 3084 2827 3084 2570 2827 4883 4626 3341 2313 2827 3341 3341 3598 3855 4369 3598 3855 4112 3598 3598 4112 4369 3855 4112 4112 4369 4883 4883 5397 5654 4626 3855 3341 3341 3084 2570 2570 3084 2827 1542 2056 3084 3084 3855 4112 3341 10794 29298 29298 29812 28270 29298 28784 30583 29812 29812 30069 30069 29812 29812 29812 29812 30069 30069 30069 30069 30069 29812 29812 29555 29812 29812 29555 29298 29298 29298 29298 29298 28784 28527 28527 28270 28527 28527 28784 29041 5911 7710 7196 8738 8738 9766 5654 3855 7196 6425 4112 6168 8738 6682 8481 9252 8995 8995 8481 7196 5397 3855 3598 4369 7196 8224 5140 7196 3084 3341 3855 6168 29812 35980 4112 4369 2827 3598 3084 3341 1285 3598 4369 3598 3855 4112 2313 2056 3341 5654 8224 9509 11051 13107 14135 14392 12850 10794 10280 9766 7453 6939 7967 7453 9766 10280 12079 13878 16448 18761 20560 21588 22616 20560 16962 12850 8224 4626 3341 3084 3341 3084 3084 3084 2056 3341 4369 3341 7967 29041 29555 29555 28784 29555 29298 30840 29812 30069 30326 30326 30069 29812 30069 30326 29812 29812 29812 29812 29812 29812 30069 30069 29812 29812 29555 29555 29555 29555 29555 29812 29041 29041 28784 28784 28784 28784 29298 29298 5911 7967 6939 8224 8481 9509 5911 3855 5911 6682 5140 6168 8738 5911 8738 8738 9252 8995 8481 7453 5140 3855 3598 4369 6682 6682 8481 4626 2313 5397 5397 4883 29812 33410 3855 3855 3084 3341 3598 3598 4112 2827 2056 3084 3598 2570 4626 9509 19532 25443 31611 34181 34695 34952 35209 34952 34181 31354 31097 30069 26214 24672 25443 24672 25957 25957 27756 30069 32896 35723 37265 38036 35723 36237 37008 36494 33667 24929 12850 3598 2313 2056 3598 3855 2570 2570 3598 2827 5140 28527 29298 30326 30069 30326 29812 30583 30326 30326 30583 30326 30326 30069 30326 30326 30069 29812 29812 29812 29812 30069 30326 30326 30069 29812 29812 29812 29812 30069 30069 30069 29298 29298 29298 29298 29041 29298 29555 30069 6168 8224 6939 8224 8224 9252 5911 4369 4883 6939 5654 5911 8481 5654 9252 7967 8995 8481 8224 7453 5654 3598 3598 4626 5911 4626 7453 5654 6425 5397 2570 6682 31868 31611 4883 3084 2570 3341 3341 3084 4112 3084 2313 3084 4626 9766 22873 37008 40349 42148 43690 43690 43947 44204 45232 46003 46003 43690 44461 44718 40606 39064 40092 39064 40863 40606 41120 42148 44461 45489 45232 44461 43433 42405 41377 41377 43176 41120 33153 24672 9509 4369 1542 2827 3084 3084 3598 4369 4369 29298 29555 30583 30326 30583 30326 30326 30840 30840 30840 30840 30326 30326 30583 30583 30326 30326 30069 30069 29812 30069 30069 30069 30326 30326 30326 30326 30326 30326 30326 30326 29812 30069 29812 29555 29555 29555 30069 30583 6682 8481 6939 7967 8224 9252 5911 4112 4369 6939 5140 5397 8481 6425 10023 7967 8224 8224 8224 7453 5911 3855 3598 4369 6425 7196 6425 6939 3855 4626 4883 4883 33667 30840 5911 3341 3084 3341 2827 2827 2570 5911 6425 7967 19018 33667 42148 43433 43947 42148 41891 44975 48573 49858 50629 50886 50115 47802 50115 51914 48830 48059 49344 48316 49087 48316 48573 49858 50886 51400 50372 48830 45232 46003 45746 43690 43690 44204 42148 38550 32896 18247 5911 3855 3855 3341 3855 4883 5397 30583 29812 29812 29812 30069 30326 30583 31097 31097 31097 30840 30583 30583 30583 30840 30840 30583 30326 30069 30069 30069 30069 30069 30583 30583 30840 30326 30583 30583 30326 30326 30069 30326 30326 30326 29812 29812 30326 30840 19275 9766 7453 9766 7453 9766 6682 4369 4626 7453 6425 6682 5911 9252 9252 7710 8481 7967 7710 7967 6168 3598 3598 4626 5397 8224 5911 5397 6425 3598 3855 6168 31868 33410 3341 3084 2570 3598 4112 3855 10794 20817 17990 22359 35209 41634 45232 46774 44975 45746 46517 47288 47802 49344 50629 51657 52685 51657 49858 50629 50372 50372 53199 52685 49344 52685 52685 51400 49087 53970 53970 51914 51914 46774 47802 43947 46517 43947 44204 39578 39578 32382 24158 15934 3341 3084 4369 3341 6682 30840 30326 29298 30840 30583 31354 30583 31097 30840 30583 30583 30840 30840 30583 30326 30583 30326 30069 30326 30326 30326 30326 30069 30326 30326 30326 30326 30326 30326 30326 30326 30583 30583 30326 30583 31097 31354 31868 32125 48573 8481 8738 9252 6682 16705 10794 5140 5911 6425 3855 7453 6425 6939 7196 7710 7710 7710 7710 7967 6168 3855 3855 4626 6168 8995 7196 6168 6168 4369 4626 4883 30583 36237 3341 3084 4883 1542 1028 9252 22873 23644 21588 29555 39835 43690 45746 44975 46517 46517 47802 48830 50115 51657 52428 52685 51143 50886 51143 52685 51400 49858 50886 50115 52428 52171 51400 51657 50629 49601 48573 48830 49087 51914 45489 43433 44461 43947 42919 40092 40092 36237 35209 24158 14906 4112 4626 2570 7710 30326 29812 29298 30583 29555 30583 31097 31354 31097 30840 30840 31097 31097 31097 30840 31097 30840 30583 30583 30840 30840 30583 30326 30583 30583 30840 30840 30840 30840 30840 30840 30840 30840 30840 31097 31097 31354 31611 31611 60138 38550 7710 12336 34952 45232 8481 2827 7196 8995 7453 7453 6425 8481 7196 7453 6425 6939 7967 7967 6168 3855 3855 4626 5911 7967 7196 6682 5911 5140 6168 4883 31611 34181 3084 4626 3084 3855 8738 17990 21331 19789 25700 35466 40092 42662 45489 45232 48316 49087 50115 50372 49087 48059 47031 46774 49601 50372 50886 52428 50886 48830 50115 49601 47288 48830 48316 45746 45489 41377 37522 35466 37522 37265 40606 40863 38807 40349 40606 41377 39835 37779 37265 33410 23387 7967 2827 5140 10537 31354 31097 30583 31611 30326 31611 32382 31611 31354 31097 31354 31611 31611 31611 31354 31611 31354 31097 31097 31354 31097 30840 30840 31097 31354 31354 31611 31611 31611 31611 31611 31097 31097 31354 31611 31611 31611 31354 31354 59624 57825 25957 51914 59367 24672 7196 3598 18247 30583 6168 7453 6939 7196 7453 7453 5911 6939 7967 7710 5911 3598 3598 4883 6939 7967 7453 7453 6168 5397 6425 4883 32382 34695 3598 3855 514 4112 10537 16191 19789 22616 31868 36494 36751 40092 42662 42919 39835 39064 37522 35466 34181 34695 37265 39578 46774 49344 50629 51143 49858 49601 51914 50115 44718 47288 46517 41120 39835 34695 33153 34438 31097 34952 41120 41634 46774 41634 39321 39835 40092 38807 35209 34695 30840 17990 5654 3341 12336 31868 31611 30069 30840 30840 30840 31097 31611 31611 31354 31611 31868 31868 31868 31611 31868 31611 31354 31611 31611 31611 31611 31354 31868 31868 31868 31868 31868 31868 31611 31611 31354 31354 31611 31611 31868 31868 31868 31868 57568 61680 61423 58339 47802 10537 4883 5140 19789 55769 13621 9509 6682 4369 11051 8738 6425 6939 7710 6939 5397 3855 3855 4626 7196 7453 6939 7453 6168 4112 5397 4883 30069 36494 4369 3084 3598 5654 9766 17990 24158 26985 32639 35209 38036 41891 43176 43176 42919 40092 37008 34952 35209 36494 39321 41891 42919 47545 49601 49344 48316 49858 52428 49344 48830 45232 41891 40092 40092 30069 24158 25186 24158 27242 32896 38550 45232 42405 45746 37779 37265 40606 39321 29555 30840 19532 11051 6168 14649 32896 32896 30583 31097 32382 32382 31097 31868 31611 31611 31611 31868 32125 31868 31868 31868 31611 31611 31611 32125 32125 32125 31868 32382 32382 32125 32125 31868 31611 31354 31354 31868 31611 31611 31611 31868 32382 32639 32896 61423 58596 57825 57054 24415 7710 9252 2827 24672 58082 39835 9252 7967 25700 39578 12336 6939 7453 7453 6939 5397 3855 3598 4112 4883 6168 5140 5140 4369 3341 4883 5654 30840 32639 4369 4883 4112 7710 18504 26985 26728 29041 31868 36751 40863 40349 39321 39835 39835 35466 30069 28270 28270 28784 29555 29812 38807 43947 46260 45489 44461 47288 51143 49344 48316 45746 41891 37779 33667 25700 22359 23644 20560 15934 17733 16448 14649 16448 16191 19018 19789 24158 24158 25700 29298 21331 10537 7967 19018 33924 33410 31354 31611 33667 32896 31868 31868 31868 31611 31868 32125 32125 32125 31868 32125 31868 31868 32125 32382 32382 32382 32125 32639 32639 32382 32382 32125 31868 31611 31611 32125 32125 31868 31868 32125 32639 33153 33410 57825 60138 57825 59110 22873 9252 3084 3855 20303 58082 60909 27242 44718 58082 33924 7453 6939 7196 7453 6682 5911 4883 4112 3598 4626 8738 6939 3855 3341 3855 5140 5140 34181 30069 5140 4369 1799 8738 26214 28784 24929 26985 30069 38036 40349 37008 38293 38036 37265 32896 28013 25700 25700 27499 30583 33924 31354 38036 43433 45232 44461 46517 51400 51914 50115 45489 38293 34181 30840 25957 16448 9252 14906 21331 26214 23901 23644 20560 11051 11051 29041 23901 11565 17990 22616 23901 11051 10794 23130 34181 32382 30840 31097 31868 30840 31611 32382 32125 31868 32125 32125 32125 32125 31868 32639 32639 32382 32382 32382 32639 32382 32125 32639 32639 32639 32639 32639 32382 32382 32125 32382 32382 32382 32382 32639 32896 33153 33153 59367 62708 62194 58082 54484 14135 8224 4369 25443 55769 61423 60395 54998 48316 10794 5397 6168 6939 7453 7196 6425 5140 3855 3341 8481 14649 11565 5140 3855 4369 5140 3855 32639 32382 6168 2827 6425 14906 29555 29298 25700 23644 20817 23130 18504 12336 12593 7453 6939 7967 9766 10537 9509 8738 11822 15163 23130 32639 43176 50115 50115 49601 52171 52942 50886 46517 38550 30326 18504 17990 26985 38550 31097 34181 36237 38293 31097 38036 59367 27756 7196 12079 10794 13364 18761 21845 16448 15934 29555 37265 34181 33667 33667 32382 31354 33667 32639 32382 32125 32125 32382 32382 32125 31868 33410 33153 32896 32639 32639 32639 32382 32125 32639 32896 32896 32896 32896 32896 32896 32896 32382 32639 32639 32896 32896 32896 32896 32896 45746 60395 52942 56026 60138 43433 6939 14906 50886 59110 58082 57311 54998 24415 9766 5397 6682 6939 6682 8224 3855 19275 13107 12593 36494 41891 7710 5654 2827 4626 4112 4883 31354 31097 7967 4883 8995 25957 34181 27756 21845 16705 7710 13107 15677 13107 7967 30069 48830 44461 36494 31868 32125 38293 38807 24672 20817 16448 29812 38293 49344 49858 47288 46260 42148 36237 27756 31097 45232 35209 30069 13107 9766 11051 15677 19789 30840 31097 39835 51400 15934 12336 22873 17990 17733 23644 27756 24415 33924 32382 34695 33667 33153 33924 32382 32382 32639 32639 32639 32639 32382 32382 32382 32382 32896 32896 33153 33410 33410 33153 33153 33153 32896 32896 32896 33153 33153 33153 32896 32896 33153 32896 32896 32896 32896 32896 33153 33153 37779 54998 17990 14649 24929 39064 23644 14649 52171 56797 56283 56026 48830 10794 7453 6168 6168 7196 6682 7967 5397 18504 28013 33410 46774 20303 4369 2570 4626 4369 3855 4883 31868 30069 7967 13621 19275 30583 31354 24158 17476 14649 4626 7196 4112 10537 32382 33153 34952 25186 15163 12336 11565 10280 23130 39321 35466 33667 35723 36751 43176 43690 43433 38036 36751 31354 32382 32896 30840 28013 12079 20303 7967 13364 11822 10794 16191 22616 20046 18504 20303 17990 15420 10280 10537 20817 31354 38293 44461 40349 32639 34952 34181 33153 33667 34952 33153 33153 33153 32896 32896 32896 32896 32896 33410 33410 33667 33667 33667 33410 33410 33153 33153 33153 33153 33410 33153 33153 33153 32896 32639 32896 32896 33153 33153 33410 33667 33667 35723 48059 9252 9766 5140 8481 7453 6939 31868 55769 59881 59110 55512 29041 8995 7196 6939 8738 6939 6682 5140 12336 28013 28784 28270 8738 4626 3598 3341 4112 5397 4369 32382 34438 7453 13621 29812 33924 27499 18761 12079 12593 14906 13364 7196 25957 29041 30840 22873 12850 10280 8995 9766 8995 14392 19275 30583 29298 28784 37779 38550 34181 35980 34695 33924 27242 36494 34695 28013 14906 20303 12079 3855 9509 9766 11051 11822 18761 20303 23387 31097 25700 20560 20817 23130 32639 36494 27756 34181 43176 33924 35466 32125 32896 35466 33667 33667 33667 33667 33667 33667 33667 33410 33410 33924 33924 34181 34181 33924 33924 33667 33410 33667 33667 33667 33667 33410 33410 33410 33153 32896 33153 33410 33667 33667 33667 33667 33667 30326 28527 6682 8224 7967 6425 3341 3598 10537 51143 59110 52685 59110 51657 11822 3855 5654 8481 7453 6168 6939 15934 30583 26728 9509 2570 5397 5911 2313 4112 6168 4626 29041 35980 8738 14649 39578 34952 29555 27499 18247 21331 15163 16962 12593 22873 17990 25700 12593 11051 14392 6425 4369 11565 22616 26728 17219 21588 23644 35980 32896 42919 49601 49087 42405 37779 39321 37779 26985 32125 28527 24929 22616 20560 19018 20046 22616 23901 27499 32382 39064 35466 37779 32896 28784 27756 31097 17990 15934 37008 35466 34438 31868 32896 35723 31868 34181 34181 34181 34181 34181 34181 34181 34181 34438 34438 34438 34438 34438 34181 33924 33667 33667 33667 33924 33924 33924 33924 33667 33667 33667 33924 34181 34181 33924 33667 33410 33153 19789 15934 10280 5140 5911 8738 4626 3855 7196 51400 37522 11051 26471 46003 29812 5911 6682 8224 7967 5397 4369 16191 29555 31868 25957 2056 3598 4369 5140 4112 4626 4883 29041 34695 8738 20817 35723 22359 21588 27242 28013 28270 26985 32896 27499 21331 20303 19018 17733 16705 18761 19275 25957 25700 25957 33153 35209 38550 38807 39835 25700 45489 52942 52942 47802 31868 45489 43176 39835 34952 32382 37779 34695 33153 30583 28527 30326 34695 36237 34181 36494 38293 42662 34181 30840 29298 35209 37265 15677 31354 33153 33153 35209 33410 33924 34438 34438 34438 34438 34438 34438 34438 34438 34438 34695 34695 34695 34695 34438 34181 33924 33667 33924 33924 34181 34438 34438 34438 34438 34438 34181 34438 34438 34438 34181 33924 33667 33410 10023 6168 5911 8224 8738 8481 3598 3084 10280 52171 20303 7196 8995 8224 13878 6939 6939 6168 7453 7453 6168 15420 22873 30069 38550 21074 3598 4112 4883 5140 4369 4112 30840 33153 6425 23901 28013 20817 27756 29041 29298 26985 37779 39321 29555 28270 19532 18247 15934 18247 26214 37522 43947 41377 36751 39064 37522 44718 49344 43433 25186 43947 50886 53199 51657 43176 43690 46774 39321 35723 44975 43176 46774 49601 46774 41891 35466 42405 43433 39835 40606 40349 40606 33667 30326 38550 40863 36237 21588 31097 33924 32639 35466 33924 33153 36237 34695 34695 34695 34695 34695 34695 34695 34695 34952 34952 34952 34695 34695 34438 34181 33924 34181 34181 34438 34438 34695 34695 34695 34695 33924 34181 34181 34438 34438 34438 34438 34438 5140 6682 7196 8224 6939 6168 3341 3855 11565 38293 5140 7967 9509 5140 6168 4112 7967 7196 7196 6939 5140 5911 4883 8224 22102 27756 5911 6425 3084 5397 4883 4369 32125 34695 5654 16448 21331 17733 31354 28270 26728 28013 35723 41891 33410 33410 25186 22359 22616 28527 35723 46003 46260 46774 42919 38036 34438 46517 51143 38036 31611 48316 52685 50115 52171 46260 34952 48059 49087 41120 36237 44204 47802 45489 42662 39835 35466 40606 43690 40863 42662 41377 41891 37779 31868 41120 48316 39578 22359 34181 35209 33410 33667 34695 34181 34952 34695 34695 34952 34952 34952 34952 34952 35209 34952 34952 34952 34952 34952 34695 34438 34181 34181 34181 34695 34695 34695 34695 34438 34438 34181 34181 34181 34181 34438 34438 34695 34695 6939 5397 6682 5397 7967 7453 4112 3855 8481 14649 6939 8995 7453 7453 6425 6168 5654 8481 7710 5911 5911 3855 2827 3855 5140 7710 6682 7196 4112 3598 4369 4883 28270 33924 7196 13107 26214 16448 35466 38036 32639 23644 33667 38036 35723 34181 35209 30583 26214 34695 33924 40092 37522 33667 30326 35466 50629 48830 44461 30840 40606 50372 52942 52685 50372 52685 36751 43690 46260 52428 48316 39578 38807 33924 36237 32896 34181 35980 44461 43176 38550 38807 38807 37265 35980 30583 41634 41891 24415 35980 33924 35209 33153 35466 34952 34438 34952 34952 34952 34952 35209 35209 35209 35209 35209 35209 35209 35209 35209 34952 34695 34438 34695 34695 34952 34695 34695 34438 34181 34181 34695 34695 34181 34181 34181 34438 34438 34438 5654 6168 5911 7196 8224 6682 4112 3598 6168 5654 6682 7710 7453 6425 5911 6682 6682 8224 6939 6682 4883 3341 4112 2827 3598 4626 5140 6168 3598 4883 4626 4369 28784 34438 5654 7967 31354 19018 40092 37265 29812 24672 35209 36237 38550 35466 38293 31868 25186 33667 34181 34438 35723 37265 45489 52685 52428 49344 43176 31354 47288 50115 53970 52942 53199 53713 45746 38293 49601 51400 51400 53970 51400 48316 43433 39578 40349 44718 45746 43176 40092 38807 38036 37008 29041 19018 33924 41377 32125 32639 34695 35466 33924 34181 35209 35980 35466 35209 34952 34952 35209 35466 35209 35209 35209 34952 35209 35723 35466 34952 34438 34695 35209 35209 35209 34952 34695 34438 34181 34181 34438 34438 34438 34438 34438 34438 34438 34438 6168 6425 6425 7196 8224 6425 3855 3084 5397 5397 6168 7453 7196 5911 5397 5911 6939 8224 7196 6425 5140 3855 4369 3598 2827 5654 4112 4112 6682 4883 4883 5140 30840 36237 3084 12593 30583 25957 41891 37522 24929 24672 33667 34181 38807 39321 39064 31097 31611 37008 42919 48059 51400 53456 54741 52942 51143 53713 38293 41377 49344 49858 52685 54484 53970 51914 53713 40863 44204 49858 52171 51400 51400 51914 49087 46003 46260 46517 43176 40349 41120 39321 31868 41120 34695 20817 28527 41120 37779 36494 36494 35723 33667 33667 34952 34438 35466 35209 34952 34952 35209 35466 35209 35209 35723 35209 35209 35466 35466 34952 34952 35209 35209 35209 35209 34952 34695 34695 34438 34438 34695 34695 34438 34438 34438 34695 34695 34695 5911 6168 6425 6939 7967 5911 3598 3084 5654 5911 6425 7710 7453 6425 5654 6425 6939 7967 6682 5911 4883 3855 4626 3855 4626 4883 4112 4112 6682 2827 4883 5911 28527 35466 14649 40092 49087 33924 40092 39578 24415 31097 37008 32125 34952 38807 38550 34695 25957 31611 47288 54484 53456 54227 55512 54227 54227 50372 32639 47545 50886 52685 52428 54484 53970 52171 52685 47031 32896 45232 50115 50372 52171 51657 46774 43176 44204 43176 40349 39064 39064 34438 35466 41377 45232 29041 31868 36237 38036 35723 35209 34695 34438 35466 36237 35466 35466 35209 35209 35209 35209 35466 35466 35209 35980 35466 35209 35466 35466 35209 35209 35723 35209 35209 34952 34952 34952 34952 34952 34952 34695 34695 34952 34952 34695 34695 34695 34695 5654 5911 6168 6682 7710 5911 3855 3598 5397 5911 6682 7710 7710 6939 6682 6682 6682 7710 6168 5397 4369 3341 4626 3598 5397 3341 5654 4626 4883 4626 4369 3084 21588 43433 38293 46774 50629 43176 46260 34952 33153 42405 42148 31611 30326 35466 36751 38293 37008 32639 42405 51914 53199 53713 51657 49344 46003 31354 30840 44975 48316 52428 52685 51143 53456 53970 54227 50115 30840 25700 38550 43433 44204 43176 43433 45746 48573 47802 42919 37779 35466 34695 37522 42662 47288 40863 32125 36237 37008 35466 35209 35209 34952 35209 35209 34181 35723 35466 35209 35209 35466 35466 35466 35466 35723 35209 35209 35466 35723 35209 35466 35723 35209 35209 35209 34952 35209 35209 35466 35466 34952 34952 34952 34952 34952 34952 34952 34952 5397 5911 5911 6425 7196 5654 3598 3598 4626 5397 6168 7196 7453 6939 6939 7196 6939 7710 6168 5140 4369 3341 4112 3341 3855 4112 6425 4626 4369 6939 3341 8995 33924 42662 40349 46517 50629 42919 43947 39835 41120 47802 43947 32896 30583 34181 33924 37265 41891 33924 35209 41377 47802 48573 40092 34181 26728 25443 41634 46260 48573 51914 53713 51914 52942 52171 50886 52171 46774 32639 28784 30069 25957 26471 34181 42919 44975 45746 42405 34952 35723 36237 36494 41634 46774 37522 30840 39578 35980 35209 35466 35980 35209 35466 35723 34952 35723 35466 35209 35209 35466 35723 35466 35466 35466 35209 35209 35980 35980 35466 35209 35466 35209 35209 35209 35209 35209 35209 35466 35466 34952 34952 34952 34952 35209 35209 35466 35466 6168 6425 6168 6425 6682 5140 3341 3598 4626 5140 6425 7196 7196 7453 7196 7196 6682 7453 6168 5397 4626 4112 4626 3341 3855 5140 4883 5397 4626 2570 6425 31868 44461 44204 38550 48573 51914 44204 41891 43947 41120 46260 44718 36494 32639 33153 32896 36237 42662 39835 33410 24929 23901 27242 27242 26985 18761 37522 48059 45489 47288 49858 52428 51143 51914 52171 49858 49344 45489 42405 29812 41634 44718 43433 46260 47031 42148 40606 40349 36494 37522 35209 39578 43690 43690 32125 40092 38550 35209 34438 34952 35466 34695 35466 36494 36237 35980 35723 35466 35466 35723 35723 35723 35466 35466 35209 35466 35980 35980 35466 35209 35209 35209 35209 35209 35209 35209 35466 35466 35466 35209 35209 35209 35209 35209 35209 35723 35723 6168 6425 6425 6168 6682 5140 3084 3341 4883 5654 6682 7196 7453 7196 7196 6939 6425 6939 5654 5397 4883 4369 5140 3598 4626 4883 4112 5654 4112 4369 22102 48059 47031 45232 36751 49344 50372 39064 39321 45489 41891 43947 44718 37522 32896 32125 34181 37008 37008 42405 41891 38293 38807 42148 40092 32382 24929 43690 40606 38550 43433 45232 49087 48316 46003 43947 44975 38550 38550 37522 24415 31611 45232 47545 47802 44975 41120 39064 39064 39578 37522 35466 39064 43690 38036 40863 43690 38550 36751 35723 35723 35466 34181 34695 34952 34181 35980 35723 35466 35466 35723 35723 35723 35723 35980 35466 35723 35980 35980 35466 35209 35466 35466 35209 35209 35209 35209 35466 35466 35466 35209 35209 35209 35466 35466 35466 35466 35466 5397 6168 5911 6425 6682 5140 3341 3855 4369 5397 6168 6682 6682 6425 6168 6168 5397 6425 4883 5397 4883 4369 5140 3598 3598 4626 4883 3855 4112 15677 41120 44975 44204 45489 37008 49344 51143 34952 37779 42148 47545 43690 42405 35466 32382 33924 37008 37008 34695 39321 40863 43433 46003 47288 40349 24415 20046 26471 20817 22873 30840 32382 37008 38293 38550 37008 28527 25700 14135 20560 13107 22102 37265 43690 43690 41120 42405 41120 39064 41891 38807 35723 38036 30069 41891 46003 37265 41891 34952 34181 34952 35723 35723 36494 36494 35466 35980 35723 35466 35466 35723 35980 35723 35723 36494 35980 35723 35980 35723 35466 35466 35980 35466 35209 35209 35209 35209 35466 35466 35466 35466 35466 35466 35466 35466 35466 35723 35723 3855 7710 6168 4883 10023 4626 3084 4626 6425 2570 6682 8481 6682 6168 4626 6682 6168 7967 6425 4369 4369 5140 5140 2313 3855 3598 5140 5397 18761 38293 44461 45489 44461 44204 38036 49601 48059 35209 38293 43947 38550 38036 25186 32382 34695 33924 37265 40349 36751 38036 41120 41377 43176 38550 25957 20046 39835 32125 15677 15420 16962 19532 23130 23130 21588 20046 24158 19018 22616 38293 25443 11565 26214 35723 38550 36751 40863 38550 40092 42405 39835 39835 35980 32639 32896 34438 42148 39064 35980 35209 35209 35466 35466 35209 35723 36237 35466 35980 36237 35980 35980 35723 35980 36237 36751 36494 35980 35723 35466 35209 35209 34952 35209 34952 34952 34952 35466 35466 35466 35209 35466 35466 35466 35466 35723 35980 36237 36237 7196 5654 4626 9509 5654 5397 4369 771 5140 6425 5140 5397 6939 5397 5140 5140 5397 5654 4369 4369 4369 4626 5140 5140 3084 5140 5654 24929 41891 41891 45232 45232 44461 44204 38293 49087 47545 38550 39064 43690 41891 39321 42405 45232 38550 33667 36494 39578 41120 36751 42405 40606 38807 34181 19532 31868 43947 42662 40863 41120 39578 30840 19275 10280 15677 29041 36751 38550 37522 40349 33153 14906 13107 27756 34438 36494 37779 37779 41120 41377 38807 42148 48830 43947 45489 40863 45489 38293 35466 34952 34952 35466 35723 35466 35466 35723 35466 35980 36237 35980 35980 35723 35980 36237 36494 36237 35980 35466 35209 35209 35209 35209 34952 34695 34695 34695 34952 35209 35209 34952 35209 35209 35466 35466 35723 35723 35980 35980 5397 6682 9252 14906 6939 1799 4883 5397 3084 6168 7710 8224 7967 5911 5397 5397 5397 4883 4112 4112 5140 4883 3855 4626 3084 7967 36494 45489 39578 45232 45746 44718 44204 43690 39064 48830 47288 41377 37522 40863 46260 44461 48059 48830 45489 35466 35980 40606 42148 38036 38807 39835 32896 22359 25700 40349 42148 40863 42919 40606 43176 41377 37265 32639 34438 40092 37779 39835 38293 35723 40349 30840 12336 16962 26214 29041 33667 37522 40863 41891 40092 41120 46003 47802 41120 46517 43947 35980 35209 35209 35209 35723 35980 35723 35723 35980 35466 35980 35980 35980 35723 35723 35980 35980 35980 35723 35466 35209 35209 35209 35209 35209 35209 34952 34695 34695 34952 35209 34952 34952 34952 34952 35209 35209 35466 35466 35723 35980 16962 9509 32382 20046 6682 5911 2570 3084 8224 3341 5654 6425 5654 6425 5140 4369 5140 5911 5140 3855 5397 4883 2827 3855 8481 38807 44975 43690 45232 42662 45489 43690 43947 42662 39064 48830 47031 42148 32382 34438 47031 49858 47545 51143 45232 35980 38036 40863 42405 39321 37008 35723 24672 16448 37522 40863 41891 42919 44461 42405 43433 44718 44975 41891 44975 41120 39578 39835 41891 39835 41891 38550 21845 11565 22102 26985 36237 38550 37265 39064 38293 42662 48830 44718 44204 43947 37522 34695 35466 34952 35209 35980 36237 35723 35723 35980 35466 35980 35980 35980 35723 35723 35723 35980 35723 35466 35466 35209 35209 35209 35209 35209 35466 35209 34952 34952 35209 35209 35209 34952 34952 34952 34952 34952 35209 35466 35466 35723 42405 39835 35209 7710 4883 3855 4112 2827 3855 6168 5654 5911 5911 4112 4883 5911 5140 5140 5654 4112 4626 3855 5397 13878 33924 40092 44975 44461 44461 45232 45489 45489 44975 42405 39578 49858 47802 41377 27499 27499 42405 48059 47288 48573 31097 34438 40349 37779 44461 38293 39835 29298 17476 24929 38036 41634 43176 46517 44975 46774 45232 47802 51143 49344 49344 46517 46517 41120 42662 43690 42662 40092 37522 21845 18761 26214 33410 37008 39321 42662 39064 37779 49087 47288 40092 39578 37779 34952 34952 34695 34952 35980 35980 35723 35466 35723 35723 35980 35980 35980 35723 35723 35723 35980 35466 35466 35209 35209 35209 35209 35466 35466 35466 35209 35209 35209 35466 35466 35209 35209 34952 34952 34952 35209 35209 35466 35466 35466 51914 42148 26471 7196 4112 6682 2570 3855 10794 19275 8995 6425 8224 2827 5397 6168 5140 4112 5654 5140 4626 4112 11051 28527 40606 41377 44718 47288 43176 43176 47545 46517 45232 42662 39578 49858 49087 40606 25443 22102 28013 39578 43176 31354 8481 23901 36237 43176 43433 41120 39578 27242 19532 34695 35209 43690 43176 46003 43690 48316 44975 47031 51143 49601 49344 48316 47031 46260 46517 44204 42919 40349 39321 33924 20046 34438 38550 41377 42148 38807 38807 25186 30326 39064 34952 41377 39578 34695 34952 34438 34695 35209 35466 34952 35209 35466 35723 35723 35980 35980 35723 35723 35723 35980 35723 35723 35466 35466 35466 35466 35723 35723 35209 34952 34952 34952 35209 35209 34952 34695 34952 34952 34952 34952 35209 35466 35209 35466 47545 43947 12850 5911 6939 3341 3084 15677 32125 22616 7196 3084 6682 5140 4369 3084 4883 4883 5911 4626 5654 6682 12850 30069 35209 44204 44461 45489 43690 43690 49087 43690 43947 43176 40092 48573 49601 40863 27242 20560 25443 29555 29812 15420 6425 21588 34181 40349 40863 44461 41377 31868 27756 36494 37008 40349 38293 34952 32639 34181 32639 35209 42662 44718 40092 36751 33153 36237 36751 35723 37265 41120 37265 39578 27499 38036 42919 43433 43176 39064 34438 19532 19789 27756 46260 41891 36494 34438 35209 34952 34695 35209 35209 34952 35209 35723 35209 35723 35980 35723 35723 35466 35723 35980 35980 35980 35723 35723 35723 35723 35980 35980 35209 34952 34952 34952 34952 34952 34952 34695 34952 34952 34952 34952 35209 35466 35466 35723 50372 43947 16962 6168 3855 5140 3084 19018 29041 6425 7196 6939 3855 6168 3084 6168 3855 5140 6168 2570 4883 8224 10280 20817 32382 42148 44975 45489 44718 43433 45746 46517 43176 43176 40092 47288 49601 41377 29555 20560 21588 26728 37008 27242 11308 11565 35209 40863 41377 43433 48316 36494 33924 35209 37522 33924 23644 17476 19532 19789 20046 19789 24158 26214 20303 20046 20560 19789 17219 19275 19018 25700 30069 36237 40349 42919 48573 42662 38807 39835 38293 17476 23130 36751 39321 35980 38036 34695 35723 35209 35466 35466 35466 35209 35466 35980 35209 35723 35980 35723 35723 35466 35723 35980 36237 36237 35980 35723 35723 35980 35980 35980 35466 35209 35209 35209 35209 35209 35209 34952 34952 34952 34952 34952 35209 35466 35466 35723 57311 51143 34695 6939 5140 4369 2313 18761 13364 8481 6168 5654 7196 3341 3855 5397 4883 5654 5654 3598 3855 9252 12850 11822 30840 38550 45489 45746 46260 43433 46517 46003 43690 43176 39835 47288 47031 34695 28784 21074 17219 15677 13878 15420 11308 10280 29812 37522 40863 43947 46774 46517 33667 32125 25443 20560 17219 23387 25957 27242 30326 28784 23901 22359 25443 33667 41634 39835 37265 40092 39321 36494 33410 37779 38807 47545 45489 44461 40606 40349 33667 20817 24929 35466 42662 42919 35466 36494 35209 35466 35466 35980 35980 35723 35723 35723 35980 35723 35723 35723 35723 35723 35723 35723 36751 36237 35723 35466 35723 35723 35466 35209 35723 35723 35723 35723 35209 34952 34952 34695 34438 34695 34952 35209 35209 35209 35723 35980 38550 43176 44204 16448 2827 5911 514 25443 15420 4369 6682 5397 5140 5140 4369 5397 5140 5397 5397 4112 4626 8995 12079 11565 24158 39578 44975 45232 45489 44204 46517 46003 43947 42405 40092 48059 44204 30069 28270 28270 15677 7967 3855 8224 10794 11565 26985 37265 39321 39064 45232 46774 40349 34952 36237 35209 37265 37779 38807 42405 45489 43947 43176 45746 45746 42405 44204 45489 43947 41120 38550 38807 41377 35466 44204 46003 44975 40349 42919 39321 30583 21074 27499 36494 44718 41891 36494 35209 35723 35723 35723 35980 35723 35723 35723 35723 36237 35980 35723 35723 35723 35723 35723 35723 35980 35723 35723 35466 35209 35209 35466 35723 35723 35723 35723 35723 35209 34952 34952 34952 34695 34952 35209 35466 35466 35466 35723 35980 20303 3084 23387 29555 6425 3084 6168 38293 24415 2827 5654 4883 3598 5911 3598 5397 5397 4883 4626 4369 5140 8738 11565 11051 16448 37779 45232 45746 45232 44461 46003 44975 43176 42405 40349 47288 42148 28013 29555 33153 29812 16448 8481 8481 10537 9766 19789 33667 36751 39578 46003 43433 40606 34695 41634 38036 37265 39064 39321 38807 42405 46517 45746 42405 43176 41120 41634 39321 35980 35980 38807 43433 42662 35466 42919 47288 40349 40349 39578 36751 24158 22616 31097 37265 41891 36494 36237 36237 36237 35980 35980 35723 35723 35980 36237 35980 36237 35980 35980 35723 35723 35723 35723 35723 35209 35466 35723 35466 34952 34695 35209 35723 35723 35723 35723 35723 35209 35209 34952 34952 35209 35209 35466 35466 35466 35466 35723 35980 7196 5654 4626 7196 4626 4626 3598 29298 33667 7453 5654 5397 4883 5397 2570 5911 5140 4883 4369 3341 4369 8738 11822 10537 11565 30840 45746 46260 45232 44975 45746 44461 42919 42919 39835 46003 42148 30583 31611 32125 37522 36237 30840 15934 7453 6939 14392 30583 37008 37522 41377 45232 42148 33410 40349 41377 37779 35723 34952 34695 32896 31097 29555 27499 25443 26728 30069 31354 34952 41634 42919 41120 40092 35980 41377 40349 40606 36494 37265 32382 22616 25700 31354 35723 37265 33153 36494 36751 36751 36237 36237 35980 35980 35980 36237 36237 36494 36237 36237 35980 35980 35723 35723 35723 35466 35466 35466 35466 34952 34952 35209 35466 35723 35723 35723 35723 35466 35209 35209 34952 35209 35209 35466 35466 35209 35209 35466 35723 4883 6939 4626 6168 4626 3855 2313 6168 28013 11051 6425 5397 6939 4626 3598 6682 4883 5140 4883 3341 4369 10023 12593 10537 11308 21331 42662 46003 44975 44975 45746 43690 42662 42148 38807 45489 43176 32382 32125 30840 35723 33410 37779 38036 29812 13878 7196 24929 33667 36751 36494 42662 37779 36237 39321 40092 42662 40863 39321 35466 29812 25957 25957 26471 26985 24415 26471 29555 34181 38807 38036 35980 40863 39835 38807 38550 37779 34952 36751 26985 26214 30326 29041 34695 35723 36494 37008 35723 36494 36494 36494 36494 36494 36237 36494 36237 36751 36494 36237 36237 35980 35980 35980 35980 36494 35980 35466 35466 35466 35466 35466 35209 35723 35723 35723 35723 35466 35209 35209 34952 34952 34952 35209 35209 34952 34952 34952 35209 5911 4369 5911 4626 2827 4626 4883 4626 10280 8481 6168 4112 6425 4369 5140 5397 4883 4883 4883 4626 6425 11308 13107 10537 12336 14392 34181 43690 44204 44461 45746 42662 43433 41634 38036 45746 43176 30840 31097 31868 36237 33667 34181 34438 33410 25700 14392 22359 31097 38036 35209 36494 32639 40349 41377 37008 35209 37779 37522 36237 38807 43176 44718 42919 41634 39064 39321 37008 34181 34695 37008 40606 41634 41120 37779 41891 34181 35723 36237 21074 28013 33153 30840 35466 35209 37265 36494 35723 36494 36751 37008 37008 37008 36751 36494 36237 37008 36494 36494 36237 36237 36237 36237 36237 37008 36237 35723 35466 35980 35980 35723 35209 35980 35980 35980 35723 35466 35209 34952 34952 34695 34952 34952 34952 34695 34695 34952 35209 6939 3084 5140 7453 5911 2827 514 3341 1799 4883 5911 3341 4883 4112 4883 3855 4626 3855 5397 7710 10023 12336 12336 11051 12336 12850 22359 40092 42662 43690 45232 42662 43176 42148 39064 45489 42148 30583 31868 32639 32896 32382 33153 33153 31097 24672 14649 21845 35209 33410 33153 37008 38807 40092 41377 43176 42919 40863 39835 43947 49858 49858 48316 48830 49087 47545 48830 48059 46774 46774 46260 46003 40606 37008 39064 35466 37008 32896 37779 22359 27756 34438 34952 36751 35209 36494 35466 37008 36751 37008 36751 36751 36751 37008 36751 37008 36494 36494 36494 36494 36237 36494 36494 36494 36751 36494 35980 35980 35980 35980 35980 35980 36237 36237 35980 35980 35466 35209 34952 34695 34695 34952 35209 35209 34952 34952 35209 35466 4369 6682 4883 5654 2056 3084 4112 3598 5140 4112 5911 4112 4883 4112 5140 4112 4626 2827 5397 10794 13107 12850 11822 11565 11565 13621 13621 37265 41377 43690 44975 42148 41891 43947 40863 44718 41120 32382 33410 31354 31868 33924 33924 33410 33667 30840 18247 17990 37265 31611 34181 35209 40863 37265 38807 40606 37265 41634 41634 42405 47802 50372 50115 50886 49858 46260 47288 49344 49344 47802 44975 45489 38807 37008 34438 29298 35209 34695 37008 32125 29812 34952 36751 35723 36494 37008 36494 37265 37265 36751 36751 37008 36751 37008 37265 37522 36494 36494 36494 36494 36494 36494 36494 36751 35980 36237 36494 36237 35723 35723 35980 36494 36494 36237 36237 35980 35466 34952 34695 34695 34952 35209 35209 35466 35209 35209 35466 35723 4626 5397 5654 4883 3855 3084 2827 3341 5140 4626 4369 4626 4626 4112 4112 4626 3598 6425 10794 13107 13107 11822 11308 11308 11565 13107 14649 23644 40863 41120 42405 38293 40092 48316 37779 39835 38807 31097 35980 31868 32382 33667 33153 34952 32639 34181 15677 9766 34695 37522 31097 33667 35723 37522 34181 38807 40349 41377 40606 39578 43433 43690 47545 48316 44204 44718 47288 49858 49601 45746 41891 40863 34181 31097 27756 32639 32382 31097 35466 32896 33410 35209 36494 37265 37265 36751 37522 36751 37522 36494 35980 36494 36751 36751 36751 37522 37008 36751 36751 36751 36751 36751 36751 36751 36237 36237 36237 36237 36237 36237 36237 36237 36751 36494 36494 36237 35980 35723 35723 35466 35466 35466 35466 35466 35466 35466 35466 35466 4883 5397 5654 5140 3855 3084 3084 3598 3598 6168 6425 3855 3341 4369 4883 4883 6425 8995 12079 13621 13107 12336 11565 11051 11565 12850 14906 15677 34438 41120 43690 34952 39064 50115 38036 35209 33667 30326 35723 31097 36237 29298 32639 37008 33667 33153 16448 19789 42919 36751 28270 29298 33153 35466 31354 35723 40092 39835 37779 37008 40863 40606 42405 41377 38550 41891 43176 42405 42405 42148 39064 34695 30326 21588 24415 20303 24415 37522 34695 12593 36751 33410 34695 35466 37265 37779 35466 36751 36237 35723 36237 36494 37008 36494 37265 37779 36751 36751 36751 36751 36751 36751 36751 36751 36494 36494 36237 36237 36237 36237 36237 36494 36751 36494 36494 36237 35723 35723 35466 35466 35466 35466 35466 35466 35466 35466 35466 35466 4883 5397 5397 5140 3855 3341 3598 3598 4369 7196 5911 3855 4883 5654 5140 5397 10280 11308 13364 14135 13621 12593 11565 11051 11822 13878 15163 11565 24929 40606 42919 35723 37779 50372 37265 32125 30069 28527 34695 31354 34438 33667 33410 39578 31097 23387 7196 44975 44204 39321 31868 22873 20560 23901 24158 28270 35980 38036 37779 37008 37522 34695 34438 32639 33924 37522 38293 36494 35466 35723 32125 26471 20303 16962 13621 17476 32639 42405 32125 4112 14649 31097 36237 36237 36751 37265 38807 36237 35980 36237 36494 36751 36494 36237 36494 37522 36751 36751 36751 36751 36751 36751 36751 36751 37008 36751 36494 36237 36237 36237 36494 36494 36751 36751 36494 36237 35723 35466 35466 35209 35466 35466 35466 35466 35466 35466 35466 35466 4883 5397 5397 5140 3855 3341 3598 4112 4112 5397 4369 3855 4883 4369 5140 8481 12593 13107 13621 14135 13621 12850 11822 11051 12079 14135 13878 13107 16705 37522 40092 38550 37522 49087 36751 32125 30069 26985 32896 33410 36751 30583 34952 36494 28013 5911 8738 59110 37779 40606 37008 24672 13621 10280 13621 17733 25443 30326 31868 30326 27242 23130 23901 25443 28013 27756 26728 25957 25700 24672 22616 19789 14135 10023 13364 31097 37779 41120 32125 2827 5654 9252 27499 36494 35209 36494 36494 38036 36751 37008 37008 37008 37008 36751 36751 36751 36751 36751 36751 36751 36751 36751 36751 36751 37265 37008 36494 36237 35980 36237 36237 36494 36751 36751 36494 36237 35723 35466 35466 35209 35723 35723 35723 35723 35723 35723 35723 35723 5140 5397 5397 4626 3855 3598 3598 4369 4112 5654 5140 4369 4369 5397 8995 14392 13364 13364 13878 13878 13621 12850 11822 11051 11308 13107 12850 13107 12850 32382 38807 36751 39064 49087 38550 31868 29812 25957 33667 33410 35466 29812 35980 31868 5397 2570 29812 50629 30326 39321 36751 33153 22359 8995 10023 11565 15677 18761 16962 14392 11308 10537 13364 16191 16962 13878 10794 10280 12850 15420 17476 19018 15934 14906 29555 37779 38807 41634 28784 3084 4883 3598 5140 23644 38036 37779 37008 34695 37265 37008 37008 37265 37779 37779 37522 37265 37008 37008 37008 37008 37008 37008 37008 37008 37265 37008 36751 36237 36237 36237 36237 36237 36751 36751 36494 36494 35980 35723 35466 35466 35723 35723 35723 35723 35723 35723 35723 35723 5140 5654 5654 4883 3598 3084 3598 4369 4883 5397 5140 4112 5397 10023 14135 14649 12850 13107 13621 13878 13107 12593 11822 10794 11308 12336 13364 11051 13364 26214 40092 31868 41120 50372 41891 29041 26985 25443 34695 29555 32639 31868 25957 6682 3084 2313 41634 44975 22873 40349 36751 36494 30840 18247 17476 16191 15420 14649 7967 6425 5397 5911 5911 6168 6168 5911 4626 5654 11051 18504 22102 22102 19275 27499 37265 35723 40863 41120 30069 4369 2313 3855 3855 4626 21331 37008 37779 40092 37522 37779 38036 37522 37522 37779 37008 36494 37265 37008 37008 37008 37008 37008 37008 37008 37265 37265 37008 36751 36494 36237 36237 36237 36751 36751 36751 36494 36237 35980 35980 35723 35980 35980 35980 35980 35980 35980 35980 35980 5140 5397 5140 4626 3598 3084 3341 4112 4626 4369 6425 8224 8738 12593 14392 11308 12079 13107 13878 14135 13621 12336 11308 10794 11051 12593 13364 12079 14135 19789 40349 28527 42405 50629 44204 26471 24929 23644 33924 23644 30583 12593 3341 4883 3598 3341 48830 46260 16191 42148 38293 34695 32125 26214 23901 23901 22102 20303 12336 10023 7710 6939 4883 3341 3855 6168 8738 11822 18247 25957 27242 24672 24158 30326 34181 37779 37265 42405 35723 1799 5397 2313 3341 3855 1542 13364 33410 37522 36237 37522 38550 38293 37522 37265 36494 35980 37008 37008 37008 37008 37008 37008 37008 37008 37522 37522 37522 37265 37008 36751 36237 36237 36751 36751 36751 36751 36237 36237 36237 36237 35980 35980 35980 35980 35980 35980 35980 35980 5654 5654 5140 4369 3084 2570 3341 4112 4883 7196 15163 19018 14392 13107 14906 13878 12079 12850 14392 14649 13621 12079 10794 10280 10280 13364 11565 14906 12336 14649 38293 28013 42662 49344 44461 25957 24415 21588 32125 19532 4883 3855 2827 2570 4369 1542 51657 53713 13878 41120 38550 35209 34181 29298 22873 27499 26471 26471 19018 14649 8481 6939 6168 7453 6682 8995 11822 15677 22102 27242 26728 23644 26985 35980 34695 37779 38293 53713 31611 3341 3084 4626 3855 3341 3855 2827 6682 17990 32896 35723 38293 38293 37522 37522 37522 37779 37008 37008 37008 37008 37265 37008 37265 37008 38036 37779 37779 37779 37522 37008 36494 36237 36494 36494 36751 36751 36494 36494 36494 36494 36237 36237 36237 36237 35980 35980 35980 36237 5397 6168 6425 2313 4112 3084 3341 3084 7453 28270 43433 35723 13621 15420 14649 12593 13107 13878 14649 14649 13364 12079 10537 10280 11308 12593 11565 12079 14392 14392 35466 28784 40863 48830 42405 25957 16705 10280 4369 3855 3084 3598 2827 2313 3598 4112 53713 56797 17219 35723 39321 35466 33924 28784 26471 26985 27756 26471 21845 17219 15163 13364 10537 8995 9509 11051 14135 17733 25700 28784 23901 24672 30326 36751 33410 39321 46517 58082 30326 3598 3084 3341 3855 3598 3598 3341 3855 3855 2570 10280 24158 36494 39835 37265 36237 38807 37522 37008 36237 37265 37779 37522 36751 36237 37265 37779 37779 37522 36751 36751 37008 37008 37008 36751 36751 36751 36751 36751 36751 37008 35980 35723 35723 35723 35980 36237 36237 36237 5397 4626 5397 3855 5397 3598 2313 10023 34438 45489 43176 34695 23130 14649 14649 12850 10794 12079 13878 14649 14392 12850 11308 10280 9252 12850 13364 12336 11565 12593 33667 32382 31354 29555 17733 5397 2827 2827 1799 3084 2827 3341 3341 3084 4626 4112 53456 57568 17219 30583 41634 34695 31354 31097 29041 25443 27756 25700 21074 19532 17219 15163 13364 14906 17476 17219 19275 23644 28013 26728 22873 27499 33924 33667 38036 39578 59110 59110 25186 3341 3084 3341 3341 3341 3084 3084 3598 3341 4112 5140 4369 6939 19789 35209 39835 35466 37522 37522 37265 37008 36751 37008 38036 39321 38036 38036 38036 37779 37522 36751 36751 36751 37008 36751 37265 37265 37265 37265 36751 37008 36494 36494 36237 35980 35980 36237 35980 36237 4883 3855 5911 4626 3598 2570 5397 28013 44204 48830 41634 35723 36494 19789 14135 13878 12336 13364 14135 14135 13107 11565 10023 8995 11565 12079 11308 12850 14906 14392 19275 12593 3855 4369 2570 1799 3341 4626 3598 3341 3598 3598 3341 3598 4626 2827 52171 58596 10794 24672 38550 40092 34181 30326 26728 29555 28013 24929 20560 21588 18761 16705 15934 21074 21845 20046 21588 25957 28784 26471 24672 30326 32382 35723 38807 49344 60909 58596 21331 3084 2570 2827 3084 3084 2827 2827 3084 3341 4112 2056 3855 7196 4883 3598 15420 31868 38036 37265 36751 38293 39064 38550 37265 36494 37522 36751 36751 37522 37522 37265 37522 38293 36494 36751 37265 37522 37522 37265 37008 36494 37008 37008 36494 35980 35980 36494 35980 35723 5911 4369 5397 4369 2313 3341 7967 42405 45232 45489 41634 35980 43433 30583 18247 15677 12079 12850 13621 14135 13364 12336 10794 10023 8481 12336 13878 11565 6682 4369 4626 3598 3341 3598 3598 2827 1799 2313 3341 3855 3855 3341 3084 3341 4112 2313 49344 60395 16191 19018 39835 39321 33410 33667 30326 30583 29041 26214 21588 22873 20046 18761 18761 25186 24929 23901 23901 27242 30069 29555 29041 32382 33667 35466 42405 59881 57311 58339 14392 3341 2570 2827 3084 3084 2570 2570 2827 3084 4369 5140 5140 4369 4112 5140 5911 5911 12079 25957 37008 36751 34952 37265 39064 37522 39321 38036 38036 38550 37779 36237 35980 36751 36751 36751 37008 37522 37265 37008 36751 36494 37008 36494 36237 35980 35980 36237 35980 35980 6425 4369 3855 4112 3855 5654 7453 42662 46517 47031 43176 38807 46003 41377 27499 13107 12593 13364 14135 14135 12593 10794 7967 6682 7453 6425 4883 3598 3598 4626 2570 1799 2313 2570 3855 4369 3855 4369 4369 2570 3341 2570 2827 4112 4369 3084 43690 60138 47802 12079 32639 39835 35723 31354 31354 32639 31097 28784 24672 24158 22102 21588 22873 27756 27756 26214 26214 28784 30069 28784 29812 32896 36751 31868 52685 60909 59624 57568 4883 4369 3084 3341 3084 3084 2570 2570 3084 3341 4112 2827 3598 5654 6425 5397 4112 4626 6168 2313 7196 23901 37008 39578 37779 37522 37008 36751 37522 38807 38293 37265 36751 37522 37008 37008 37008 36751 36751 36751 36751 37008 36494 36494 35723 35723 36237 36237 36237 36237 4883 4883 4626 4112 4112 5140 7710 42148 43433 48573 43433 43433 47031 48573 43947 19018 13621 12850 10794 8738 6939 5140 3341 2313 2827 2313 2827 2570 2827 3855 2827 3341 3855 3598 3598 2827 2056 3341 4112 2056 2570 2827 3341 4369 4112 2313 32639 55769 61166 31868 22359 36237 34695 32125 33410 30326 32382 29555 26471 23901 24158 23387 25700 29298 26728 25186 26214 31354 30840 26214 29298 34438 30069 41377 59367 58339 60909 48316 2056 4369 3341 3084 3084 2827 2570 2570 3084 3341 3598 4369 5140 5140 4626 4369 5140 6425 4883 5911 5654 4369 6682 15677 27499 35980 38293 38550 38807 38293 37008 36494 37522 38036 37522 37265 37265 36751 36751 36494 36494 36751 36237 35980 35980 35723 35980 36237 35980 35980 4112 5140 5140 3598 3084 2827 9252 43947 45232 48573 45232 44718 47545 51914 52685 25443 7967 6939 4883 3598 2827 3341 3598 3598 4626 2827 3084 2313 1285 1542 3341 3341 771 2570 4369 4369 3855 3855 3855 3855 3084 3341 2827 3855 2827 2313 24415 53199 61166 54227 18247 30840 37008 31097 30069 32639 32896 29041 26471 23387 25700 23644 26728 29555 26985 26471 27499 32896 31611 27242 29812 33410 31611 56026 59367 59110 59110 30840 4112 3598 3341 3084 3341 3084 2570 2570 3084 3341 3341 3598 4626 5911 5911 5140 4883 5140 4626 5397 5397 5140 4369 4883 6168 7196 12593 19532 28784 34952 38036 38807 38036 36751 37522 37265 37522 37265 36751 36494 36494 36237 36751 36237 35723 35466 35980 35980 35723 35723 4883 4626 4112 3341 4369 2827 9509 41634 47802 45489 48059 45746 49858 51914 43176 13107 3855 3598 3341 3855 4112 3855 3341 2570 4112 2313 3598 4112 4626 3084 5140 2056 4112 3855 2570 2570 3598 2827 2313 3341 3341 3341 2827 3341 3084 5140 22873 56283 59624 62194 30840 17990 34695 36494 31868 30840 33667 28527 26471 23387 27499 23901 27242 29812 28270 28784 28270 31097 29555 25957 27242 25700 47288 59881 59881 59624 59881 17219 2827 3598 3341 3341 3084 2827 2313 2313 2570 3084 3598 5140 5397 4369 4883 6425 6168 4369 5911 5654 4883 4626 5911 6682 5911 4626 5911 6682 6425 6168 10537 20817 32382 38807 37522 37522 37779 37522 37522 37008 36237 35723 37008 36751 35980 35723 35980 35723 35723 35466 5654 4112 4883 3855 4112 2827 8995 40863 47288 47545 47802 45746 42148 33667 7967 4369 3598 3598 3341 3598 3341 3341 3341 3084 3341 3341 3598 3598 3341 3084 3084 3084 4112 3598 3341 3084 3084 3084 3084 2570 4369 3341 3341 2827 3855 2827 19789 57311 57311 63222 57311 16705 27499 34181 34952 30326 32382 32125 26214 24672 24158 18247 28784 26985 26471 24929 29041 31611 26985 25700 19275 38807 58339 62451 59881 59110 57825 5911 3855 2570 2827 2827 3084 3084 2570 2570 2827 3341 3084 3598 4369 5140 5397 5654 5911 5911 5654 5654 5911 5911 5654 5397 5654 5397 6168 6168 6682 6168 4626 4112 6682 10280 26728 37779 37779 36494 36751 38036 35466 37265 36237 36237 36237 36237 35723 35980 35980 35723 4883 4883 4883 4883 4626 2313 6682 41377 44975 49858 41634 7453 4626 4883 514 5397 3598 3598 3855 3855 3598 3598 3341 3341 3598 3341 3598 3598 3341 3084 3341 3084 3084 3084 2827 2827 3598 3341 3341 3341 2827 2570 4112 4112 4112 3855 14392 58853 57825 61166 62965 53970 23387 31868 32639 33924 32639 34181 27242 23130 25700 17476 21588 22873 22102 24415 24929 33153 27242 17733 30840 58596 61680 61166 63222 59110 38036 3855 2313 3341 2827 3084 3341 3084 2570 2570 3341 3598 3855 4369 4626 5140 5140 5397 5397 5654 5654 6168 6168 5911 5654 5911 5911 5911 6939 5911 5397 6425 6168 5397 5654 6168 6168 8995 26728 38293 36751 36237 37008 35466 36494 36237 36494 36237 35980 35466 35723 35723 4369 5397 3598 4626 4883 3084 5397 42919 50372 44461 7710 5397 2827 3598 4883 3598 3855 3855 4112 4112 3598 3598 3855 3598 3341 3598 3598 3341 3598 3084 3084 2827 2827 3084 3084 2827 3341 3598 3598 3598 3855 3855 4112 4369 2827 4369 8481 57311 60652 61166 65021 61937 56540 26728 34695 36237 34952 33667 28784 25186 25700 17219 21845 25443 21588 19275 30326 29812 23387 25700 58853 60652 64507 61423 62451 58596 15677 2313 2313 3341 3084 3341 3341 3341 2827 2827 3341 3598 4369 4626 4369 4883 4883 5140 5397 5654 5397 5654 5911 5911 5654 5654 5654 5911 6939 5397 5140 6425 6939 5911 4883 4369 4883 5654 7967 16191 34181 37779 36751 36494 36237 36494 36494 36237 35723 35209 35723 35723 5140 5397 3084 4112 4369 4112 4369 42148 47288 20046 3341 5911 1799 3341 3084 3084 3855 4112 3855 4112 3855 3855 3598 3598 3084 3084 3341 3598 3084 3084 3341 2827 3341 3084 3084 3341 3341 3341 3084 3084 3855 3855 3855 3855 2570 4112 5140 42919 57568 63736 63222 65021 63993 50886 25443 37008 41634 35723 31868 29298 24158 16962 25700 23901 21588 23130 33153 30069 21588 58082 61937 64250 64764 63736 60652 51143 4883 2570 3084 3084 3598 3341 3598 3341 3341 3341 3855 4112 3598 4112 4626 4883 5140 5397 5654 5140 5397 5654 5654 5654 5397 5397 5654 5911 6682 6168 6168 5911 5654 5140 5397 6425 6939 5140 4626 5911 5397 12593 32125 37008 35980 36237 36237 35723 35723 35209 35466 35466 5654 5140 3855 4112 3341 3855 3598 40606 44204 3855 7710 1285 2056 6168 3855 4112 3855 3855 4369 4369 4112 4112 3855 3598 3084 3084 3341 3084 3341 3341 2827 3084 3341 3341 3341 3084 3341 3341 3341 3341 2313 3084 4112 4112 4369 3598 3598 20303 56283 58339 65278 64764 63993 63736 42919 27756 39321 38550 37008 33924 27756 22359 31354 23644 21588 34952 31354 21588 58596 64250 63736 65021 64250 65278 62451 32382 4112 3855 3855 3598 3855 3598 3341 3598 3341 3598 4112 4112 3598 4112 4883 5140 5397 5397 5397 4883 5140 5397 5654 5654 5654 5397 5397 5654 5654 5911 5911 5654 5397 5140 5911 6939 6425 7710 4883 4883 4883 5397 15163 37779 35980 36237 36237 35980 35723 34952 34952 35466 10794 4369 4626 5397 2827 3598 4369 39064 23901 3341 1542 6168 4112 2570 3855 4883 3855 4112 3855 4112 3855 4112 3598 3598 3341 3341 3341 3084 3084 3341 3084 2827 2827 2827 3084 3084 3341 3341 3598 3855 3341 3598 3855 3598 4883 3855 5140 6425 47802 57311 61680 64507 65278 64507 63736 38293 31868 39835 43176 38807 35209 30326 36237 30069 32639 34181 26471 59110 64507 63222 65021 65021 64764 65021 60395 12079 5140 4369 3598 4369 4112 4112 3341 3598 3598 3855 4112 4112 4883 5397 5397 5911 5911 5397 5397 5140 5654 5654 5911 5911 5397 5654 5911 5911 5911 5397 5397 5654 5654 5397 5140 4883 4112 3855 7710 5911 4369 4626 4112 31097 36237 36494 36237 35980 35466 34952 34952 35466 26471 7453 4369 5140 3341 3341 4369 34695 11051 4626 3855 2056 4369 4626 4626 2313 3598 3855 3598 3855 3598 3598 3341 3341 3341 3341 3084 3084 3084 3084 2827 2827 2827 3341 3598 3341 3341 3084 3341 3341 4369 4369 3598 2827 4112 3598 5911 4369 31097 58082 61680 65278 64507 65278 63993 62451 36751 33924 39835 38293 37522 34438 35466 33410 34181 38293 58853 63479 63479 65278 65278 63993 65278 63993 43433 3598 4883 4369 4626 4369 4883 4369 3598 3598 4112 4112 4626 4626 5654 5654 5140 5140 5397 5140 5397 5140 5654 5911 5911 5654 5654 5654 5654 5911 5140 5140 5140 5140 5654 5397 4626 3855 6939 3855 7453 4112 3341 5911 4883 17733 36237 36237 36237 36237 35466 35209 35209 35209 43690 12850 3855 4369 3598 3341 3084 28784 3341 1799 4626 4883 3855 3598 4112 4626 3598 3598 3598 3855 3598 3598 3341 3341 3341 3341 3341 3341 3341 2827 3084 2827 3598 3598 3598 3341 2827 2827 2827 3084 2056 3084 3084 3084 3855 3341 4369 5911 20817 58853 58853 65278 65021 63993 65021 64250 60395 35980 41120 47545 52171 53456 52171 50115 48316 39835 61166 64764 65021 64507 64507 65278 65278 63479 23130 5140 4883 3598 5911 4112 4883 4369 3598 3855 4112 4369 4369 4626 5140 4883 4369 4369 4369 4883 5397 5654 5397 5654 5911 5397 5397 5140 5397 5397 4883 5397 5140 4883 4369 4626 4883 5397 4626 5654 4626 4626 7710 3084 5397 7710 36237 36237 36237 35980 35723 35466 34952 35209 47802 36237 4883 4369 3598 3598 5397 13621 3598 3855 4112 4369 4369 4112 3598 3598 4369 3855 3855 3598 3341 3341 3341 3598 3084 3084 3341 3341 3341 3341 2827 2570 3084 3341 3598 3598 3598 3341 3084 3084 3084 3084 3084 3598 3598 3855 4626 4883 9509 54998 59624 62965 64507 64764 65278 64764 63993 62708 61166 58853 59624 57054 47288 41120 12593 5911 15420 57568 64764 65278 65278 64507 63222 54741 5911 5654 5911 4883 3341 5140 4369 4626 4626 4626 4626 4626 4883 4883 5654 5654 5654 5397 5140 4883 4883 4883 5397 5397 5140 5397 5654 5654 5140 4626 4883 4626 4626 4626 4883 4626 4626 4369 3855 4626 4883 4883 4626 4112 3341 3598 32896 35466 35466 37008 35209 36494 34695 35980 47031 42919 18247 2827 3855 3341 4883 7710 3598 3598 3855 4112 4112 3855 3855 3598 3855 3855 3855 3598 3598 3598 3598 3598 3341 3341 3341 3341 3341 3341 3084 3084 3084 3341 3598 3855 3341 3084 3084 3084 3341 3341 3598 3341 3341 3341 3855 4112 6425 43690 60909 62194 62965 65021 63993 65021 63993 34952 20303 18761 12850 8738 7453 6168 6168 6425 3855 9766 52685 63993 65278 64507 65278 29812 5654 3855 4369 4883 4369 5140 4883 4883 4883 4883 5140 5397 5140 5140 5140 5140 5140 5397 5397 5397 5654 5654 5654 5397 5397 5654 5654 5654 5140 4883 5911 5654 5397 5140 4883 4626 4369 4112 3855 4112 4883 4883 4626 3855 3598 3598 21588 34695 37265 34952 35980 35723 35209 36751 45489 45746 34181 12079 3598 4626 6168 4112 3598 3341 3598 3855 3855 3598 3341 3598 3598 3855 3598 3598 3598 3341 3341 3341 3855 3855 3598 3341 3341 3341 3084 3084 2827 3084 3598 3598 3341 3084 3341 3341 3084 3341 3598 3341 3341 3341 3341 3598 5654 30326 57825 62451 65021 63479 65278 63993 28527 5911 1799 7453 4626 4369 6168 4626 4112 5140 7967 4626 11051 55512 65021 62708 57825 10023 6168 4626 4369 5654 5140 5140 5140 5140 5140 5140 5397 5397 5140 5140 5397 5397 5654 5654 5654 5654 5911 5654 6168 5911 5911 6168 6168 6168 5911 5654 6425 6168 5654 5140 4883 4369 3855 3598 3855 4369 4626 4626 4369 3855 3855 4112 10794 37522 37522 34952 36237 34952 36237 35980 45232 43176 44204 30583 4626 5654 5654 4112 3598 3341 3598 3855 3855 3855 3341 3598 3598 3855 3855 3855 3598 3598 3598 3341 4112 4112 3855 3341 3341 3341 3341 3341 3084 3341 3598 3598 3084 3084 3084 3341 2570 2827 3341 3341 3341 3341 3598 3598 4626 21074 57568 64507 65021 64250 63736 26728 4883 3855 6682 6939 5911 6939 5140 3855 6939 3598 2570 2827 7710 12336 58339 63993 34952 6168 5397 6168 5140 5397 5140 4883 5140 5140 5140 5140 5397 5140 4883 4883 6168 6168 6168 5911 5654 5397 5397 5397 5911 5911 5911 6168 6168 6168 5911 5654 5654 5397 5140 4883 4626 4369 4112 3855 4112 4369 4369 4369 4112 3598 3855 3855 5654 35980 34695 36751 35723 35209 37522 34952 46517 41891 47288 40863 11565 5140 3598 4369 3855 3855 3598 3855 3855 3855 3598 3855 3598 3855 3855 3855 3855 3855 3598 3598 4369 4112 3855 3598 3341 3341 3341 3341 3341 3341 3598 3598 3084 2827 2827 3084 2570 2827 3084 3341 3341 3341 3598 3598 5140 9252 51657 60909 63736 65278 25443 3341 4112 5911 5397 2827 4112 5397 4112 6939 5140 5140 5911 5397 4883 3855 21331 58853 12336 5397 4626 5397 4883 4369 5397 4369 5397 5397 5397 5140 5397 5397 5140 5140 6425 6425 6168 6168 5911 5397 5397 5140 5140 5397 5397 5397 5397 5397 5397 5397 5397 5140 4883 4626 4883 4626 4369 4112 4369 4112 4369 4112 3855 3341 3598 3598 3598 23130 35466 36751 34952 35980 37265 35723 46003 42662 44975 38550 21845 5911 2056 4112 3855 3855 3598 3598 3855 3855 3598 3855 3341 3855 3855 4112 4112 3855 3855 3598 4112 3855 3855 3598 3341 3341 3341 3341 3341 3598 3598 3341 2827 2570 2827 2827 2827 3084 3341 3341 3084 3084 3341 3341 3598 6939 32125 61680 65278 24929 5140 5654 4883 2827 3855 3855 3598 4369 3855 4883 4112 4369 3598 4112 2570 8481 3341 17219 5911 3341 6939 4883 5140 4626 5911 4626 5654 5654 5397 5397 5654 5654 5397 5397 5911 5911 5911 6168 5911 5654 5397 5397 5140 5397 5654 5654 5397 5397 5654 5654 5654 5397 5140 5140 4883 4883 4626 4369 4112 4112 4369 4112 3855 3341 3598 3598 3855 8995 37522 35980 36237 37008 35209 37779 45232 42919 42919 37522 29555 5654 3855 2827 3855 3855 3598 3855 3598 3598 3598 3855 3341 3598 3855 3855 4112 3855 3598 3598 3598 3598 3598 3598 3598 3341 3341 3341 3084 3341 3341 3341 2827 2827 2827 3084 3084 3084 3341 3084 3084 3084 3598 3855 2827 7196 17219 61166 30069 4626 2827 2827 3855 2570 5397 4883 2313 3855 4369 3341 4626 5140 5654 4112 7710 2313 5140 6168 6939 3855 7967 5654 5140 5654 5397 4883 5397 5397 5397 5397 5654 5654 5397 5397 5654 5911 5911 5911 5654 5397 5140 4883 5397 5654 5911 5654 5397 5397 5911 6168 5654 5397 5140 4883 5140 4883 4626 4369 3598 3855 4369 3855 3855 3341 3598 3341 4369 3855 30583 36237 36751 36494 35209 38036 46003 42919 42662 41377 31097 4883 5654 1542 3598 3341 3341 3598 3341 3341 3341 3598 3084 3341 3598 3855 3855 3855 3598 3341 3341 3341 3598 3598 3598 3598 3341 3084 2827 3084 3341 3084 2827 2827 3084 3341 2570 2827 2827 3084 3084 3598 4112 4626 5397 2570 8224 26985 3855 4883 4626 2570 3598 3084 4369 3598 2827 3341 3084 4883 4112 4112 5397 4883 3084 7710 5140 5911 4626 5654 5140 5397 3598 5911 4112 5140 4883 4883 5140 5140 5397 5397 5397 5397 6168 6168 6168 5911 5654 4883 4626 4369 4369 4883 5140 5140 4626 4626 5140 5397 4883 4626 4626 4626 4883 4883 4883 4626 3341 3598 4112 4112 3855 3341 3341 3341 2570 4369 18247 36751 36237 35466 37522 36751 46260 42148 43690 39835 32382 7710 3084 3855 3341 3084 2827 3341 3084 3598 3855 4369 3341 3341 3341 3341 3341 3598 3598 3855 3855 3598 3341 3341 3598 3598 3341 3084 3341 3341 3084 3084 2827 2827 3084 3084 3598 3598 3341 3084 3084 3341 3598 4112 4112 4112 7196 3855 4112 6425 2570 4112 5911 4626 5140 4112 5911 2827 5397 10023 7453 8738 11308 5397 4883 4626 4883 5911 5397 5140 4883 5140 5654 5654 5397 5140 5397 5397 5397 5397 5654 5911 5654 5911 5911 5654 5397 5654 5911 5911 5911 5654 4883 4883 4626 4112 4112 4369 5140 5654 5397 4883 4626 4369 4369 4626 4626 4626 3598 3598 3598 3855 3855 3855 3855 4112 4369 3855 8738 37008 36751 35980 37522 36494 46774 43176 43433 39835 32639 6682 2570 3598 3341 3084 3341 3598 3341 3341 3341 3598 3341 3598 3598 3341 3598 3598 3855 3855 3598 3341 3341 3341 3598 3598 3341 3084 3341 3341 3341 3084 2827 3084 3084 3084 3341 3341 3341 3084 2827 2827 3341 3855 4369 4112 6425 4369 2827 3341 2056 4626 3084 3855 3341 32639 43433 50886 54998 52428 53970 51400 47288 40349 7196 4112 4883 4112 4883 4883 4626 4883 5397 5654 5397 5140 5140 4883 4626 4369 4626 4626 4883 4883 5140 5140 5140 5654 6168 6168 6168 5654 4883 4883 4626 4112 4112 4369 5140 5654 5654 5140 4626 4369 4369 4369 4112 4369 3855 4112 3598 3598 3341 3341 3341 3341 3084 2827 5654 31354 35980 36751 37008 37265 46260 43690 42405 39578 33153 5140 2570 3341 3341 3341 3598 3598 3341 3084 2827 2827 3341 3598 3598 3598 3598 3855 3855 3855 3598 3341 3084 3084 3341 3598 3598 3341 3598 3598 3341 3341 3084 3084 3341 3341 3341 3341 3341 3084 2827 2827 3341 3598 3084 4369 5397 4369 3855 5911 6425 4112 6425 5397 26471 52171 61423 64507 65278 65278 64507 64507 61937 57054 23130 6425 4369 3855 4369 4369 4626 4883 5140 5397 5654 5397 5140 4883 4369 3855 3855 4112 4112 4369 4626 4883 5140 5911 6168 6168 5911 5397 4883 4883 4626 4112 4112 4369 4883 5397 5654 5140 4626 4369 4112 4112 3855 3598 4369 4369 3855 3855 3598 3341 3084 3084 2570 2827 2570 22616 35466 37008 36494 37779 45489 43947 41634 39578 32382 3855 3341 3341 3341 3598 3341 3341 3084 3084 2827 2827 3598 3598 3598 3598 3598 3855 3855 3855 3341 3084 3084 3084 3341 3598 3598 3341 3598 3598 3598 3598 3341 3341 3341 3341 3598 3855 3598 3341 3084 3084 3341 3855 3855 4626 4112 4369 4112 5140 6682 3341 4369 7196 44718 56540 65278 65278 63479 65278 63993 63736 60652 56797 29555 6168 3855 5397 4369 4369 4626 4883 5140 5140 5654 5654 5397 5140 4626 4112 4369 4369 4369 4369 4626 5140 5397 5911 5911 5654 5140 4626 4626 4626 4369 4112 3855 3855 4369 4883 5140 4883 4369 4112 4112 4112 3855 3598 4369 3855 3855 3598 3341 3084 2827 2827 3341 3084 2313 14135 36751 37265 36494 37522 45489 44204 41634 39835 29298 3341 3855 3598 3598 3598 3084 2827 2827 3084 3341 3341 3341 3341 3341 3598 3598 3598 3598 3598 3598 3341 3084 3084 3341 3341 3598 3341 3598 3598 3598 3598 3341 3341 3341 3341 3598 3598 3598 3598 3084 3084 3341 3855 4369 3598 3341 5911 5654 4112 6168 7196 5397 26214 51657 63736 65278 65021 65278 64507 65021 64764 61166 57825 16191 4369 4626 4112 4369 4626 5140 5397 5140 5397 5397 5654 5140 5140 5140 5140 5397 5140 4883 4883 5397 5654 5911 5911 5397 4626 4112 3855 4626 4626 4369 3855 3598 3598 4112 4369 4883 4369 4112 4112 4112 4112 3855 3598 3598 3855 3341 3341 3084 3341 3084 3084 3855 3084 3598 7967 37008 37008 36751 37008 45746 43690 42148 40092 24415 3084 3598 3341 3341 3598 3084 2827 2827 3084 3598 3855 3341 3341 3341 3598 3598 3598 3598 3598 4369 3855 3341 3084 3341 3341 3341 3341 3598 3598 3598 3598 3341 3341 3341 3341 3084 3341 3341 3341 3084 3084 3084 3598 3084 4112 4369 4626 6682 6425 4883 4883 13364 41891 56797 65021 64764 63993 65278 65021 63736 61423 59110 43947 5397 4626 6682 3341 4883 5140 5654 5654 5397 5397 5397 5654 5140 5140 5397 5654 5911 5654 5397 5140 6168 6168 5911 5397 4626 3855 3598 3598 4626 4626 4369 4112 3598 3598 4112 4369 4369 4112 4112 4112 4112 4112 3855 3855 3598 3598 3341 3084 3084 3341 3084 3341 3598 2570 3855 4112 34438 37265 37265 37008 45489 42919 42405 39835 19532 3341 3084 3341 3341 3341 3598 3598 3084 3341 3598 3598 3341 3341 3598 3598 3855 3598 3598 3598 4883 4369 3855 3341 3341 3341 3084 3084 3341 3341 3598 3598 3341 3341 3084 3084 3084 3084 3341 3341 3084 3084 3341 3598 3598 5140 5397 3341 4883 4883 4112 10794 37779 52942 63736 64507 65278 65278 65278 64250 65278 60395 53713 19275 5140 5397 5911 5397 5397 5654 6168 5911 5397 5140 5140 5397 5654 5654 5654 5654 5911 5911 5654 5654 6168 6168 5654 4883 3855 3598 3855 4112 5140 4883 4883 4369 4112 3855 4112 4369 4369 4369 4112 3855 3855 3855 3598 3341 3341 3598 3341 3084 3084 3084 3341 3341 3341 3084 3341 3598 29298 37522 37265 37522 44975 41891 42405 39835 16191 3598 3598 3855 3598 3341 3598 3598 3598 3341 3084 2827 3341 3598 3598 3855 3855 3855 3855 3598 5140 4626 3855 3598 3341 3084 3084 2827 3341 3341 3598 3598 3341 3341 3084 3084 3084 3341 3598 3598 3341 3341 3598 3855 4369 2313 5140 6682 6939 3855 11822 37522 52685 59881 64764 65021 63736 65021 64764 65278 61937 52428 44718 5397 6425 7196 4112 6425 5654 6168 6425 6168 5397 5397 5397 5654 6425 6425 6168 5911 6168 5911 5911 6168 5911 5911 5397 4369 3598 3341 3855 4369 5397 5654 5140 4626 4626 4369 4626 4883 4883 4626 4369 3855 3855 3598 3341 3084 3341 3341 3341 3341 2827 3084 3084 2827 3855 3855 2827 4112 25443 38036 36751 37779 43176 42919 42405 40863 13107 3084 4112 2570 4112 3855 3341 3084 3084 3084 3084 3341 2827 2313 4883 1028 6168 3855 2570 4112 4112 3084 2827 4626 1799 3341 3341 2313 1799 5397 3598 2827 3341 3598 4626 3084 4112 4112 3855 3598 3341 3341 3598 3855 4883 2827 6425 5911 6168 5397 39321 49344 58596 64507 63993 65021 65021 65021 64507 63736 54227 48573 15677 6682 6939 5911 4626 6425 6939 6425 5911 5911 5140 4369 4369 5140 6168 3855 6168 5397 4883 6168 5140 4883 5654 4369 4883 2827 5654 3341 4883 4883 5140 3341 5140 3598 5140 5654 4883 4626 4883 4112 4369 4112 4112 4112 2827 3341 3855 3855 3855 3598 3341 3341 3341 3341 4369 3084 3341 4626 20560 37779 38807 37522 43690 42919 41891 40863 10023 2570 4112 3084 3855 3598 3341 3341 3084 3341 3084 3598 5654 2313 3084 6682 2827 2827 7967 3084 4369 4112 4112 5654 2570 3855 4112 4112 2570 1799 2827 3341 5654 5911 1028 6168 3855 3855 3855 3341 3084 3084 3341 3598 3598 4883 4626 4369 6168 8481 32639 50115 57054 65021 65021 64764 65021 65021 62451 55255 40606 29041 8995 5140 5654 6682 5140 5911 6425 6168 5397 5654 5397 4626 4626 5140 5911 4369 5654 7196 6682 5911 6682 6682 5397 5140 4112 3598 2056 3855 4883 4883 6425 3598 7196 2570 3598 3341 4369 4883 4369 3341 3341 3855 4369 4369 3855 4112 3598 3855 3598 3598 3084 3598 3341 3598 3855 3341 3855 4112 17219 38293 38807 38036 44718 41891 41120 40606 6425 2313 4112 3855 3598 3084 3084 3341 3084 3341 3084 3084 1799 3598 33667 35466 35980 31354 28527 23644 21588 18504 13621 10537 5140 4626 3341 2570 4883 3855 4626 3598 2056 5397 2313 3598 3855 3855 3598 3341 3084 2827 3084 3341 2827 6168 2827 4112 5140 7710 19532 47031 55769 62194 63993 65021 65021 63479 53713 38550 29041 12079 5397 5911 5654 7453 5654 5654 6168 5654 5654 5911 5911 5140 4883 5397 4883 6682 4883 5140 4883 5140 5140 3598 4369 5654 5654 6425 3084 5654 5397 4883 3084 5397 4626 4883 6168 5654 3341 3598 4626 4112 3855 4112 3855 2827 2570 3084 3084 3341 3341 3341 3084 3598 3341 3598 3855 4112 4112 4112 12850 39064 38550 39064 44461 41634 40863 39321 3855 2827 3855 3855 3084 3084 3341 3598 3341 3341 3084 3084 7453 2056 34181 47802 65021 65021 62965 37008 37779 39578 41377 45746 46774 47545 43433 40349 34438 32896 25700 19789 3855 771 6425 4369 3855 3855 3598 3341 3084 3084 3084 3341 3341 4883 2827 5654 5140 5140 7967 38807 49601 60395 64764 63993 61680 56026 40092 26214 21588 6425 6425 6939 6168 6425 5911 5397 5397 5654 5911 5911 5911 5397 5397 5397 3598 6939 5911 5654 6168 5654 6682 19275 14906 16448 17476 17476 17219 16962 16962 17476 18504 28784 5140 4369 3855 4626 2570 5140 3341 3598 3084 4626 4369 2827 3598 4112 2827 3084 3341 3084 3341 3598 3341 3855 3598 4369 4112 3341 8995 38550 38036 38550 43433 41377 41634 35723 3341 3341 3341 3341 2827 3084 3341 3598 3341 3341 3084 3084 2570 8224 36494 50372 63993 64507 53713 31354 37522 38807 38550 41120 42662 46517 46774 47545 45746 46003 43433 43947 24672 4626 1542 2313 3855 3855 3855 3598 3341 3341 3855 3855 4112 3341 4626 6425 6168 5911 4883 25700 46260 56026 62965 60395 54741 39578 27242 31097 12593 5140 6168 5911 6168 4112 5397 5654 5140 5654 5911 6168 5911 5654 5654 5140 7967 4626 3598 5140 7453 4112 4369 35980 21588 22873 21331 21331 23130 22873 22359 25443 22873 45489 7710 4369 4883 5140 4626 4626 5140 4626 2827 4369 4112 2056 3084 2570 3084 3341 3341 3341 3598 3598 3855 3855 3341 4112 3341 2827 6168 34952 37265 37779 43176 41377 42148 29298 3598 4112 3084 3341 3341 3084 3341 3341 3084 3341 3084 3084 1799 10794 43176 47802 54741 58082 51914 41377 36751 42405 44975 47031 46003 46774 45746 47031 46774 44461 43433 44975 39321 20046 4626 3598 3598 3855 4112 3855 3598 3598 4112 4369 4883 3341 5140 4626 5654 6939 5654 11051 45746 49858 57311 56283 43176 33410 35980 34952 5654 5140 5911 5140 6682 3855 5397 5397 5397 5911 5911 5911 5911 5911 5397 5140 4626 5397 7710 4369 5140 5654 5397 39321 21845 22359 22616 22616 23130 23130 23387 23901 25186 44975 10537 4883 4626 2570 5654 3341 2570 3855 3341 5911 5140 1799 3598 3598 3341 3341 3341 3598 3855 3855 4112 3855 4112 4112 4626 3855 5397 30583 37779 38036 42919 42405 42148 22102 4112 3855 2827 3341 3598 3598 3598 3341 3084 3341 3084 3341 5654 14906 43947 54227 52942 49601 57054 38293 35723 43690 48316 51400 51143 51400 49601 50886 50629 49087 48059 46517 48830 38807 20817 2056 3341 3855 4112 4112 3855 3855 4369 4626 4883 4369 4626 4626 5140 5654 6425 4369 34438 51143 55769 47288 34695 39835 49858 20303 4883 5397 5911 5140 5911 5397 5397 5397 5654 6425 6425 5911 5397 5654 5397 4883 6168 4883 4626 6939 23644 40092 26985 28270 25186 21331 30840 25186 25957 22359 29812 20817 32896 35980 23387 32382 26471 23644 19789 17733 19018 25700 28013 26985 16191 3855 3084 3855 3341 3855 3855 3855 4369 4369 3855 3855 4626 4112 5911 4112 4883 24672 38293 39321 42919 42662 42148 17476 4369 3598 2827 3855 3855 3598 3598 3341 3084 3084 3084 3341 3855 19532 33153 44718 57568 55769 38293 31354 34695 39578 40092 41377 42148 44204 43947 46003 45746 44718 43947 42919 43947 42148 39064 8481 3341 3598 3855 4112 3855 3855 4369 4626 3855 4626 3598 6682 5911 3855 7196 6425 18761 50372 48059 39835 35466 35723 40092 4112 5397 3598 5140 4112 4369 6425 5140 4883 6168 6682 6425 5654 5397 5911 5397 4883 4369 6425 11051 21074 42662 62451 44975 27499 35723 25957 44461 29555 33924 25443 42405 25186 47545 28270 27756 49601 34695 32896 22616 24929 20817 34695 42662 40092 22102 3341 2056 4626 3855 4112 3855 4112 4369 4369 4112 3855 3855 3855 5654 3855 4112 20046 37779 39321 44204 41634 42405 10023 3598 4369 3084 3084 3084 3084 3341 3341 3084 2827 3084 3341 4112 13621 23901 28784 28270 28270 31868 36237 36494 37779 39578 40863 41891 42662 44204 45489 42662 43433 41891 41891 41634 40349 39578 8224 3084 3341 3598 3855 3598 3341 3341 3084 4112 4369 4369 4369 4626 4626 4883 5140 4112 46260 44718 29298 20046 36751 10794 3598 5140 4369 3598 3855 4626 5397 5397 5654 7196 5654 4626 5397 6168 5397 5140 5911 5654 12079 20046 26728 47802 61166 44975 26728 35209 25700 46774 32125 36751 30326 43176 27499 47288 30840 26985 45232 36237 32639 24415 23901 22359 30069 38036 41377 21588 4369 3598 4112 3855 4112 4369 4112 4369 3855 4112 4369 4369 4626 5140 3598 5140 15420 37779 39321 43690 41891 40092 7967 2827 4112 3084 3598 3598 3598 3855 3598 3598 3341 3855 3855 2313 3341 4112 3084 1799 2570 5397 8224 10023 12079 14906 18247 21845 25186 28527 30326 34181 36751 37522 38550 39064 39321 35723 7710 3084 3341 3341 3341 3341 3341 3598 3598 4112 4112 4112 4369 4369 4112 4369 4626 5911 23130 36494 17990 14906 24415 3084 4883 5140 4626 4369 4112 4626 4883 4883 5397 4883 4626 5397 6168 5140 4369 4883 6425 13107 22359 26471 25186 22873 30326 22359 23644 30326 39578 35723 30840 32125 38550 27242 28784 34952 28013 22359 25443 22102 24672 21845 19275 20560 20817 22102 30840 9766 2313 2827 4369 3855 4112 4626 4883 4369 4112 4112 3855 4626 4369 4883 4626 4883 11822 38550 39578 42919 42148 35466 5397 2570 4112 2827 3855 3084 3341 3341 3341 3084 3084 3598 3598 3855 3341 3084 3341 3598 3598 3598 3341 4112 4112 3855 3341 2827 2570 3084 3341 4112 3598 4883 8224 8995 11308 13621 3855 3084 3084 3084 2827 3084 3341 4112 4369 4112 4112 3855 3855 4112 3855 3855 4112 4626 6682 21074 15163 15934 8481 3084 4369 4112 3855 4112 4369 4626 4883 5397 5654 5911 5397 5397 5140 4883 6168 10280 14906 31868 44975 45232 39835 20046 20046 20817 34952 41891 48573 19018 37522 46260 58596 16962 23387 44204 38807 29555 22616 22359 22102 21074 20817 21588 20046 21074 34695 7967 4369 3341 5140 3855 3855 4626 4883 4369 4112 4112 4112 4369 4112 4369 5911 4369 7453 39321 39321 42148 42148 30840 3084 2313 4112 2570 3855 2827 2827 3084 2827 3084 2827 3341 3341 2827 3084 3341 3855 3855 3855 3598 3598 3598 3855 3855 3598 3341 3084 3598 3855 3598 2056 3341 4369 1799 2056 3084 3084 3084 3084 2827 2827 3084 3341 3855 3855 4369 4112 3855 3598 3855 3855 3855 3598 3084 3855 7710 16191 14392 2056 5654 3598 3341 3855 4112 4112 4112 4626 5397 6168 6682 5911 5397 4626 5654 8738 14649 19532 35980 46774 43690 38807 21074 20303 20817 29812 41377 49344 25186 38036 40092 53970 23130 28527 42919 36237 27756 22873 24415 21331 19789 21331 22616 21845 23901 33410 9766 4112 2056 2827 3855 4369 4369 4369 4369 4369 3855 4112 4369 4626 4369 5911 4112 4626 40092 38807 41377 41377 25957 2827 3084 4112 2313 3598 3341 3341 3598 3341 3341 3084 3598 3598 3855 4369 4112 3341 2570 2313 2827 3341 3084 3341 3598 3598 3341 3084 3084 3084 3084 3598 5140 2827 3084 6425 4112 2313 3084 3084 3084 3084 3084 3084 3084 3084 4112 4112 3598 3855 3341 3341 3341 3341 4369 3341 4626 9766 6425 4626 3084 5140 4369 4112 4112 3855 4112 4369 4883 5654 5397 5140 4626 5140 6168 7710 10280 12079 17476 21331 16962 15934 9766 10537 10280 11565 14906 16191 7196 9766 9252 17733 8995 9766 12593 10023 6939 6168 6168 6682 5654 4883 6425 4883 5654 9509 3341 2313 4369 5140 4112 4369 4369 4112 3855 4112 4112 4369 4112 4626 4626 4883 4369 4626 38293 38550 41634 40092 21074 3341 3598 4112 2570 3341 3084 3084 3341 3084 3084 3084 3084 3598 3598 3598 3855 4369 4883 4626 4112 3598 3855 4112 4369 4626 4626 4626 4369 4112 4626 3855 5397 2056 2313 3855 2827 3084 3341 3341 3084 3084 3084 3084 2827 2827 3598 3598 3855 3855 3598 3598 3598 4112 4369 3855 4883 3855 2570 5654 2827 3855 3598 3855 3855 4112 4369 5140 5654 6168 5140 4626 4369 4626 5654 5911 5140 4883 5397 5654 4883 6425 6168 5911 6682 7196 6682 5654 6425 7710 7453 6168 5654 6682 6168 5654 5911 8224 4112 5654 5397 4883 6425 4369 4112 1542 4112 2313 4369 3855 4369 4369 4112 3855 3855 4112 4112 4626 4112 4626 4883 3855 4626 4626 32639 38807 42662 38807 17476 3855 3855 3341 3084 3341 2827 2570 3084 2570 2827 2827 2827 3341 4883 3598 2313 1799 2570 3341 3598 3598 3341 3341 3341 3341 3341 3084 2827 2570 2313 514 4626 4112 5140 1799 2827 4626 3341 3084 3084 2827 2827 2827 2827 3084 3341 3341 3598 3855 3855 3855 4112 4626 3598 5140 3855 4369 3341 4112 5140 3084 3598 3855 4369 4626 5397 5654 5911 5911 5140 4883 4883 4369 5140 5140 5654 5654 6682 5654 7196 8224 6682 5654 4883 6168 6939 8224 6939 4883 5911 8481 7967 4112 5654 5397 5654 7710 5397 4626 5140 6425 4112 5140 6425 4112 4626 3084 3341 3084 4112 4112 4112 4112 4112 4112 4112 4369 4626 3855 4883 3341 4883 4112 24929 39578 43433 38036 15420 4112 3855 2827 3598 3341 3084 3084 3341 3084 3084 3341 3341 3598 3341 3598 3855 3855 3855 4112 3855 3855 3855 3598 3598 3598 3598 3598 3598 3598 4369 2056 4369 1542 4626 3341 5397 3084 3598 3084 2827 2570 2570 2827 3084 3341 3341 3341 3598 3855 3855 4112 4369 4626 5397 2570 3084 5397 2056 3855 4883 4626 5397 5140 5140 5911 5911 5397 4626 3855 3598 4369 5140 5140 5140 5140 5911 6168 5911 5397 5911 5911 4369 7196 5911 6168 5140 5911 5654 8738 6682 5140 5140 6682 5654 6939 5911 3341 5397 5911 4883 4369 4883 4883 4883 4626 2313 4369 3855 5140 4112 4112 4626 4369 4112 4369 4112 4112 4883 2827 4883 3341 5140 3341 19275 40349 \ No newline at end of file diff --git a/Tests/images/hopper_1bit.pbm b/Tests/images/hopper_1bit.pbm new file mode 100644 index 000000000..216a94ffa Binary files /dev/null and b/Tests/images/hopper_1bit.pbm differ diff --git a/Tests/images/hopper_1bit_plain.pbm b/Tests/images/hopper_1bit_plain.pbm new file mode 100644 index 000000000..9f5c6e501 --- /dev/null +++ b/Tests/images/hopper_1bit_plain.pbm @@ -0,0 +1,14 @@ +P1 +128 128 +111111111111111111111111111111000001 +111110111100000000111111111111111111 +111111111111111111111111111111111111 +111111111111111111111111111111111111 +111111111111100101111111101111100000 +001111111111111111111111111111111111 +111111111111111111111111111111111111 +111111111111111111111111111111111111 +011111111011111110000001111111111111 +111111111111111111111111111111111111 +111111111111111111111111111111111111 +1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 0 0 1 0 0 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 0 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 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1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 \ No newline at end of file diff --git a/Tests/images/hopper_8bit.pgm b/Tests/images/hopper_8bit.pgm new file mode 100644 index 000000000..23d7ada96 Binary files /dev/null and b/Tests/images/hopper_8bit.pgm differ diff --git a/Tests/images/hopper_8bit.ppm b/Tests/images/hopper_8bit.ppm new file mode 100644 index 000000000..a63406cf4 Binary files /dev/null and b/Tests/images/hopper_8bit.ppm differ diff --git a/Tests/images/hopper_8bit_plain.pgm b/Tests/images/hopper_8bit_plain.pgm new file mode 100644 index 000000000..37d152c73 --- /dev/null +++ b/Tests/images/hopper_8bit_plain.pgm @@ -0,0 +1,4 @@ +P2 +128 128 +255 +25 22 14 26 29 29 18 22 34 35 27 23 30 30 26 30 36 37 32 24 22 23 24 31 33 30 21 31 22 110 229 162 181 165 183 117 22 39 36 18 51 173 71 20 38 121 205 235 247 242 240 239 235 197 46 58 103 91 93 94 100 98 105 102 100 89 100 94 93 100 100 98 97 95 95 95 95 96 99 101 100 99 97 97 100 100 101 102 100 100 100 99 98 99 99 98 98 98 98 99 99 99 99 99 99 99 98 98 99 100 101 101 99 98 99 102 108 112 115 115 116 116 116 115 112 111 111 112 25 22 16 27 28 28 17 20 32 33 25 21 29 29 27 32 34 37 31 22 21 21 23 29 25 32 26 27 30 131 177 92 174 59 48 88 63 31 20 27 56 168 73 29 17 31 80 145 201 241 243 241 236 205 42 38 92 95 99 83 73 81 92 98 98 101 98 98 103 96 92 99 99 95 95 102 103 97 95 97 100 99 98 99 101 101 103 102 102 101 102 100 99 99 99 98 100 98 98 98 98 99 99 100 100 100 99 99 98 98 98 99 102 101 100 101 106 109 114 115 117 117 118 116 114 113 113 114 25 24 17 28 28 27 15 19 31 32 23 20 28 29 26 32 31 35 31 23 22 23 24 29 35 29 22 28 34 119 98 62 169 67 29 30 24 33 45 21 72 173 57 18 28 35 24 39 52 201 236 240 237 224 138 29 36 41 37 29 52 38 41 52 45 64 83 102 100 113 97 108 99 99 98 98 97 97 101 106 101 100 100 101 102 102 102 102 105 103 103 102 102 100 99 99 101 100 98 98 98 99 100 101 100 99 99 99 99 98 98 98 103 102 101 101 103 107 112 117 117 118 118 117 115 114 115 116 23 22 18 29 29 26 14 19 32 34 23 21 28 30 26 33 31 37 31 23 22 24 25 28 38 27 21 29 29 70 41 81 179 60 24 25 30 27 36 21 56 176 62 22 22 30 31 33 31 190 246 145 128 172 57 26 39 29 26 79 126 122 74 53 47 47 47 41 80 96 107 93 98 100 98 97 103 109 103 92 102 102 102 103 104 104 103 101 104 103 103 102 102 101 101 101 101 100 100 99 99 100 101 101 98 99 99 99 100 100 99 99 100 101 101 100 101 105 111 116 114 115 115 114 114 114 115 116 21 22 19 28 28 25 15 21 33 34 25 21 28 30 27 32 31 36 33 23 22 24 25 27 23 31 28 23 22 36 21 85 166 48 29 24 36 36 31 19 88 169 33 26 29 24 35 32 45 205 202 47 27 18 32 31 40 152 139 73 136 238 113 32 122 168 79 47 42 53 96 111 101 103 105 104 101 101 104 107 103 103 104 104 106 105 103 102 102 102 103 103 102 102 102 102 102 102 102 102 102 102 102 101 101 101 101 101 101 101 101 100 98 100 102 101 101 103 107 111 109 110 111 111 111 111 112 113 21 22 20 30 28 25 15 22 33 34 25 21 29 29 25 30 30 36 32 21 19 22 23 25 26 34 26 21 26 25 22 83 176 51 34 30 34 27 22 34 90 175 40 30 23 25 31 20 47 216 85 43 20 21 26 88 234 250 252 210 139 253 170 159 249 253 243 170 41 47 54 95 107 96 95 108 110 101 97 103 106 104 105 106 106 106 104 102 100 100 101 101 103 102 103 103 102 103 103 104 103 103 102 101 104 103 102 101 100 100 100 100 100 101 101 101 101 102 103 105 106 106 107 108 108 109 110 111 20 24 22 32 28 24 15 21 30 32 24 22 30 31 26 31 30 36 31 21 18 22 22 24 35 31 21 23 25 24 26 84 167 54 25 25 38 37 29 19 84 169 40 20 20 37 31 40 46 184 164 148 28 23 124 248 222 157 233 244 254 249 242 253 246 209 205 230 194 50 43 136 193 154 117 103 104 105 106 107 106 105 105 105 105 105 104 103 100 101 101 101 103 102 102 102 104 104 104 103 103 103 103 103 105 103 102 100 99 99 100 101 102 101 100 101 102 102 102 101 103 105 107 108 108 108 109 110 22 25 22 33 29 24 13 20 27 30 24 21 30 31 26 31 32 39 33 20 18 21 23 24 24 27 25 26 18 28 27 77 170 60 21 31 37 26 30 28 109 157 30 23 31 31 29 108 216 251 254 135 24 66 122 86 121 95 74 102 166 225 222 164 101 88 130 123 73 101 35 51 235 252 246 201 143 108 103 107 107 106 106 104 105 105 105 103 101 101 101 101 102 102 102 102 106 105 103 102 102 103 104 104 103 102 100 98 98 99 101 102 102 101 99 100 102 104 104 104 104 106 107 108 109 109 110 110 23 27 115 40 24 22 16 17 28 35 22 18 42 34 23 29 27 39 26 24 18 22 17 21 29 28 29 20 19 25 30 79 172 53 26 32 34 35 30 26 98 162 31 35 25 44 194 247 255 250 254 105 30 28 29 136 190 242 232 143 233 198 212 200 147 245 217 212 83 26 47 37 184 254 248 252 251 209 127 106 110 108 100 114 96 112 107 102 103 103 104 103 104 103 103 104 105 103 102 103 103 102 103 105 101 101 100 99 99 100 102 104 100 102 104 103 102 101 102 103 103 103 103 103 104 105 107 107 22 37 204 90 36 15 21 17 37 26 13 20 40 22 29 30 36 34 26 26 21 16 18 27 28 27 24 24 31 27 28 74 170 53 25 33 35 34 28 24 100 162 32 14 78 227 248 253 245 253 249 86 26 33 33 120 186 218 223 245 250 245 251 250 249 228 227 212 87 52 28 33 147 253 253 242 253 252 236 182 115 100 106 110 108 106 98 109 104 103 103 103 103 104 103 104 103 102 101 103 103 102 103 105 102 102 101 101 100 101 103 104 101 101 102 102 101 101 101 101 103 103 103 103 104 105 107 107 16 35 213 223 44 25 16 35 25 30 24 26 27 43 24 26 26 28 33 22 15 23 30 17 33 32 24 21 28 25 31 74 170 56 27 33 35 32 27 22 113 162 31 90 250 254 249 248 248 242 221 63 40 25 31 54 213 204 213 226 219 218 208 218 232 220 179 217 71 39 52 48 153 254 249 254 252 254 254 248 210 125 106 112 110 97 116 98 102 102 102 102 102 103 102 103 102 101 101 102 102 102 103 105 103 103 103 102 102 102 104 105 104 103 103 103 103 103 103 102 104 103 104 104 105 106 107 108 20 39 198 240 128 81 172 91 27 29 21 23 33 125 38 24 34 34 34 25 12 17 17 23 27 29 29 23 20 24 31 72 170 60 27 32 37 32 28 24 119 148 59 245 242 252 246 225 173 173 207 59 12 23 22 38 108 217 203 246 250 250 251 245 250 247 208 164 42 23 29 26 116 236 252 253 243 253 252 253 253 220 115 105 105 111 101 104 100 101 100 100 100 100 100 100 102 100 100 102 103 102 102 104 104 104 104 103 103 103 104 105 106 104 103 103 104 104 103 101 104 104 105 105 105 106 107 108 26 29 195 251 236 229 195 73 31 26 21 26 36 182 94 32 24 34 26 24 24 30 7 23 21 25 25 28 22 26 25 64 172 65 25 29 35 30 29 26 109 156 214 246 252 241 158 137 114 60 33 24 21 32 26 38 184 220 153 214 248 253 254 255 248 239 155 217 106 40 33 39 59 125 190 217 251 252 246 251 243 251 190 105 103 103 105 102 100 100 100 101 100 100 100 100 102 99 100 101 102 101 101 103 102 103 103 103 102 101 102 103 104 102 101 100 102 102 101 100 104 104 104 104 105 106 108 109 35 134 227 241 238 236 162 38 27 30 28 25 31 198 164 27 34 36 95 102 24 14 27 18 30 57 20 26 25 26 24 64 170 69 24 27 35 28 29 26 100 196 238 247 229 122 100 47 16 21 14 23 15 16 32 25 131 164 202 227 225 252 246 250 213 210 191 200 92 33 47 31 35 24 33 99 169 219 245 252 252 253 240 128 114 100 99 109 102 102 102 103 102 102 102 103 101 100 100 102 102 101 101 103 101 102 103 103 102 101 101 101 104 103 102 101 102 102 102 102 103 103 104 104 106 107 110 110 171 230 241 251 243 230 115 16 34 34 18 20 41 212 213 85 80 190 208 81 22 24 20 19 49 138 38 21 24 23 29 63 168 71 24 27 36 27 29 26 97 218 243 235 106 54 14 18 13 12 93 112 32 26 17 39 125 238 232 209 162 227 249 247 192 212 235 237 87 41 39 32 35 104 34 40 27 81 154 192 248 238 232 209 93 114 107 104 103 103 103 103 103 103 103 103 102 101 101 103 103 101 101 102 101 102 103 103 102 101 100 101 105 105 104 103 103 103 104 105 103 104 103 104 106 108 111 112 179 224 241 247 248 248 172 62 27 34 23 37 46 200 230 224 240 230 161 30 30 20 12 22 54 213 71 24 27 24 34 53 168 72 24 28 38 28 30 27 90 228 233 135 26 12 20 106 98 46 33 149 28 63 77 38 98 189 193 191 211 155 96 107 169 188 193 205 99 46 63 35 75 138 28 100 111 27 34 76 163 238 237 225 123 103 106 107 103 104 103 103 103 103 104 103 103 101 101 103 103 101 101 102 101 102 103 103 102 101 100 100 103 103 104 103 101 101 103 105 102 102 103 104 106 108 111 112 27 50 120 247 244 204 192 90 30 36 25 76 166 237 234 232 236 215 58 33 25 29 8 21 70 229 144 26 57 118 48 58 171 78 23 23 36 33 25 29 84 185 141 25 23 26 27 175 204 192 183 146 193 222 234 214 215 121 98 36 32 49 38 37 38 49 82 178 194 231 242 174 184 138 216 218 176 53 97 58 47 164 244 222 159 106 109 105 106 101 107 101 108 102 103 103 105 103 102 102 103 104 103 102 103 102 102 101 101 101 102 103 104 105 106 107 106 106 107 107 108 107 107 107 108 109 111 112 26 27 84 244 191 64 57 42 27 52 147 219 245 237 243 240 234 106 32 30 27 10 34 19 75 227 208 143 195 127 32 41 168 81 25 23 36 33 25 25 22 5 16 18 10 25 22 46 136 150 55 175 227 179 175 224 239 235 243 192 114 78 31 54 106 197 246 234 238 228 200 237 231 140 185 201 189 223 202 46 23 43 189 184 109 54 42 94 106 102 105 100 107 103 102 102 105 102 101 101 102 102 102 101 103 103 102 102 102 103 104 105 106 107 108 108 107 107 109 110 109 109 109 109 110 111 112 113 16 37 79 235 127 28 28 22 30 41 95 177 221 248 243 239 225 170 44 33 16 18 24 28 110 237 220 180 173 51 27 49 163 86 25 23 34 33 22 19 25 16 16 19 15 16 10 22 13 35 60 106 52 34 180 197 172 145 100 75 63 78 50 76 70 81 144 159 213 217 131 77 111 112 18 37 100 192 173 159 163 49 54 29 18 15 28 47 104 105 105 100 108 104 105 104 105 104 102 102 103 103 102 102 104 104 103 103 104 105 106 107 106 107 108 109 108 108 109 110 109 109 110 111 111 112 113 113 20 33 62 207 65 31 29 14 21 38 20 37 74 197 247 246 241 230 108 30 27 47 94 140 208 237 196 182 94 21 23 36 159 90 22 25 33 26 19 14 7 18 18 15 7 14 22 19 26 13 11 26 56 31 31 33 32 34 30 20 30 26 19 36 29 24 45 34 46 49 61 70 173 180 188 64 25 24 95 137 56 34 25 18 26 11 24 14 92 106 105 101 106 104 106 106 107 107 106 106 106 105 105 104 105 105 105 105 105 106 106 107 106 107 108 108 108 108 109 110 108 109 110 111 112 112 113 113 29 34 60 148 32 31 28 19 19 24 25 19 38 196 238 116 130 197 204 58 26 48 85 150 201 221 219 177 44 24 26 38 156 93 18 27 30 19 13 13 17 12 14 23 19 12 17 3 21 16 14 27 16 26 24 13 20 18 26 22 36 24 30 24 31 29 23 28 37 24 25 37 98 130 221 211 80 33 22 15 13 17 15 9 16 14 6 18 74 101 101 102 103 101 104 107 108 109 109 109 109 108 107 107 107 107 107 106 106 106 106 106 108 108 109 109 108 109 110 111 109 110 111 112 113 113 113 113 14 31 43 60 26 34 26 18 29 29 31 35 27 200 188 44 31 38 92 85 20 24 20 32 129 223 225 186 111 28 27 29 151 100 19 26 25 14 12 13 10 18 11 7 23 12 13 24 11 18 14 7 19 15 14 33 32 22 19 20 14 15 23 16 22 11 20 28 17 30 27 28 42 92 48 28 18 24 8 17 12 8 13 18 10 17 11 21 62 101 102 105 105 103 105 110 109 110 111 111 110 109 108 108 109 109 108 108 107 107 106 106 110 110 110 110 109 109 111 112 111 112 112 113 114 115 115 115 27 34 28 32 48 36 22 22 26 31 11 31 40 202 102 35 33 44 37 40 26 13 18 14 98 238 192 190 195 51 14 32 146 111 21 20 17 12 17 11 17 13 19 11 15 16 18 4 14 7 17 17 2 20 15 5 11 15 19 26 17 20 19 19 17 20 24 20 22 28 10 16 12 9 18 8 16 10 0 14 12 12 13 15 4 8 19 16 62 108 105 109 108 107 109 110 109 110 112 112 110 109 109 110 111 111 110 109 109 109 108 108 111 111 111 110 109 109 110 111 111 111 112 112 113 114 116 116 20 41 26 29 39 40 30 15 19 26 24 22 45 165 33 37 31 35 32 27 21 21 15 18 126 223 80 39 145 126 27 23 142 118 25 18 11 12 20 12 15 9 19 12 18 16 14 15 12 13 7 16 19 1 17 9 13 11 11 8 11 13 9 12 15 11 9 12 7 7 16 11 12 17 5 9 12 7 24 9 14 4 16 10 18 17 10 13 64 110 106 109 108 109 107 108 110 111 113 113 111 110 110 111 111 111 110 110 110 110 110 110 110 110 110 109 107 107 109 110 111 110 111 111 112 113 115 116 23 32 28 34 37 40 27 20 28 24 18 30 44 57 36 27 35 34 34 30 22 15 15 18 147 166 25 14 29 51 28 20 130 119 22 14 13 16 16 15 14 16 13 12 14 12 11 13 8 12 13 12 11 13 12 7 10 13 11 10 14 12 9 11 14 12 11 11 12 12 11 10 10 12 12 10 10 13 12 8 13 10 12 13 13 17 17 11 64 112 108 109 104 113 108 116 112 112 113 113 111 110 110 110 110 111 112 112 112 112 111 111 110 110 109 109 110 112 112 113 113 111 109 109 111 112 111 111 24 32 28 34 36 39 25 17 22 27 24 32 32 39 28 32 32 33 34 31 23 17 16 18 132 64 22 25 16 17 20 27 124 123 19 14 12 16 15 14 9 18 16 10 10 15 15 18 15 15 13 11 9 10 14 19 12 14 13 12 14 13 9 10 9 10 10 10 12 13 14 13 9 13 14 12 9 9 10 11 8 4 7 10 8 10 15 17 56 110 111 113 109 115 109 116 113 113 114 114 113 112 112 112 113 113 114 114 113 113 112 112 113 112 111 111 111 112 112 113 113 111 109 109 110 111 111 111 23 32 29 35 35 38 23 16 21 26 25 29 24 24 24 37 31 32 34 32 24 18 16 18 58 23 36 13 10 23 22 21 119 132 16 16 12 15 14 14 21 16 9 11 19 16 6 6 11 8 10 17 16 11 9 12 11 11 11 11 12 13 11 12 14 14 14 13 12 11 11 10 14 12 12 13 14 14 13 14 14 9 12 17 14 10 12 12 48 111 113 116 111 116 110 116 114 114 115 116 115 114 114 114 115 115 116 116 115 114 114 113 115 115 114 113 112 113 113 114 112 111 110 109 110 111 111 111 23 32 28 35 35 37 22 14 26 25 18 25 29 25 29 37 33 33 34 31 24 16 15 17 17 32 28 18 21 24 14 25 117 141 16 18 12 15 13 13 13 14 12 11 12 10 11 19 18 13 9 11 13 13 14 15 17 14 15 16 14 14 16 17 15 16 16 17 19 19 21 22 18 15 13 13 12 10 10 12 11 6 8 12 12 15 16 13 42 114 114 116 110 114 112 119 116 116 117 117 116 116 116 116 117 117 117 117 117 116 116 115 116 116 115 114 114 114 114 114 112 111 111 110 111 111 112 113 23 30 28 34 34 38 22 15 28 25 16 24 34 26 33 36 35 35 33 28 21 15 14 17 28 32 20 28 12 13 15 24 116 140 16 17 11 14 12 13 5 14 17 14 15 16 9 8 13 22 32 37 43 51 55 56 50 42 40 38 29 27 31 29 38 40 47 54 64 73 80 84 88 80 66 50 32 18 13 12 13 12 12 12 8 13 17 13 31 113 115 115 112 115 114 120 116 117 118 118 117 116 117 118 116 116 116 116 116 116 117 117 116 116 115 115 115 115 115 116 113 113 112 112 112 112 114 114 23 31 27 32 33 37 23 15 23 26 20 24 34 23 34 34 36 35 33 29 20 15 14 17 26 26 33 18 9 21 21 19 116 130 15 15 12 13 14 14 16 11 8 12 14 10 18 37 76 99 123 133 135 136 137 136 133 122 121 117 102 96 99 96 101 101 108 117 128 139 145 148 139 141 144 142 131 97 50 14 9 8 14 15 10 10 14 11 20 111 114 118 117 118 116 119 118 118 119 118 118 117 118 118 117 116 116 116 116 117 118 118 117 116 116 116 116 117 117 117 114 114 114 114 113 114 115 117 24 32 27 32 32 36 23 17 19 27 22 23 33 22 36 31 35 33 32 29 22 14 14 18 23 18 29 22 25 21 10 26 124 123 19 12 10 13 13 12 16 12 9 12 18 38 89 144 157 164 170 170 171 172 176 179 179 170 173 174 158 152 156 152 159 158 160 164 173 177 176 173 169 165 161 161 168 160 129 96 37 17 6 11 12 12 14 17 17 114 115 119 118 119 118 118 120 120 120 120 118 118 119 119 118 118 117 117 116 117 117 117 118 118 118 118 118 118 118 118 116 117 116 115 115 115 117 119 26 33 27 31 32 36 23 16 17 27 20 21 33 25 39 31 32 32 32 29 23 15 14 17 25 28 25 27 15 18 19 19 131 120 23 13 12 13 11 11 10 23 25 31 74 131 164 169 171 164 163 175 189 194 197 198 195 186 195 202 190 187 192 188 191 188 189 194 198 200 196 190 176 179 178 170 170 172 164 150 128 71 23 15 15 13 15 19 21 119 116 116 116 117 118 119 121 121 121 120 119 119 119 120 120 119 118 117 117 117 117 117 119 119 120 118 119 119 118 118 117 118 118 118 116 116 118 120 75 38 29 38 29 38 26 17 18 29 25 26 23 36 36 30 33 31 30 31 24 14 14 18 21 32 23 21 25 14 15 24 124 130 13 12 10 14 16 15 42 81 70 87 137 162 176 182 175 178 181 184 186 192 197 201 205 201 194 197 196 196 207 205 192 205 205 200 191 210 210 202 202 182 186 171 181 171 172 154 154 126 94 62 13 12 17 13 26 120 118 114 120 119 122 119 121 120 119 119 120 120 119 118 119 118 117 118 118 118 118 117 118 118 118 118 118 118 118 118 119 119 118 119 121 122 124 125 189 33 34 36 26 65 42 20 23 25 15 29 25 27 28 30 30 30 30 31 24 15 15 18 24 35 28 24 24 17 18 19 119 141 13 12 19 6 4 36 89 92 84 115 155 170 178 175 181 181 186 190 195 201 204 205 199 198 199 205 200 194 198 195 204 203 200 201 197 193 189 190 191 202 177 169 173 171 167 156 156 141 137 94 58 16 18 10 30 118 116 114 119 115 119 121 122 121 120 120 121 121 121 120 121 120 119 119 120 120 119 118 119 119 120 120 120 120 120 120 120 120 120 121 121 122 123 123 234 150 30 48 136 176 33 11 28 35 29 29 25 33 28 29 25 27 31 31 24 15 15 18 23 31 28 26 23 20 24 19 123 133 12 18 12 15 34 70 83 77 100 138 156 166 177 176 188 191 195 196 191 187 183 182 193 196 198 204 198 190 195 193 184 190 188 178 177 161 146 138 146 145 158 159 151 157 158 161 155 147 145 130 91 31 11 20 41 122 121 119 123 118 123 126 123 122 121 122 123 123 123 122 123 122 121 121 122 121 120 120 121 122 122 123 123 123 123 123 121 121 122 123 123 123 122 122 232 225 101 202 231 96 28 14 71 119 24 29 27 28 29 29 23 27 31 30 23 14 14 19 27 31 29 29 24 21 25 19 126 135 14 15 2 16 41 63 77 88 124 142 143 156 166 167 155 152 146 138 133 135 145 154 182 192 197 199 194 193 202 195 174 184 181 160 155 135 129 134 121 136 160 162 182 162 153 155 156 151 137 135 120 70 22 13 48 124 123 117 120 120 120 121 123 123 122 123 124 124 124 123 124 123 122 123 123 123 123 122 124 124 124 124 124 124 123 123 122 122 123 123 124 124 124 124 224 240 239 227 186 41 19 20 77 217 53 37 26 17 43 34 25 27 30 27 21 15 15 18 28 29 27 29 24 16 21 19 117 142 17 12 14 22 38 70 94 105 127 137 148 163 168 168 167 156 144 136 137 142 153 163 167 185 193 192 188 194 204 192 190 176 163 156 156 117 94 98 94 106 128 150 176 165 178 147 145 158 153 115 120 76 43 24 57 128 128 119 121 126 126 121 124 123 123 123 124 125 124 124 124 123 123 123 125 125 125 124 126 126 125 125 124 123 122 122 124 123 123 123 124 126 127 128 239 228 225 222 95 30 36 11 96 226 155 36 31 100 154 48 27 29 29 27 21 15 14 16 19 24 20 20 17 13 19 22 120 127 17 19 16 30 72 105 104 113 124 143 159 157 153 155 155 138 117 110 110 112 115 116 151 171 180 177 173 184 199 192 188 178 163 147 131 100 87 92 80 62 69 64 57 64 63 74 77 94 94 100 114 83 41 31 74 132 130 122 123 131 128 124 124 124 123 124 125 125 125 124 125 124 124 125 126 126 126 125 127 127 126 126 125 124 123 123 125 125 124 124 125 127 129 130 225 234 225 230 89 36 12 15 79 226 237 106 174 226 132 29 27 28 29 26 23 19 16 14 18 34 27 15 13 15 20 20 133 117 20 17 7 34 102 112 97 105 117 148 157 144 149 148 145 128 109 100 100 107 119 132 122 148 169 176 173 181 200 202 195 177 149 133 120 101 64 36 58 83 102 93 92 80 43 43 113 93 45 70 88 93 43 42 90 133 126 120 121 124 120 123 126 125 124 125 125 125 125 124 127 127 126 126 126 127 126 125 127 127 127 127 127 126 126 125 126 126 126 126 127 128 129 129 231 244 242 226 212 55 32 17 99 217 239 235 214 188 42 21 24 27 29 28 25 20 15 13 33 57 45 20 15 17 20 15 127 126 24 11 25 58 115 114 100 92 81 90 72 48 49 29 27 31 38 41 37 34 46 59 90 127 168 195 195 193 203 206 198 181 150 118 72 70 105 150 121 133 141 149 121 148 231 108 28 47 42 52 73 85 64 62 115 145 133 131 131 126 122 131 127 126 125 125 126 126 125 124 130 129 128 127 127 127 126 125 127 128 128 128 128 128 128 128 126 127 127 128 128 128 128 128 178 235 206 218 234 169 27 58 198 230 226 223 214 95 38 21 26 27 26 32 15 75 51 49 142 163 30 22 11 18 16 19 122 121 31 19 35 101 133 108 85 65 30 51 61 51 31 117 190 173 142 124 125 149 151 96 81 64 116 149 192 194 184 180 164 141 108 121 176 137 117 51 38 43 61 77 120 121 155 200 62 48 89 70 69 92 108 95 132 126 135 131 129 132 126 126 127 127 127 127 126 126 126 126 128 128 129 130 130 129 129 129 128 128 128 129 129 129 128 128 129 128 128 128 128 128 129 129 147 214 70 57 97 152 92 57 203 221 219 218 190 42 29 24 24 28 26 31 21 72 109 130 182 79 17 10 18 17 15 19 124 117 31 53 75 119 122 94 68 57 18 28 16 41 126 129 136 98 59 48 45 40 90 153 138 131 139 143 168 170 169 148 143 122 126 128 120 109 47 79 31 52 46 42 63 88 78 72 79 70 60 40 41 81 122 149 173 157 127 136 133 129 131 136 129 129 129 128 128 128 128 128 130 130 131 131 131 130 130 129 129 129 129 130 129 129 129 128 127 128 128 129 129 130 131 131 139 187 36 38 20 33 29 27 124 217 233 230 216 113 35 28 27 34 27 26 20 48 109 112 110 34 18 14 13 16 21 17 126 134 29 53 116 132 107 73 47 49 58 52 28 101 113 120 89 50 40 35 38 35 56 75 119 114 112 147 150 133 140 135 132 106 142 135 109 58 79 47 15 37 38 43 46 73 79 91 121 100 80 81 90 127 142 108 133 168 132 138 125 128 138 131 131 131 131 131 131 131 130 130 132 132 133 133 132 132 131 130 131 131 131 131 130 130 130 129 128 129 130 131 131 131 131 131 118 111 26 32 31 25 13 14 41 199 230 205 230 201 46 15 22 33 29 24 27 62 119 104 37 10 21 23 9 16 24 18 113 140 34 57 154 136 115 107 71 83 59 66 49 89 70 100 49 43 56 25 17 45 88 104 67 84 92 140 128 167 193 191 165 147 153 147 105 125 111 97 88 80 74 78 88 93 107 126 152 138 147 128 112 108 121 70 62 144 138 134 124 128 139 124 133 133 133 133 133 133 133 133 134 134 134 134 134 133 132 131 131 131 132 132 132 132 131 131 131 132 133 133 132 131 130 129 77 62 40 20 23 34 18 15 28 200 146 43 103 179 116 23 26 32 31 21 17 63 115 124 101 8 14 17 20 16 18 19 113 135 34 81 139 87 84 106 109 110 105 128 107 83 79 74 69 65 73 75 101 100 101 129 137 150 151 155 100 177 206 206 186 124 177 168 155 136 126 147 135 129 119 111 118 135 141 133 142 149 166 133 120 114 137 145 61 122 129 129 137 130 132 134 134 134 134 134 134 134 134 134 135 135 135 135 134 133 132 131 132 132 133 134 134 134 134 134 133 134 134 134 133 132 131 130 39 24 23 32 34 33 14 12 40 203 79 28 35 32 54 27 27 24 29 29 24 60 89 117 150 82 14 16 19 20 17 16 120 129 25 93 109 81 108 113 114 105 147 153 115 110 76 71 62 71 102 146 171 161 143 152 146 174 192 169 98 171 198 207 201 168 170 182 153 139 175 168 182 193 182 163 138 165 169 155 158 157 158 131 118 150 159 141 84 121 132 127 138 132 129 141 135 135 135 135 135 135 135 135 136 136 136 135 135 134 133 132 133 133 134 134 135 135 135 135 132 133 133 134 134 134 134 134 20 26 28 32 27 24 13 15 45 149 20 31 37 20 24 16 31 28 28 27 20 23 19 32 86 108 23 25 12 21 19 17 125 135 22 64 83 69 122 110 104 109 139 163 130 130 98 87 88 111 139 179 180 182 167 148 134 181 199 148 123 188 205 195 203 180 136 187 191 160 141 172 186 177 166 155 138 158 170 159 166 161 163 147 124 160 188 154 87 133 137 130 131 135 133 136 135 135 136 136 136 136 136 137 136 136 136 136 136 135 134 133 133 133 135 135 135 135 134 134 133 133 133 133 134 134 135 135 27 21 26 21 31 29 16 15 33 57 27 35 29 29 25 24 22 33 30 23 23 15 11 15 20 30 26 28 16 14 17 19 110 132 28 51 102 64 138 148 127 92 131 148 139 133 137 119 102 135 132 156 146 131 118 138 197 190 173 120 158 196 206 205 196 205 143 170 180 204 188 154 151 132 141 128 133 140 173 168 150 151 151 145 140 119 162 163 95 140 132 137 129 138 136 134 136 136 136 136 137 137 137 137 137 137 137 137 137 136 135 134 135 135 136 135 135 134 133 133 135 135 133 133 133 134 134 134 22 24 23 28 32 26 16 14 24 22 26 30 29 25 23 26 26 32 27 26 19 13 16 11 14 18 20 24 14 19 18 17 112 134 22 31 122 74 156 145 116 96 137 141 150 138 149 124 98 131 133 134 139 145 177 205 204 192 168 122 184 195 210 206 207 209 178 149 193 200 200 210 200 188 169 154 157 174 178 168 156 151 148 144 113 74 132 161 125 127 135 138 132 133 137 140 138 137 136 136 137 138 137 137 137 136 137 139 138 136 134 135 137 137 137 136 135 134 133 133 134 134 134 134 134 134 134 134 24 25 25 28 32 25 15 12 21 21 24 29 28 23 21 23 27 32 28 25 20 15 17 14 11 22 16 16 26 19 19 20 120 141 12 49 119 101 163 146 97 96 131 133 151 153 152 121 123 144 167 187 200 208 213 206 199 209 149 161 192 194 205 212 210 202 209 159 172 194 203 200 200 202 191 179 180 181 168 157 160 153 124 160 135 81 111 160 147 142 142 139 131 131 136 134 138 137 136 136 137 138 137 137 139 137 137 138 138 136 136 137 137 137 137 136 135 135 134 134 135 135 134 134 134 135 135 135 23 24 25 27 31 23 14 12 22 23 25 30 29 25 22 25 27 31 26 23 19 15 18 15 18 19 16 16 26 11 19 23 111 138 57 156 191 132 156 154 95 121 144 125 136 151 150 135 101 123 184 212 208 211 216 211 211 196 127 185 198 205 204 212 210 203 205 183 128 176 195 196 203 201 182 168 172 168 157 152 152 134 138 161 176 113 124 141 148 139 137 135 134 138 141 138 138 137 137 137 137 138 138 137 140 138 137 138 138 137 137 139 137 137 136 136 136 136 136 136 135 135 136 136 135 135 135 135 22 23 24 26 30 23 15 14 21 23 26 30 30 27 26 26 26 30 24 21 17 13 18 14 21 13 22 18 19 18 17 12 84 169 149 182 197 168 180 136 129 165 164 123 118 138 143 149 144 127 165 202 207 209 201 192 179 122 120 175 188 204 205 199 208 210 211 195 120 100 150 169 172 168 169 178 189 186 167 147 138 135 146 166 184 159 125 141 144 138 137 137 136 137 137 133 139 138 137 137 138 138 138 138 139 137 137 138 139 137 138 139 137 137 137 136 137 137 138 138 136 136 136 136 136 136 136 136 21 23 23 25 28 22 14 14 18 21 24 28 29 27 27 28 27 30 24 20 17 13 16 13 15 16 25 18 17 27 13 35 132 166 157 181 197 167 171 155 160 186 171 128 119 133 132 145 163 132 137 161 186 189 156 133 104 99 162 180 189 202 209 202 206 203 198 203 182 127 112 117 101 103 133 167 175 178 165 136 139 141 142 162 182 146 120 154 140 137 138 140 137 138 139 136 139 138 137 137 138 139 138 138 138 137 137 140 140 138 137 138 137 137 137 137 137 137 138 138 136 136 136 136 137 137 138 138 24 25 24 25 26 20 13 14 18 20 25 28 28 29 28 28 26 29 24 21 18 16 18 13 15 20 19 21 18 10 25 124 173 172 150 189 202 172 163 171 160 180 174 142 127 129 128 141 166 155 130 97 93 106 106 105 73 146 187 177 184 194 204 199 202 203 194 192 177 165 116 162 174 169 180 183 164 158 157 142 146 137 154 170 170 125 156 150 137 134 136 138 135 138 142 141 140 139 138 138 139 139 139 138 138 137 138 140 140 138 137 137 137 137 137 137 137 138 138 138 137 137 137 137 137 137 139 139 24 25 25 24 26 20 12 13 19 22 26 28 29 28 28 27 25 27 22 21 19 17 20 14 18 19 16 22 16 17 86 187 183 176 143 192 196 152 153 177 163 171 174 146 128 125 133 144 144 165 163 149 151 164 156 126 97 170 158 150 169 176 191 188 179 171 175 150 150 146 95 123 176 185 186 175 160 152 152 154 146 138 152 170 148 159 170 150 143 139 139 138 133 135 136 133 140 139 138 138 139 139 139 139 140 138 139 140 140 138 137 138 138 137 137 137 137 138 138 138 137 137 137 138 138 138 138 138 21 24 23 25 26 20 13 15 17 21 24 26 26 25 24 24 21 25 19 21 19 17 20 14 14 18 19 15 16 61 160 175 172 177 144 192 199 136 147 164 185 170 165 138 126 132 144 144 135 153 159 169 179 184 157 95 78 103 81 89 120 126 144 149 150 144 111 100 55 80 51 86 145 170 170 160 165 160 152 163 151 139 148 117 163 179 145 163 136 133 136 139 139 142 142 138 140 139 138 138 139 140 139 139 142 140 139 140 139 138 138 140 138 137 137 137 137 138 138 138 138 138 138 138 138 138 139 139 15 30 24 19 39 18 12 18 25 10 26 33 26 24 18 26 24 31 25 17 17 20 20 9 15 14 20 21 73 149 173 177 173 172 148 193 187 137 149 171 150 148 98 126 135 132 145 157 143 148 160 161 168 150 101 78 155 125 61 60 66 76 90 90 84 78 94 74 88 149 99 45 102 139 150 143 159 150 156 165 155 155 140 127 128 134 164 152 140 137 137 138 138 137 139 141 138 140 141 140 140 139 140 141 143 142 140 139 138 137 137 136 137 136 136 136 138 138 138 137 138 138 138 138 139 140 141 141 28 22 18 37 22 21 17 3 20 25 20 21 27 21 20 20 21 22 17 17 17 18 20 20 12 20 22 97 163 163 176 176 173 172 149 191 185 150 152 170 163 153 165 176 150 131 142 154 160 143 165 158 151 133 76 124 171 166 159 160 154 120 75 40 61 113 143 150 146 157 129 58 51 108 134 142 147 147 160 161 151 164 190 171 177 159 177 149 138 136 136 138 139 138 138 139 138 140 141 140 140 139 140 141 142 141 140 138 137 137 137 137 136 135 135 135 136 137 137 136 137 137 138 138 139 139 140 140 21 26 36 58 27 7 19 21 12 24 30 32 31 23 21 21 21 19 16 16 20 19 15 18 12 31 142 177 154 176 178 174 172 170 152 190 184 161 146 159 180 173 187 190 177 138 140 158 164 148 151 155 128 87 100 157 164 159 167 158 168 161 145 127 134 156 147 155 149 139 157 120 48 66 102 113 131 146 159 163 156 160 179 186 160 181 171 140 137 137 137 139 140 139 139 140 138 140 140 140 139 139 140 140 140 139 138 137 137 137 137 137 137 136 135 135 136 137 136 136 136 136 137 137 138 138 139 140 66 37 126 78 26 23 10 12 32 13 22 25 22 25 20 17 20 23 20 15 21 19 11 15 33 151 175 170 176 166 177 170 171 166 152 190 183 164 126 134 183 194 185 199 176 140 148 159 165 153 144 139 96 64 146 159 163 167 173 165 169 174 175 163 175 160 154 155 163 155 163 150 85 45 86 105 141 150 145 152 149 166 190 174 172 171 146 135 138 136 137 140 141 139 139 140 138 140 140 140 139 139 139 140 139 138 138 137 137 137 137 137 138 137 136 136 137 137 137 136 136 136 136 136 137 138 138 139 165 155 137 30 19 15 16 11 15 24 22 23 23 16 19 23 20 20 22 16 18 15 21 54 132 156 175 173 173 176 177 177 175 165 154 194 186 161 107 107 165 187 184 189 121 134 157 147 173 149 155 114 68 97 148 162 168 181 175 182 176 186 199 192 192 181 181 160 166 170 166 156 146 85 73 102 130 144 153 166 152 147 191 184 156 154 147 136 136 135 136 140 140 139 138 139 139 140 140 140 139 139 139 140 138 138 137 137 137 137 138 138 138 137 137 137 138 138 137 137 136 136 136 137 137 138 138 138 202 164 103 28 16 26 10 15 42 75 35 25 32 11 21 24 20 16 22 20 18 16 43 111 158 161 174 184 168 168 185 181 176 166 154 194 191 158 99 86 109 154 168 122 33 93 141 168 169 160 154 106 76 135 137 170 168 179 170 188 175 183 199 193 192 188 183 180 181 172 167 157 153 132 78 134 150 161 164 151 151 98 118 152 136 161 154 135 136 134 135 137 138 136 137 138 139 139 140 140 139 139 139 140 139 139 138 138 138 138 139 139 137 136 136 136 137 137 136 135 136 136 136 136 137 138 137 138 185 171 50 23 27 13 12 61 125 88 28 12 26 20 17 12 19 19 23 18 22 26 50 117 137 172 173 177 170 170 191 170 171 168 156 189 193 159 106 80 99 115 116 60 25 84 133 157 159 173 161 124 108 142 144 157 149 136 127 133 127 137 166 174 156 143 129 141 143 139 145 160 145 154 107 148 167 169 168 152 134 76 77 108 180 163 142 134 137 136 135 137 137 136 137 139 137 139 140 139 139 138 139 140 140 140 139 139 139 139 140 140 137 136 136 136 136 136 136 135 136 136 136 136 137 138 138 139 196 171 66 24 15 20 12 74 113 25 28 27 15 24 12 24 15 20 24 10 19 32 40 81 126 164 175 177 174 169 178 181 168 168 156 184 193 161 115 80 84 104 144 106 44 45 137 159 161 169 188 142 132 137 146 132 92 68 76 77 78 77 94 102 79 78 80 77 67 75 74 100 117 141 157 167 189 166 151 155 149 68 90 143 153 140 148 135 139 137 138 138 138 137 138 140 137 139 140 139 139 138 139 140 141 141 140 139 139 140 140 140 138 137 137 137 137 137 137 136 136 136 136 136 137 138 138 139 223 199 135 27 20 17 9 73 52 33 24 22 28 13 15 21 19 22 22 14 15 36 50 46 120 150 177 178 180 169 181 179 170 168 155 184 183 135 112 82 67 61 54 60 44 40 116 146 159 171 182 181 131 125 99 80 67 91 101 106 118 112 93 87 99 131 162 155 145 156 153 142 130 147 151 185 177 173 158 157 131 81 97 138 166 167 138 142 137 138 138 140 140 139 139 139 140 139 139 139 139 139 139 139 143 141 139 138 139 139 138 137 139 139 139 139 137 136 136 135 134 135 136 137 137 137 139 140 150 168 172 64 11 23 2 99 60 17 26 21 20 20 17 21 20 21 21 16 18 35 47 45 94 154 175 176 177 172 181 179 171 165 156 187 172 117 110 110 61 31 15 32 42 45 105 145 153 152 176 182 157 136 141 137 145 147 151 165 177 171 168 178 178 165 172 177 171 160 150 151 161 138 172 179 175 157 167 153 119 82 107 142 174 163 142 137 139 139 139 140 139 139 139 139 141 140 139 139 139 139 139 139 140 139 139 138 137 137 138 139 139 139 139 139 137 136 136 136 135 136 137 138 138 138 139 140 79 12 91 115 25 12 24 149 95 11 22 19 14 23 14 21 21 19 18 17 20 34 45 43 64 147 176 178 176 173 179 175 168 165 157 184 164 109 115 129 116 64 33 33 41 38 77 131 143 154 179 169 158 135 162 148 145 152 153 151 165 181 178 165 168 160 162 153 140 140 151 169 166 138 167 184 157 157 154 143 94 88 121 145 163 142 141 141 141 140 140 139 139 140 141 140 141 140 140 139 139 139 139 139 137 138 139 138 136 135 137 139 139 139 139 139 137 137 136 136 137 137 138 138 138 138 139 140 28 22 18 28 18 18 14 114 131 29 22 21 19 21 10 23 20 19 17 13 17 34 46 41 45 120 178 180 176 175 178 173 167 167 155 179 164 119 123 125 146 141 120 62 29 27 56 119 144 146 161 176 164 130 157 161 147 139 136 135 128 121 115 107 99 104 117 122 136 162 167 160 156 140 161 157 158 142 145 126 88 100 122 139 145 129 142 143 143 141 141 140 140 140 141 141 142 141 141 140 140 139 139 139 138 138 138 138 136 136 137 138 139 139 139 139 138 137 137 136 137 137 138 138 137 137 138 139 19 27 18 24 18 15 9 24 109 43 25 21 27 18 14 26 19 20 19 13 17 39 49 41 44 83 166 179 175 175 178 170 166 164 151 177 168 126 125 120 139 130 147 148 116 54 28 97 131 143 142 166 147 141 153 156 166 159 153 138 116 101 101 103 105 95 103 115 133 151 148 140 159 155 151 150 147 136 143 105 102 118 113 135 139 142 144 139 142 142 142 142 142 141 142 141 143 142 141 141 140 140 140 140 142 140 138 138 138 138 138 137 139 139 139 139 138 137 137 136 136 136 137 137 136 136 136 137 23 17 23 18 11 18 19 18 40 33 24 16 25 17 20 21 19 19 19 18 25 44 51 41 48 56 133 170 172 173 178 166 169 162 148 178 168 120 121 124 141 131 133 134 130 100 56 87 121 148 137 142 127 157 161 144 137 147 146 141 151 168 174 167 162 152 153 144 133 135 144 158 162 160 147 163 133 139 141 82 109 129 120 138 137 145 142 139 142 143 144 144 144 143 142 141 144 142 142 141 141 141 141 141 144 141 139 138 140 140 139 137 140 140 140 139 138 137 136 136 135 136 136 136 135 135 136 137 27 12 20 29 23 11 2 13 7 19 23 13 19 16 19 15 18 15 21 30 39 48 48 43 48 50 87 156 166 170 176 166 168 164 152 177 164 119 124 127 128 126 129 129 121 96 57 85 137 130 129 144 151 156 161 168 167 159 155 171 194 194 188 190 191 185 190 187 182 182 180 179 158 144 152 138 144 128 147 87 108 134 136 143 137 142 138 144 143 144 143 143 143 144 143 144 142 142 142 142 141 142 142 142 143 142 140 140 140 140 140 140 141 141 140 140 138 137 136 135 135 136 137 137 136 136 137 138 17 26 19 22 8 12 16 14 20 16 23 16 19 16 20 16 18 11 21 42 51 50 46 45 45 53 53 145 161 170 175 164 163 171 159 174 160 126 130 122 124 132 132 130 131 120 71 70 145 123 133 137 159 145 151 158 145 162 162 165 186 196 195 198 194 180 184 192 192 186 175 177 151 144 134 114 137 135 144 125 116 136 143 139 142 144 142 145 145 143 143 144 143 144 145 146 142 142 142 142 142 142 142 143 140 141 142 141 139 139 140 142 142 141 141 140 138 136 135 135 136 137 137 138 137 137 138 139 18 21 22 19 15 12 11 13 20 18 17 18 18 16 16 18 14 25 42 51 51 46 44 44 45 51 57 92 159 160 165 149 156 188 147 155 151 121 140 124 126 131 129 136 127 133 61 38 135 146 121 131 139 146 133 151 157 161 158 154 169 170 185 188 172 174 184 194 193 178 163 159 133 121 108 127 126 121 138 128 130 137 142 145 145 143 146 143 146 142 140 142 143 143 143 146 144 143 143 143 143 143 143 143 141 141 141 141 141 141 141 141 143 142 142 141 140 139 139 138 138 138 138 138 138 138 138 138 19 21 22 20 15 12 12 14 14 24 25 15 13 17 19 19 25 35 47 53 51 48 45 43 45 50 58 61 134 160 170 136 152 195 148 137 131 118 139 121 141 114 127 144 131 129 64 77 167 143 110 114 129 138 122 139 156 155 147 144 159 158 165 161 150 163 168 165 165 164 152 135 118 84 95 79 95 146 135 49 143 130 135 138 145 147 138 143 141 139 141 142 144 142 145 147 143 143 143 143 143 143 143 143 142 142 141 141 141 141 141 142 143 142 142 141 139 139 138 138 138 138 138 138 138 138 138 138 19 21 21 20 15 13 14 14 17 28 23 15 19 22 20 21 40 44 52 55 53 49 45 43 46 54 59 45 97 158 167 139 147 196 145 125 117 111 135 122 134 131 130 154 121 91 28 175 172 153 124 89 80 93 94 110 140 148 147 144 146 135 134 127 132 146 149 142 138 139 125 103 79 66 53 68 127 165 125 16 57 121 141 141 143 145 151 141 140 141 142 143 142 141 142 146 143 143 143 143 143 143 143 143 144 143 142 141 141 141 142 142 143 143 142 141 139 138 138 137 138 138 138 138 138 138 138 138 19 21 21 20 15 13 14 16 16 21 17 15 19 17 20 33 49 51 53 55 53 50 46 43 47 55 54 51 65 146 156 150 146 191 143 125 117 105 128 130 143 119 136 142 109 23 34 230 147 158 144 96 53 40 53 69 99 118 124 118 106 90 93 99 109 108 104 101 100 96 88 77 55 39 52 121 147 160 125 11 22 36 107 142 137 142 142 148 143 144 144 144 144 143 143 143 143 143 143 143 143 143 143 143 145 144 142 141 140 141 141 142 143 143 142 141 139 138 138 137 139 139 139 139 139 139 139 139 20 21 21 18 15 14 14 17 16 22 20 17 17 21 35 56 52 52 54 54 53 50 46 43 44 51 50 51 50 126 151 143 152 191 150 124 116 101 131 130 138 116 140 124 21 10 116 197 118 153 143 129 87 35 39 45 61 73 66 56 44 41 52 63 66 54 42 40 50 60 68 74 62 58 115 147 151 162 112 12 19 14 20 92 148 147 144 135 145 144 144 145 147 147 146 145 144 144 144 144 144 144 144 144 145 144 143 141 141 141 141 141 143 143 142 142 140 139 138 138 139 139 139 139 139 139 139 139 20 22 22 19 14 12 14 17 19 21 20 16 21 39 55 57 50 51 53 54 51 49 46 42 44 48 52 43 52 102 156 124 160 196 163 113 105 99 135 115 127 124 101 26 12 9 162 175 89 157 143 142 120 71 68 63 60 57 31 25 21 23 23 24 24 23 18 22 43 72 86 86 75 107 145 139 159 160 117 17 9 15 15 18 83 144 147 156 146 147 148 146 146 147 144 142 145 144 144 144 144 144 144 144 145 145 144 143 142 141 141 141 143 143 143 142 141 140 140 139 140 140 140 140 140 140 140 140 20 21 20 18 14 12 13 16 18 17 25 32 34 49 56 44 47 51 54 55 53 48 44 42 43 49 52 47 55 77 157 111 165 197 172 103 97 92 132 92 119 49 13 19 14 13 190 180 63 164 149 135 125 102 93 93 86 79 48 39 30 27 19 13 15 24 34 46 71 101 106 96 94 118 133 147 145 165 139 7 21 9 13 15 6 52 130 146 141 146 150 149 146 145 142 140 144 144 144 144 144 144 144 144 146 146 146 145 144 143 141 141 143 143 143 143 141 141 141 141 140 140 140 140 140 140 140 140 22 22 20 17 12 10 13 16 19 28 59 74 56 51 58 54 47 50 56 57 53 47 42 40 40 52 45 58 48 57 149 109 166 192 173 101 95 84 125 76 19 15 11 10 17 6 201 209 54 160 150 137 133 114 89 107 103 103 74 57 33 27 24 29 26 35 46 61 86 106 104 92 105 140 135 147 149 209 123 13 12 18 15 13 15 11 26 70 128 139 149 149 146 146 146 147 144 144 144 144 145 144 145 144 148 147 147 147 146 144 142 141 142 142 143 143 142 142 142 142 141 141 141 141 140 140 140 141 21 24 25 9 16 12 13 12 29 110 169 139 53 60 57 49 51 54 57 57 52 47 41 40 44 49 45 47 56 56 138 112 159 190 165 101 65 40 17 15 12 14 11 9 14 16 209 221 67 139 153 138 132 112 103 105 108 103 85 67 59 52 41 35 37 43 55 69 100 112 93 96 118 143 130 153 181 226 118 14 12 13 15 14 14 13 15 15 10 40 94 142 155 145 141 151 146 144 141 145 147 146 143 141 145 147 147 146 143 143 144 144 144 143 143 143 143 143 143 144 140 139 139 139 140 141 141 141 21 18 21 15 21 14 9 39 134 177 168 135 90 57 57 50 42 47 54 57 56 50 44 40 36 50 52 48 45 49 131 126 122 115 69 21 11 11 7 12 11 13 13 12 18 16 208 224 67 119 162 135 122 121 113 99 108 100 82 76 67 59 52 58 68 67 75 92 109 104 89 107 132 131 148 154 230 230 98 13 12 13 13 13 12 12 14 13 16 20 17 27 77 137 155 138 146 146 145 144 143 144 148 153 148 148 148 147 146 143 143 143 144 143 145 145 145 145 143 144 142 142 141 140 140 141 140 141 19 15 23 18 14 10 21 109 172 190 162 139 142 77 55 54 48 52 55 55 51 45 39 35 45 47 44 50 58 56 75 49 15 17 10 7 13 18 14 13 14 14 13 14 18 11 203 228 42 96 150 156 133 118 104 115 109 97 80 84 73 65 62 82 85 78 84 101 112 103 96 118 126 139 151 192 237 228 83 12 10 11 12 12 11 11 12 13 16 8 15 28 19 14 60 124 148 145 143 149 152 150 145 142 146 143 143 146 146 145 146 149 142 143 145 146 146 145 144 142 144 144 142 140 140 142 140 139 23 17 21 17 9 13 31 165 176 177 162 140 169 119 71 61 47 50 53 55 52 48 42 39 33 48 54 45 26 17 18 14 13 14 14 11 7 9 13 15 15 13 12 13 16 9 192 235 63 74 155 153 130 131 118 119 113 102 84 89 78 73 73 98 97 93 93 106 117 115 113 126 131 138 165 233 223 227 56 13 10 11 12 12 10 10 11 12 17 20 20 17 16 20 23 23 47 101 144 143 136 145 152 146 153 148 148 150 147 141 140 143 143 143 144 146 145 144 143 142 144 142 141 140 140 141 140 140 25 17 15 16 15 22 29 166 181 183 168 151 179 161 107 51 49 52 55 55 49 42 31 26 29 25 19 14 14 18 10 7 9 10 15 17 15 17 17 10 13 10 11 16 17 12 170 234 186 47 127 155 139 122 122 127 121 112 96 94 86 84 89 108 108 102 102 112 117 112 116 128 143 124 205 237 232 224 19 17 12 13 12 12 10 10 12 13 16 11 14 22 25 21 16 18 24 9 28 93 144 154 147 146 144 143 146 151 149 145 143 146 144 144 144 143 143 143 143 144 142 142 139 139 141 141 141 141 19 19 18 16 16 20 30 164 169 189 169 169 183 189 171 74 53 50 42 34 27 20 13 9 11 9 11 10 11 15 11 13 15 14 14 11 8 13 16 8 10 11 13 17 16 9 127 217 238 124 87 141 135 125 130 118 126 115 103 93 94 91 100 114 104 98 102 122 120 102 114 134 117 161 231 227 237 188 8 17 13 12 12 11 10 10 12 13 14 17 20 20 18 17 20 25 19 23 22 17 26 61 107 140 149 150 151 149 144 142 146 148 146 145 145 143 143 142 142 143 141 140 140 139 140 141 140 140 16 20 20 14 12 11 36 171 176 189 176 174 185 202 205 99 31 27 19 14 11 13 14 14 18 11 12 9 5 6 13 13 3 10 17 17 15 15 15 15 12 13 11 15 11 9 95 207 238 211 71 120 144 121 117 127 128 113 103 91 100 92 104 115 105 103 107 128 123 106 116 130 123 218 231 230 230 120 16 14 13 12 13 12 10 10 12 13 13 14 18 23 23 20 19 20 18 21 21 20 17 19 24 28 49 76 112 136 148 151 148 143 146 145 146 145 143 142 142 141 143 141 139 138 140 140 139 139 19 18 16 13 17 11 37 162 186 177 187 178 194 202 168 51 15 14 13 15 16 15 13 10 16 9 14 16 18 12 20 8 16 15 10 10 14 11 9 13 13 13 11 13 12 20 89 219 232 242 120 70 135 142 124 120 131 111 103 91 107 93 106 116 110 112 110 121 115 101 106 100 184 233 233 232 233 67 11 14 13 13 12 11 9 9 10 12 14 20 21 17 19 25 24 17 23 22 19 18 23 26 23 18 23 26 25 24 41 81 126 151 146 146 147 146 146 144 141 139 144 143 140 139 140 139 139 138 22 16 19 15 16 11 35 159 184 185 186 178 164 131 31 17 14 14 13 14 13 13 13 12 13 13 14 14 13 12 12 12 16 14 13 12 12 12 12 10 17 13 13 11 15 11 77 223 223 246 223 65 107 133 136 118 126 125 102 96 94 71 112 105 103 97 113 123 105 100 75 151 227 243 233 230 225 23 15 10 11 11 12 12 10 10 11 13 12 14 17 20 21 22 23 23 22 22 23 23 22 21 22 21 24 24 26 24 18 16 26 40 104 147 147 142 143 148 138 145 141 141 141 141 139 140 140 139 19 19 19 19 18 9 26 161 175 194 162 29 18 19 2 21 14 14 15 15 14 14 13 13 14 13 14 14 13 12 13 12 12 12 11 11 14 13 13 13 11 10 16 16 16 15 56 229 225 238 245 210 91 124 127 132 127 133 106 90 100 68 84 89 86 95 97 129 106 69 120 228 240 238 246 230 148 15 9 13 11 12 13 12 10 10 13 14 15 17 18 20 20 21 21 22 22 24 24 23 22 23 23 23 27 23 21 25 24 21 22 24 24 35 104 149 143 141 144 138 142 141 142 141 140 138 139 139 17 21 14 18 19 12 21 167 196 173 30 21 11 14 19 14 15 15 16 16 14 14 15 14 13 14 14 13 14 12 12 11 11 12 12 11 13 14 14 14 15 15 16 17 11 17 33 223 236 238 253 241 220 104 135 141 136 131 112 98 100 67 85 99 84 75 118 116 91 100 229 236 251 239 243 228 61 9 9 13 12 13 13 13 11 11 13 14 17 18 17 19 19 20 21 22 21 22 23 23 22 22 22 23 27 21 20 25 27 23 19 17 19 22 31 63 133 147 143 142 141 142 142 141 139 137 139 139 20 21 12 16 17 16 17 164 184 78 13 23 7 13 12 12 15 16 15 16 15 15 14 14 12 12 13 14 12 12 13 11 13 12 12 13 13 13 12 12 15 15 15 15 10 16 20 167 224 248 246 253 249 198 99 144 162 139 124 114 94 66 100 93 84 90 129 117 84 226 241 250 252 248 236 199 19 10 12 12 14 13 14 13 13 13 15 16 14 16 18 19 20 21 22 20 21 22 22 22 21 21 22 23 26 24 24 23 22 20 21 25 27 20 18 23 21 49 125 144 140 141 141 139 139 137 138 138 22 20 15 16 13 15 14 158 172 15 30 5 8 24 15 16 15 15 17 17 16 16 15 14 12 12 13 12 13 13 11 12 13 13 13 12 13 13 13 13 9 12 16 16 17 14 14 79 219 227 254 252 249 248 167 108 153 150 144 132 108 87 122 92 84 136 122 84 228 250 248 253 250 254 243 126 16 15 15 14 15 14 13 14 13 14 16 16 14 16 19 20 21 21 21 19 20 21 22 22 22 21 21 22 22 23 23 22 21 20 23 27 25 30 19 19 19 21 59 147 140 141 141 140 139 136 136 138 42 17 18 21 11 14 17 152 93 13 6 24 16 10 15 19 15 16 15 16 15 16 14 14 13 13 13 12 12 13 12 11 11 11 12 12 13 13 14 15 13 14 15 14 19 15 20 25 186 223 240 251 254 251 248 149 124 155 168 151 137 118 141 117 127 133 103 230 251 246 253 253 252 253 235 47 20 17 14 17 16 16 13 14 14 15 16 16 19 21 21 23 23 21 21 20 22 22 23 23 21 22 23 23 23 21 21 22 22 21 20 19 16 15 30 23 17 18 16 121 141 142 141 140 138 136 136 138 103 29 17 20 13 13 17 135 43 18 15 8 17 18 18 9 14 15 14 15 14 14 13 13 13 13 12 12 12 12 11 11 11 13 14 13 13 12 13 13 17 17 14 11 16 14 23 17 121 226 240 254 251 254 249 243 143 132 155 149 146 134 138 130 133 149 229 247 247 254 254 249 254 249 169 14 19 17 18 17 19 17 14 14 16 16 18 18 22 22 20 20 21 20 21 20 22 23 23 22 22 22 22 23 20 20 20 20 22 21 18 15 27 15 29 16 13 23 19 69 141 141 141 141 138 137 137 137 170 50 15 17 14 13 12 112 13 7 18 19 15 14 16 18 14 14 14 15 14 14 13 13 13 13 13 13 13 11 12 11 14 14 14 13 11 11 11 12 8 12 12 12 15 13 17 23 81 229 229 254 253 249 253 250 235 140 160 185 203 208 203 195 188 155 238 252 253 251 251 254 254 247 90 20 19 14 23 16 19 17 14 15 16 17 17 18 20 19 17 17 17 19 21 22 21 22 23 21 21 20 21 21 19 21 20 19 17 18 19 21 18 22 18 18 30 12 21 30 141 141 141 140 139 138 136 137 186 141 19 17 14 14 21 53 14 15 16 17 17 16 14 14 17 15 15 14 13 13 13 14 12 12 13 13 13 13 11 10 12 13 14 14 14 13 12 12 12 12 12 14 14 15 18 19 37 214 232 245 251 252 254 252 249 244 238 229 232 222 184 160 49 23 60 224 252 254 254 251 246 213 23 22 23 19 13 20 17 18 18 18 18 18 19 19 22 22 22 21 20 19 19 19 21 21 20 21 22 22 20 18 19 18 18 18 19 18 18 17 15 18 19 19 18 16 13 14 128 138 138 144 137 142 135 140 183 167 71 11 15 13 19 30 14 14 15 16 16 15 15 14 15 15 15 14 14 14 14 14 13 13 13 13 13 13 12 12 12 13 14 15 13 12 12 12 13 13 14 13 13 13 15 16 25 170 237 242 245 253 249 253 249 136 79 73 50 34 29 24 24 25 15 38 205 249 254 251 254 116 22 15 17 19 17 20 19 19 19 19 20 21 20 20 20 20 20 21 21 21 22 22 22 21 21 22 22 22 20 19 23 22 21 20 19 18 17 16 15 16 19 19 18 15 14 14 84 135 145 136 140 139 137 143 177 178 133 47 14 18 24 16 14 13 14 15 15 14 13 14 14 15 14 14 14 13 13 13 15 15 14 13 13 13 12 12 11 12 14 14 13 12 13 13 12 13 14 13 13 13 13 14 22 118 225 243 253 247 254 249 111 23 7 29 18 17 24 18 16 20 31 18 43 216 253 244 225 39 24 18 17 22 20 20 20 20 20 20 21 21 20 20 21 21 22 22 22 22 23 22 24 23 23 24 24 24 23 22 25 24 22 20 19 17 15 14 15 17 18 18 17 15 15 16 42 146 146 136 141 136 141 140 176 168 172 119 18 22 22 16 14 13 14 15 15 15 13 14 14 15 15 15 14 14 14 13 16 16 15 13 13 13 13 13 12 13 14 14 12 12 12 13 10 11 13 13 13 13 14 14 18 82 224 251 253 250 248 104 19 15 26 27 23 27 20 15 27 14 10 11 30 48 227 249 136 24 21 24 20 21 20 19 20 20 20 20 21 20 19 19 24 24 24 23 22 21 21 21 23 23 23 24 24 24 23 22 22 21 20 19 18 17 16 15 16 17 17 17 16 14 15 15 22 140 135 143 139 137 146 136 181 163 184 159 45 20 14 17 15 15 14 15 15 15 14 15 14 15 15 15 15 15 14 14 17 16 15 14 13 13 13 13 13 13 14 14 12 11 11 12 10 11 12 13 13 13 14 14 20 36 201 237 248 254 99 13 16 23 21 11 16 21 16 27 20 20 23 21 19 15 83 229 48 21 18 21 19 17 21 17 21 21 21 20 21 21 20 20 25 25 24 24 23 21 21 20 20 21 21 21 21 21 21 21 21 20 19 18 19 18 17 16 17 16 17 16 15 13 14 14 14 90 138 143 136 140 145 139 179 166 175 150 85 23 8 16 15 15 14 14 15 15 14 15 13 15 15 16 16 15 15 14 16 15 15 14 13 13 13 13 13 14 14 13 11 10 11 11 11 12 13 13 12 12 13 13 14 27 125 240 254 97 20 22 19 11 15 15 14 17 15 19 16 17 14 16 10 33 13 67 23 13 27 19 20 18 23 18 22 22 21 21 22 22 21 21 23 23 23 24 23 22 21 21 20 21 22 22 21 21 22 22 22 21 20 20 19 19 18 17 16 16 17 16 15 13 14 14 15 35 146 140 141 144 137 147 176 167 167 146 115 22 15 11 15 15 14 15 14 14 14 15 13 14 15 15 16 15 14 14 14 14 14 14 14 13 13 13 12 13 13 13 11 11 11 12 12 12 13 12 12 12 14 15 11 28 67 238 117 18 11 11 15 10 21 19 9 15 17 13 18 20 22 16 30 9 20 24 27 15 31 22 20 22 21 19 21 21 21 21 22 22 21 21 22 23 23 23 22 21 20 19 21 22 23 22 21 21 23 24 22 21 20 19 20 19 18 17 14 15 17 15 15 13 14 13 17 15 119 141 143 142 137 148 179 167 166 161 121 19 22 6 14 13 13 14 13 13 13 14 12 13 14 15 15 15 14 13 13 13 14 14 14 14 13 12 11 12 13 12 11 11 12 13 10 11 11 12 12 14 16 18 21 10 32 105 15 19 18 10 14 12 17 14 11 13 12 19 16 16 21 19 12 30 20 23 18 22 20 21 14 23 16 20 19 19 20 20 21 21 21 21 24 24 24 23 22 19 18 17 17 19 20 20 18 18 20 21 19 18 18 18 19 19 19 18 13 14 16 16 15 13 13 13 10 17 71 143 141 138 146 143 180 164 170 155 126 30 12 15 13 12 11 13 12 14 15 17 13 13 13 13 13 14 14 15 15 14 13 13 14 14 13 12 13 13 12 12 11 11 12 12 14 14 13 12 12 13 14 16 16 16 28 15 16 25 10 16 23 18 20 16 23 11 21 39 29 34 44 21 19 18 19 23 21 20 19 20 22 22 21 20 21 21 21 21 22 23 22 23 23 22 21 22 23 23 23 22 19 19 18 16 16 17 20 22 21 19 18 17 17 18 18 18 14 14 14 15 15 15 15 16 17 15 34 144 143 140 146 142 182 168 169 155 127 26 10 14 13 12 13 14 13 13 13 14 13 14 14 13 14 14 15 15 14 13 13 13 14 14 13 12 13 13 13 12 11 12 12 12 13 13 13 12 11 11 13 15 17 16 25 17 11 13 8 18 12 15 13 127 169 198 214 204 210 200 184 157 28 16 19 16 19 19 18 19 21 22 21 20 20 19 18 17 18 18 19 19 20 20 20 22 24 24 24 22 19 19 18 16 16 17 20 22 22 20 18 17 17 17 16 17 15 16 14 14 13 13 13 13 12 11 22 122 140 143 144 145 180 170 165 154 129 20 10 13 13 13 14 14 13 12 11 11 13 14 14 14 14 15 15 15 14 13 12 12 13 14 14 13 14 14 13 13 12 12 13 13 13 13 13 12 11 11 13 14 12 17 21 17 15 23 25 16 25 21 103 203 239 251 254 254 251 251 241 222 90 25 17 15 17 17 18 19 20 21 22 21 20 19 17 15 15 16 16 17 18 19 20 23 24 24 23 21 19 19 18 16 16 17 19 21 22 20 18 17 16 16 15 14 17 17 15 15 14 13 12 12 10 11 10 88 138 144 142 147 177 171 162 154 126 15 13 13 13 14 13 13 12 12 11 11 14 14 14 14 14 15 15 15 13 12 12 12 13 14 14 13 14 14 14 14 13 13 13 13 14 15 14 13 12 12 13 15 15 18 16 17 16 20 26 13 17 28 174 220 254 254 247 254 249 248 236 221 115 24 15 21 17 17 18 19 20 20 22 22 21 20 18 16 17 17 17 17 18 20 21 23 23 22 20 18 18 18 17 16 15 15 17 19 20 19 17 16 16 16 15 14 17 15 15 14 13 12 11 11 13 12 9 55 143 145 142 146 177 172 162 155 114 13 15 14 14 14 12 11 11 12 13 13 13 13 13 14 14 14 14 14 14 13 12 12 13 13 14 13 14 14 14 14 13 13 13 13 14 14 14 14 12 12 13 15 17 14 13 23 22 16 24 28 21 102 201 248 254 253 254 251 253 252 238 225 63 17 18 16 17 18 20 21 20 21 21 22 20 20 20 20 21 20 19 19 21 22 23 23 21 18 16 15 18 18 17 15 14 14 16 17 19 17 16 16 16 16 15 14 14 15 13 13 12 13 12 12 15 12 14 31 144 144 143 144 178 170 164 156 95 12 14 13 13 14 12 11 11 12 14 15 13 13 13 14 14 14 14 14 17 15 13 12 13 13 13 13 14 14 14 14 13 13 13 13 12 13 13 13 12 12 12 14 12 16 17 18 26 25 19 19 52 163 221 253 252 249 254 253 248 239 230 171 21 18 26 13 19 20 22 22 21 21 21 22 20 20 21 22 23 22 21 20 24 24 23 21 18 15 14 14 18 18 17 16 14 14 16 17 17 16 16 16 16 16 15 15 14 14 13 12 12 13 12 13 14 10 15 16 134 145 145 144 177 167 165 155 76 13 12 13 13 13 14 14 12 13 14 14 13 13 14 14 15 14 14 14 19 17 15 13 13 13 12 12 13 13 14 14 13 13 12 12 12 12 13 13 12 12 13 14 14 20 21 13 19 19 16 42 147 206 248 251 254 254 254 250 254 235 209 75 20 21 23 21 21 22 24 23 21 20 20 21 22 22 22 22 23 23 22 22 24 24 22 19 15 14 15 16 20 19 19 17 16 15 16 17 17 17 16 15 15 15 14 13 13 14 13 12 12 12 13 13 13 12 13 14 114 146 145 146 175 163 165 155 63 14 14 15 14 13 14 14 14 13 12 11 13 14 14 15 15 15 15 14 20 18 15 14 13 12 12 11 13 13 14 14 13 13 12 12 12 13 14 14 13 13 14 15 17 9 20 26 27 15 46 146 205 233 252 253 248 253 252 254 241 204 174 21 25 28 16 25 22 24 25 24 21 21 21 22 25 25 24 23 24 23 23 24 23 23 21 17 14 13 15 17 21 22 20 18 18 17 18 19 19 18 17 15 15 14 13 12 13 13 13 13 11 12 12 11 15 15 11 16 99 148 143 147 168 167 165 159 51 12 16 10 16 15 13 12 12 12 12 13 11 9 19 4 24 15 10 16 16 12 11 18 7 13 13 9 7 21 14 11 13 14 18 12 16 16 15 14 13 13 14 15 19 11 25 23 24 21 153 192 228 251 249 253 253 253 251 248 211 189 61 26 27 23 18 25 27 25 23 23 20 17 17 20 24 15 24 21 19 24 20 19 22 17 19 11 22 13 19 19 20 13 20 14 20 22 19 18 19 16 17 16 16 16 11 13 15 15 15 14 13 13 13 13 17 12 13 18 80 147 151 146 170 167 163 159 39 10 16 12 15 14 13 13 12 13 12 14 22 9 12 26 11 11 31 12 17 16 16 22 10 15 16 16 10 7 11 13 22 23 4 24 15 15 15 13 12 12 13 14 14 19 18 17 24 33 127 195 222 253 253 252 253 253 243 215 158 113 35 20 22 26 20 23 25 24 21 22 21 18 18 20 23 17 22 28 26 23 26 26 21 20 16 14 8 15 19 19 25 14 28 10 14 13 17 19 17 13 13 15 17 17 15 16 14 15 14 14 12 14 13 14 15 13 15 16 67 149 151 148 174 163 160 158 25 9 16 15 14 12 12 13 12 13 12 12 7 14 131 138 140 122 111 92 84 72 53 41 20 18 13 10 19 15 18 14 8 21 9 14 15 15 14 13 12 11 12 13 11 24 11 16 20 30 76 183 217 242 249 253 253 247 209 150 113 47 21 23 22 29 22 22 24 22 22 23 23 20 19 21 19 26 19 20 19 20 20 14 17 22 22 25 12 22 21 19 12 21 18 19 24 22 13 14 18 16 15 16 15 11 10 12 12 13 13 13 12 14 13 14 15 16 16 16 50 152 150 152 173 162 159 153 15 11 15 15 12 12 13 14 13 13 12 12 29 8 133 186 253 253 245 144 147 154 161 178 182 185 169 157 134 128 100 77 15 3 25 17 15 15 14 13 12 12 12 13 13 19 11 22 20 20 31 151 193 235 252 249 240 218 156 102 84 25 25 27 24 25 23 21 21 22 23 23 23 21 21 21 14 27 23 22 24 22 26 75 58 64 68 68 67 66 66 68 72 112 20 17 15 18 10 20 13 14 12 18 17 11 14 16 11 12 13 12 13 14 13 15 14 17 16 13 35 150 148 150 169 161 162 139 13 13 13 13 11 12 13 14 13 13 12 12 10 32 142 196 249 251 209 122 146 151 150 160 166 181 182 185 178 179 169 171 96 18 6 9 15 15 15 14 13 13 15 15 16 13 18 25 24 23 19 100 180 218 245 235 213 154 106 121 49 20 24 23 24 16 21 22 20 22 23 24 23 22 22 20 31 18 14 20 29 16 17 140 84 89 83 83 90 89 87 99 89 177 30 17 19 20 18 18 20 18 11 17 16 8 12 10 12 13 13 13 14 14 15 15 13 16 13 11 24 136 145 147 168 161 164 114 14 16 12 13 13 12 13 13 12 13 12 12 7 42 168 186 213 226 202 161 143 165 175 183 179 182 178 183 182 173 169 175 153 78 18 14 14 15 16 15 14 14 16 17 19 13 20 18 22 27 22 43 178 194 223 219 168 130 140 136 22 20 23 20 26 15 21 21 21 23 23 23 23 23 21 20 18 21 30 17 20 22 21 153 85 87 88 88 90 90 91 93 98 175 41 19 18 10 22 13 10 15 13 23 20 7 14 14 13 13 13 14 15 15 16 15 16 16 18 15 21 119 147 148 167 165 164 86 16 15 11 13 14 14 14 13 12 13 12 13 22 58 171 211 206 193 222 149 139 170 188 200 199 200 193 198 197 191 187 181 190 151 81 8 13 15 16 16 15 15 17 18 19 17 18 18 20 22 25 17 134 199 217 184 135 155 194 79 19 21 23 20 23 21 21 21 22 25 25 23 21 22 21 19 24 19 18 27 92 156 105 110 98 83 120 98 101 87 116 81 128 140 91 126 103 92 77 69 74 100 109 105 63 15 12 15 13 15 15 15 17 17 15 15 18 16 23 16 19 96 149 153 167 166 164 68 17 14 11 15 15 14 14 13 12 12 12 13 15 76 129 174 224 217 149 122 135 154 156 161 164 172 171 179 178 174 171 167 171 164 152 33 13 14 15 16 15 15 17 18 15 18 14 26 23 15 28 25 73 196 187 155 138 139 156 16 21 14 20 16 17 25 20 19 24 26 25 22 21 23 21 19 17 25 43 82 166 243 175 107 139 101 173 115 132 99 165 98 185 110 108 193 135 128 88 97 81 135 166 156 86 13 8 18 15 16 15 16 17 17 16 15 15 15 22 15 16 78 147 153 172 162 165 39 14 17 12 12 12 12 13 13 12 11 12 13 16 53 93 112 110 110 124 141 142 147 154 159 163 166 172 177 166 169 163 163 162 157 154 32 12 13 14 15 14 13 13 12 16 17 17 17 18 18 19 20 16 180 174 114 78 143 42 14 20 17 14 15 18 21 21 22 28 22 18 21 24 21 20 23 22 47 78 104 186 238 175 104 137 100 182 125 143 118 168 107 184 120 105 176 141 127 95 93 87 117 148 161 84 17 14 16 15 16 17 16 17 15 16 17 17 18 20 14 20 60 147 153 170 163 156 31 11 16 12 14 14 14 15 14 14 13 15 15 9 13 16 12 7 10 21 32 39 47 58 71 85 98 111 118 133 143 146 150 152 153 139 30 12 13 13 13 13 13 14 14 16 16 16 17 17 16 17 18 23 90 142 70 58 95 12 19 20 18 17 16 18 19 19 21 19 18 21 24 20 17 19 25 51 87 103 98 89 118 87 92 118 154 139 120 125 150 106 112 136 109 87 99 86 96 85 75 80 81 86 120 38 9 11 17 15 16 18 19 17 16 16 15 18 17 19 18 19 46 150 154 167 164 138 21 10 16 11 15 12 13 13 13 12 12 14 14 15 13 12 13 14 14 14 13 16 16 15 13 11 10 12 13 16 14 19 32 35 44 53 15 12 12 12 11 12 13 16 17 16 16 15 15 16 15 15 16 18 26 82 59 62 33 12 17 16 15 16 17 18 19 21 22 23 21 21 20 19 24 40 58 124 175 176 155 78 78 81 136 163 189 74 146 180 228 66 91 172 151 115 88 87 86 82 81 84 78 82 135 31 17 13 20 15 15 18 19 17 16 16 16 17 16 17 23 17 29 153 153 164 164 120 12 9 16 10 15 11 11 12 11 12 11 13 13 11 12 13 15 15 15 14 14 14 15 15 14 13 12 14 15 14 8 13 17 7 8 12 12 12 12 11 11 12 13 15 15 17 16 15 14 15 15 15 14 12 15 30 63 56 8 22 14 13 15 16 16 16 18 21 24 26 23 21 18 22 34 57 76 140 182 170 151 82 79 81 116 161 192 98 148 156 210 90 111 167 141 108 89 95 83 77 83 88 85 93 130 38 16 8 11 15 17 17 17 17 17 15 16 17 18 17 23 16 18 156 151 161 161 101 11 12 16 9 14 13 13 14 13 13 12 14 14 15 17 16 13 10 9 11 13 12 13 14 14 13 12 12 12 12 14 20 11 12 25 16 9 12 12 12 12 12 12 12 12 16 16 14 15 13 13 13 13 17 13 18 38 25 18 12 20 17 16 16 15 16 17 19 22 21 20 18 20 24 30 40 47 68 83 66 62 38 41 40 45 58 63 28 38 36 69 35 38 49 39 27 24 24 26 22 19 25 19 22 37 13 9 17 20 16 17 17 16 15 16 16 17 16 18 18 19 17 18 149 150 162 156 82 13 14 16 10 13 12 12 13 12 12 12 12 14 14 14 15 17 19 18 16 14 15 16 17 18 18 18 17 16 18 15 21 8 9 15 11 12 13 13 12 12 12 12 11 11 14 14 15 15 14 14 14 16 17 15 19 15 10 22 11 15 14 15 15 16 17 20 22 24 20 18 17 18 22 23 20 19 21 22 19 25 24 23 26 28 26 22 25 30 29 24 22 26 24 22 23 32 16 22 21 19 25 17 16 6 16 9 17 15 17 17 16 15 15 16 16 18 16 18 19 15 18 18 127 151 166 151 68 15 15 13 12 13 11 10 12 10 11 11 11 13 19 14 9 7 10 13 14 14 13 13 13 13 13 12 11 10 9 2 18 16 20 7 11 18 13 12 12 11 11 11 11 12 13 13 14 15 15 15 16 18 14 20 15 17 13 16 20 12 14 15 17 18 21 22 23 23 20 19 19 17 20 20 22 22 26 22 28 32 26 22 19 24 27 32 27 19 23 33 31 16 22 21 22 30 21 18 20 25 16 20 25 16 18 12 13 12 16 16 16 16 16 16 16 17 18 15 19 13 19 16 97 154 169 148 60 16 15 11 14 13 12 12 13 12 12 13 13 14 13 14 15 15 15 16 15 15 15 14 14 14 14 14 14 14 17 8 17 6 18 13 21 12 14 12 11 10 10 11 12 13 13 13 14 15 15 16 17 18 21 10 12 21 8 15 19 18 21 20 20 23 23 21 18 15 14 17 20 20 20 20 23 24 23 21 23 23 17 28 23 24 20 23 22 34 26 20 20 26 22 27 23 13 21 23 19 17 19 19 19 18 9 17 15 20 16 16 18 17 16 17 16 16 19 11 19 13 20 13 75 157 \ No newline at end of file diff --git a/Tests/images/hopper_8bit_plain.ppm b/Tests/images/hopper_8bit_plain.ppm new file mode 100644 index 000000000..c39a92a0b Binary files /dev/null and b/Tests/images/hopper_8bit_plain.ppm differ diff --git a/Tests/images/hopper_rle8_greyscale.bmp b/Tests/images/hopper_rle8_greyscale.bmp new file mode 100644 index 000000000..ead32ff95 Binary files /dev/null and b/Tests/images/hopper_rle8_greyscale.bmp differ diff --git a/Tests/images/imagedraw_polygon_1px_high_translucent.png b/Tests/images/imagedraw_polygon_1px_high_translucent.png new file mode 100644 index 000000000..8bbf9397c Binary files /dev/null and b/Tests/images/imagedraw_polygon_1px_high_translucent.png differ diff --git a/Tests/images/input_bw_one_band.fpx b/Tests/images/input_bw_one_band.fpx new file mode 100644 index 000000000..9bdc53763 Binary files /dev/null and b/Tests/images/input_bw_one_band.fpx differ diff --git a/Tests/images/input_bw_one_band.png b/Tests/images/input_bw_one_band.png new file mode 100644 index 000000000..6b4c1f376 Binary files /dev/null and b/Tests/images/input_bw_one_band.png differ diff --git a/Tests/images/issue_6194.j2k b/Tests/images/issue_6194.j2k new file mode 100644 index 000000000..b1b885167 Binary files /dev/null and b/Tests/images/issue_6194.j2k differ diff --git a/Tests/images/multiple_comments.gif b/Tests/images/multiple_comments.gif new file mode 100644 index 000000000..88b2af800 Binary files /dev/null and b/Tests/images/multiple_comments.gif differ diff --git a/Tests/images/palette_negative.png b/Tests/images/palette_negative.png index 938a7285f..7fcfd29a0 100644 Binary files a/Tests/images/palette_negative.png and b/Tests/images/palette_negative.png differ diff --git a/Tests/images/palette_sepia.png b/Tests/images/palette_sepia.png index f3fc93253..9e7d6b034 100644 Binary files a/Tests/images/palette_sepia.png and b/Tests/images/palette_sepia.png differ diff --git a/Tests/images/palette_wedge.png b/Tests/images/palette_wedge.png index 23fb7940d..4b3d9ff3a 100644 Binary files a/Tests/images/palette_wedge.png and b/Tests/images/palette_wedge.png differ diff --git a/Tests/images/rectangle_surrounding_text.png b/Tests/images/rectangle_surrounding_text.png index 2b75a5e9c..ca77cea73 100644 Binary files a/Tests/images/rectangle_surrounding_text.png and b/Tests/images/rectangle_surrounding_text.png differ diff --git a/Tests/images/rgb32bf-abgr.bmp b/Tests/images/rgb32bf-abgr.bmp new file mode 100644 index 000000000..2443714ca Binary files /dev/null and b/Tests/images/rgb32bf-abgr.bmp differ diff --git a/Tests/images/rgba.psd b/Tests/images/rgba.psd new file mode 100644 index 000000000..45fb7c3cc Binary files /dev/null and b/Tests/images/rgba.psd differ diff --git a/Tests/images/second_frame_comment.gif b/Tests/images/second_frame_comment.gif new file mode 100644 index 000000000..c8fc95791 Binary files /dev/null and b/Tests/images/second_frame_comment.gif differ diff --git a/Tests/images/tiny.png b/Tests/images/tiny.png new file mode 100644 index 000000000..3d9ff56e7 Binary files /dev/null and b/Tests/images/tiny.png differ diff --git a/Tests/images/xmp_tags_orientation_exiftool.png b/Tests/images/xmp_tags_orientation_exiftool.png new file mode 100644 index 000000000..10f0f4400 Binary files /dev/null and b/Tests/images/xmp_tags_orientation_exiftool.png differ diff --git a/Tests/oss-fuzz/fuzzers.py b/Tests/oss-fuzz/fuzzers.py index 5786764a6..10a172b46 100644 --- a/Tests/oss-fuzz/fuzzers.py +++ b/Tests/oss-fuzz/fuzzers.py @@ -33,9 +33,9 @@ def fuzz_font(data): # different font objects. return - font.getsize_multiline("ABC\nAaaa") + font.getbbox("ABC") font.getmask("test text") with Image.new(mode="RGBA", size=(200, 200)) as im: draw = ImageDraw.Draw(im) - draw.multiline_textsize("ABC\nAaaa", font, stroke_width=2) + draw.multiline_textbbox((10, 10), "ABC\nAaaa", font, stroke_width=2) draw.text((10, 10), "Test Text", font=font, fill="#000") diff --git a/Tests/test_decompression_bomb.py b/Tests/test_decompression_bomb.py index 1572328de..63071b78c 100644 --- a/Tests/test_decompression_bomb.py +++ b/Tests/test_decompression_bomb.py @@ -51,7 +51,6 @@ class TestDecompressionBomb: with Image.open(TEST_FILE): pass - @pytest.mark.xfail(reason="different exception") def test_exception_ico(self): with pytest.raises(Image.DecompressionBombError): with Image.open("Tests/images/decompression_bomb.ico"): @@ -62,6 +61,11 @@ class TestDecompressionBomb: with Image.open("Tests/images/decompression_bomb.gif"): pass + def test_exception_gif_extents(self): + with Image.open("Tests/images/decompression_bomb_extents.gif") as im: + with pytest.raises(Image.DecompressionBombError): + im.seek(1) + def test_exception_bmp(self): with pytest.raises(Image.DecompressionBombError): with Image.open("Tests/images/bmp/b/reallybig.bmp"): diff --git a/Tests/test_file_apng.py b/Tests/test_file_apng.py index d1d5c85c1..0ff05f608 100644 --- a/Tests/test_file_apng.py +++ b/Tests/test_file_apng.py @@ -325,8 +325,9 @@ def test_apng_syntax_errors(): pytest.warns(UserWarning, open) -def test_apng_sequence_errors(): - test_files = [ +@pytest.mark.parametrize( + "test_file", + ( "sequence_start.png", "sequence_gap.png", "sequence_repeat.png", @@ -334,12 +335,13 @@ def test_apng_sequence_errors(): "sequence_reorder.png", "sequence_reorder_chunk.png", "sequence_fdat_fctl.png", - ] - for f in test_files: - with pytest.raises(SyntaxError): - with Image.open(f"Tests/images/apng/{f}") as im: - im.seek(im.n_frames - 1) - im.load() + ), +) +def test_apng_sequence_errors(test_file): + with pytest.raises(SyntaxError): + with Image.open(f"Tests/images/apng/{test_file}") as im: + im.seek(im.n_frames - 1) + im.load() def test_apng_save(tmp_path): @@ -637,6 +639,15 @@ def test_apng_save_blend(tmp_path): assert im.getpixel((0, 0)) == (0, 255, 0, 255) +def test_seek_after_close(): + im = Image.open("Tests/images/apng/delay.png") + im.seek(1) + im.close() + + with pytest.raises(ValueError): + im.seek(0) + + def test_constants_deprecation(): for enum, prefix in { PngImagePlugin.Disposal: "APNG_DISPOSE_", diff --git a/Tests/test_file_bmp.py b/Tests/test_file_bmp.py index f214fd6bd..d58666b44 100644 --- a/Tests/test_file_bmp.py +++ b/Tests/test_file_bmp.py @@ -129,11 +129,21 @@ def test_rgba_bitfields(): assert_image_equal_tofile(im, "Tests/images/bmp/q/rgb32bf-xbgr.bmp") + # This test image has been manually hexedited + # to change the bitfield compression in the header from XBGR to ABGR + with Image.open("Tests/images/rgb32bf-abgr.bmp") as im: + assert_image_equal_tofile( + im.convert("RGB"), "Tests/images/bmp/q/rgb32bf-xbgr.bmp" + ) + def test_rle8(): with Image.open("Tests/images/hopper_rle8.bmp") as im: assert_image_similar_tofile(im.convert("RGB"), "Tests/images/hopper.bmp", 12) + with Image.open("Tests/images/hopper_rle8_greyscale.bmp") as im: + assert_image_equal_tofile(im, "Tests/images/bw_gradient.png") + # This test image has been manually hexedited # to have rows with too much data with Image.open("Tests/images/hopper_rle8_row_overflow.bmp") as im: diff --git a/Tests/test_file_container.py b/Tests/test_file_container.py index b752e217f..65cf6a75e 100644 --- a/Tests/test_file_container.py +++ b/Tests/test_file_container.py @@ -1,3 +1,5 @@ +import pytest + from PIL import ContainerIO, Image from .helper import hopper @@ -59,89 +61,89 @@ def test_seek_mode_2(): assert container.tell() == 100 -def test_read_n0(): +@pytest.mark.parametrize("bytesmode", (True, False)) +def test_read_n0(bytesmode): # Arrange - for bytesmode in (True, False): - with open(TEST_FILE, "rb" if bytesmode else "r") as fh: - container = ContainerIO.ContainerIO(fh, 22, 100) + with open(TEST_FILE, "rb" if bytesmode else "r") as fh: + container = ContainerIO.ContainerIO(fh, 22, 100) - # Act - container.seek(81) - data = container.read() + # Act + container.seek(81) + data = container.read() - # Assert - if bytesmode: - data = data.decode() - assert data == "7\nThis is line 8\n" + # Assert + if bytesmode: + data = data.decode() + assert data == "7\nThis is line 8\n" -def test_read_n(): +@pytest.mark.parametrize("bytesmode", (True, False)) +def test_read_n(bytesmode): # Arrange - for bytesmode in (True, False): - with open(TEST_FILE, "rb" if bytesmode else "r") as fh: - container = ContainerIO.ContainerIO(fh, 22, 100) + with open(TEST_FILE, "rb" if bytesmode else "r") as fh: + container = ContainerIO.ContainerIO(fh, 22, 100) - # Act - container.seek(81) - data = container.read(3) + # Act + container.seek(81) + data = container.read(3) - # Assert - if bytesmode: - data = data.decode() - assert data == "7\nT" + # Assert + if bytesmode: + data = data.decode() + assert data == "7\nT" -def test_read_eof(): +@pytest.mark.parametrize("bytesmode", (True, False)) +def test_read_eof(bytesmode): # Arrange - for bytesmode in (True, False): - with open(TEST_FILE, "rb" if bytesmode else "r") as fh: - container = ContainerIO.ContainerIO(fh, 22, 100) + with open(TEST_FILE, "rb" if bytesmode else "r") as fh: + container = ContainerIO.ContainerIO(fh, 22, 100) - # Act - container.seek(100) - data = container.read() + # Act + container.seek(100) + data = container.read() - # Assert - if bytesmode: - data = data.decode() - assert data == "" + # Assert + if bytesmode: + data = data.decode() + assert data == "" -def test_readline(): +@pytest.mark.parametrize("bytesmode", (True, False)) +def test_readline(bytesmode): # Arrange - for bytesmode in (True, False): - with open(TEST_FILE, "rb" if bytesmode else "r") as fh: - container = ContainerIO.ContainerIO(fh, 0, 120) + with open(TEST_FILE, "rb" if bytesmode else "r") as fh: + container = ContainerIO.ContainerIO(fh, 0, 120) - # Act - data = container.readline() + # Act + data = container.readline() - # Assert - if bytesmode: - data = data.decode() - assert data == "This is line 1\n" + # Assert + if bytesmode: + data = data.decode() + assert data == "This is line 1\n" -def test_readlines(): +@pytest.mark.parametrize("bytesmode", (True, False)) +def test_readlines(bytesmode): # Arrange - for bytesmode in (True, False): - expected = [ - "This is line 1\n", - "This is line 2\n", - "This is line 3\n", - "This is line 4\n", - "This is line 5\n", - "This is line 6\n", - "This is line 7\n", - "This is line 8\n", - ] - with open(TEST_FILE, "rb" if bytesmode else "r") as fh: - container = ContainerIO.ContainerIO(fh, 0, 120) + expected = [ + "This is line 1\n", + "This is line 2\n", + "This is line 3\n", + "This is line 4\n", + "This is line 5\n", + "This is line 6\n", + "This is line 7\n", + "This is line 8\n", + ] + with open(TEST_FILE, "rb" if bytesmode else "r") as fh: + container = ContainerIO.ContainerIO(fh, 0, 120) - # Act - data = container.readlines() + # Act + data = container.readlines() - # Assert - if bytesmode: - data = [line.decode() for line in data] - assert data == expected + # Assert + if bytesmode: + data = [line.decode() for line in data] + assert data == expected diff --git a/Tests/test_file_dds.py b/Tests/test_file_dds.py index 58447122e..351001199 100644 --- a/Tests/test_file_dds.py +++ b/Tests/test_file_dds.py @@ -10,6 +10,8 @@ from .helper import assert_image_equal, assert_image_equal_tofile, hopper TEST_FILE_DXT1 = "Tests/images/dxt1-rgb-4bbp-noalpha_MipMaps-1.dds" TEST_FILE_DXT3 = "Tests/images/dxt3-argb-8bbp-explicitalpha_MipMaps-1.dds" TEST_FILE_DXT5 = "Tests/images/dxt5-argb-8bbp-interpolatedalpha_MipMaps-1.dds" +TEST_FILE_ATI1 = "Tests/images/ati1.dds" +TEST_FILE_ATI2 = "Tests/images/ati2.dds" TEST_FILE_DX10_BC5_TYPELESS = "Tests/images/bc5_typeless.dds" TEST_FILE_DX10_BC5_UNORM = "Tests/images/bc5_unorm.dds" TEST_FILE_DX10_BC5_SNORM = "Tests/images/bc5_snorm.dds" @@ -62,6 +64,32 @@ def test_sanity_dxt5(): assert_image_equal_tofile(im, TEST_FILE_DXT5.replace(".dds", ".png")) +def test_sanity_ati1(): + """Check ATI1 images can be opened""" + + with Image.open(TEST_FILE_ATI1) as im: + im.load() + + assert im.format == "DDS" + assert im.mode == "L" + assert im.size == (64, 64) + + assert_image_equal_tofile(im, TEST_FILE_ATI1.replace(".dds", ".png")) + + +def test_sanity_ati2(): + """Check ATI2 images can be opened""" + + with Image.open(TEST_FILE_ATI2) as im: + im.load() + + assert im.format == "DDS" + assert im.mode == "RGB" + assert im.size == (256, 256) + + assert_image_equal_tofile(im, TEST_FILE_DX10_BC5_UNORM.replace(".dds", ".png")) + + @pytest.mark.parametrize( ("image_path", "expected_path"), ( diff --git a/Tests/test_file_fli.py b/Tests/test_file_fli.py index c1ad4a7f0..a7d43d2e9 100644 --- a/Tests/test_file_fli.py +++ b/Tests/test_file_fli.py @@ -46,6 +46,15 @@ def test_closed_file(): im.close() +def test_seek_after_close(): + im = Image.open(animated_test_file) + im.seek(1) + im.close() + + with pytest.raises(ValueError): + im.seek(0) + + def test_context_manager(): with warnings.catch_warnings(): with Image.open(static_test_file) as im: diff --git a/Tests/test_file_fpx.py b/Tests/test_file_fpx.py index 818565f88..fa22e90f6 100644 --- a/Tests/test_file_fpx.py +++ b/Tests/test_file_fpx.py @@ -2,11 +2,22 @@ import pytest from PIL import Image +from .helper import assert_image_equal_tofile + FpxImagePlugin = pytest.importorskip( "PIL.FpxImagePlugin", reason="olefile not installed" ) +def test_sanity(): + with Image.open("Tests/images/input_bw_one_band.fpx") as im: + assert im.mode == "L" + assert im.size == (70, 46) + assert im.format == "FPX" + + assert_image_equal_tofile(im, "Tests/images/input_bw_one_band.png") + + def test_invalid_file(): # Test an invalid OLE file invalid_file = "Tests/images/flower.jpg" diff --git a/Tests/test_file_gif.py b/Tests/test_file_gif.py index 3c2fab722..68cb8a36e 100644 --- a/Tests/test_file_gif.py +++ b/Tests/test_file_gif.py @@ -46,6 +46,19 @@ def test_closed_file(): im.close() +def test_seek_after_close(): + im = Image.open("Tests/images/iss634.gif") + im.load() + im.close() + + with pytest.raises(ValueError): + im.is_animated + with pytest.raises(ValueError): + im.n_frames + with pytest.raises(ValueError): + im.seek(1) + + def test_context_manager(): with warnings.catch_warnings(): with Image.open(TEST_GIF) as im: @@ -145,6 +158,9 @@ def test_optimize_correctness(): assert_image_equal(im.convert("RGB"), reloaded.convert("RGB")) # These do optimize the palette + check(256, 511, 256) + check(255, 511, 255) + check(129, 511, 129) check(128, 511, 128) check(64, 511, 64) check(4, 511, 4) @@ -154,11 +170,6 @@ def test_optimize_correctness(): check(64, 513, 256) check(4, 513, 256) - # Other limits that don't optimize the palette - check(129, 511, 256) - check(255, 511, 256) - check(256, 511, 256) - def test_optimize_full_l(): im = Image.frombytes("L", (16, 16), bytes(range(256))) @@ -167,6 +178,19 @@ def test_optimize_full_l(): assert im.mode == "L" +def test_optimize_if_palette_can_be_reduced_by_half(): + with Image.open("Tests/images/test.colors.gif") as im: + # Reduce dimensions because original is too big for _get_optimize() + im = im.resize((591, 443)) + im_rgb = im.convert("RGB") + + for (optimize, colors) in ((False, 256), (True, 8)): + out = BytesIO() + im_rgb.save(out, "GIF", optimize=optimize) + with Image.open(out) as reloaded: + assert len(reloaded.palette.palette) // 3 == colors + + def test_roundtrip(tmp_path): out = str(tmp_path / "temp.gif") im = hopper() @@ -341,16 +365,23 @@ def test_seek_rewind(): assert_image_equal(im, expected) -def test_n_frames(): - for path, n_frames in [[TEST_GIF, 1], ["Tests/images/iss634.gif", 42]]: - # Test is_animated before n_frames - with Image.open(path) as im: - assert im.is_animated == (n_frames != 1) +@pytest.mark.parametrize( + "path, n_frames", + ( + (TEST_GIF, 1), + ("Tests/images/comment_after_last_frame.gif", 2), + ("Tests/images/iss634.gif", 42), + ), +) +def test_n_frames(path, n_frames): + # Test is_animated before n_frames + with Image.open(path) as im: + assert im.is_animated == (n_frames != 1) - # Test is_animated after n_frames - with Image.open(path) as im: - assert im.n_frames == n_frames - assert im.is_animated == (n_frames != 1) + # Test is_animated after n_frames + with Image.open(path) as im: + assert im.n_frames == n_frames + assert im.is_animated == (n_frames != 1) def test_no_change(): @@ -368,6 +399,11 @@ def test_no_change(): assert im.is_animated assert_image_equal(im, expected) + with Image.open("Tests/images/comment_after_only_frame.gif") as im: + expected = Image.new("P", (1, 1)) + assert not im.is_animated + assert_image_equal(im, expected) + def test_eoferror(): with Image.open(TEST_GIF) as im: @@ -619,7 +655,8 @@ def test_dispose2_background(tmp_path): assert im.getpixel((0, 0)) == (255, 0, 0) -def test_transparency_in_second_frame(): +def test_transparency_in_second_frame(tmp_path): + out = str(tmp_path / "temp.gif") with Image.open("Tests/images/different_transparency.gif") as im: assert im.info["transparency"] == 0 @@ -629,6 +666,14 @@ def test_transparency_in_second_frame(): assert_image_equal_tofile(im, "Tests/images/different_transparency_merged.png") + im.save(out, save_all=True) + + with Image.open(out) as reread: + reread.seek(reread.tell() + 1) + assert_image_equal_tofile( + reread, "Tests/images/different_transparency_merged.png" + ) + def test_no_transparency_in_second_frame(): with Image.open("Tests/images/iss634.gif") as img: @@ -640,6 +685,22 @@ def test_no_transparency_in_second_frame(): assert img.histogram()[255] == 0 +def test_remapped_transparency(tmp_path): + out = str(tmp_path / "temp.gif") + + im = Image.new("P", (1, 2)) + im2 = im.copy() + + # Add transparency at a higher index + # so that it will be optimized to a lower index + im.putpixel((0, 1), 5) + im.info["transparency"] = 5 + im.save(out, save_all=True, append_images=[im2]) + + with Image.open(out) as reloaded: + assert reloaded.info["transparency"] == reloaded.getpixel((0, 1)) + + def test_duration(tmp_path): duration = 1000 @@ -759,9 +820,16 @@ def test_number_of_loops(tmp_path): im = Image.new("L", (100, 100), "#000") im.save(out, loop=number_of_loops) with Image.open(out) as reread: - assert reread.info["loop"] == number_of_loops + # Check that even if a subsequent GIF frame has the number of loops specified, + # only the value from the first frame is used + with Image.open("Tests/images/duplicate_number_of_loops.gif") as im: + assert im.info["loop"] == 2 + + im.seek(1) + assert im.info["loop"] == 2 + def test_background(tmp_path): out = str(tmp_path / "temp.gif") @@ -794,6 +862,9 @@ def test_comment(tmp_path): with Image.open(out) as reread: assert reread.info["comment"] == im.info["comment"].encode() + # Test that GIF89a is used for comments + assert reread.info["version"] == b"GIF89a" + def test_comment_over_255(tmp_path): out = str(tmp_path / "temp.gif") @@ -804,15 +875,67 @@ def test_comment_over_255(tmp_path): im.info["comment"] = comment im.save(out) with Image.open(out) as reread: - assert reread.info["comment"] == comment + # Test that GIF89a is used for comments + assert reread.info["version"] == b"GIF89a" + def test_zero_comment_subblocks(): with Image.open("Tests/images/hopper_zero_comment_subblocks.gif") as im: assert_image_equal_tofile(im, TEST_GIF) +def test_read_multiple_comment_blocks(): + with Image.open("Tests/images/multiple_comments.gif") as im: + # Multiple comment blocks in a frame are separated not concatenated + assert im.info["comment"] == b"Test comment 1\nTest comment 2" + + +def test_empty_string_comment(tmp_path): + out = str(tmp_path / "temp.gif") + with Image.open("Tests/images/chi.gif") as im: + assert "comment" in im.info + + # Empty string comment should suppress existing comment + im.save(out, save_all=True, comment="") + + with Image.open(out) as reread: + for frame in ImageSequence.Iterator(reread): + assert "comment" not in frame.info + + +def test_retain_comment_in_subsequent_frames(tmp_path): + # Test that a comment block at the beginning is kept + with Image.open("Tests/images/chi.gif") as im: + for frame in ImageSequence.Iterator(im): + assert frame.info["comment"] == b"Created with GIMP" + + with Image.open("Tests/images/second_frame_comment.gif") as im: + assert "comment" not in im.info + + # Test that a comment in the middle is read + im.seek(1) + assert im.info["comment"] == b"Comment in the second frame" + + # Test that it is still present in a later frame + im.seek(2) + assert im.info["comment"] == b"Comment in the second frame" + + # Test that rewinding removes the comment + im.seek(0) + assert "comment" not in im.info + + # Test that a saved image keeps the comment + out = str(tmp_path / "temp.gif") + with Image.open("Tests/images/dispose_prev.gif") as im: + im.save(out, save_all=True, comment="Test") + + with Image.open(out) as reread: + for frame in ImageSequence.Iterator(reread): + assert frame.info["comment"] == b"Test" + + def test_version(tmp_path): out = str(tmp_path / "temp.gif") @@ -875,8 +998,8 @@ def test_append_images(tmp_path): def test_transparent_optimize(tmp_path): # From issue #2195, if the transparent color is incorrectly optimized out, GIF loses # transparency. - # Need a palette that isn't using the 0 color, and one that's > 128 items where the - # transparent color is actually the top palette entry to trigger the bug. + # Need a palette that isn't using the 0 color, + # where the transparent color is actually the top palette entry to trigger the bug. data = bytes(range(1, 254)) palette = ImagePalette.ImagePalette("RGB", list(range(256)) * 3) @@ -886,10 +1009,10 @@ def test_transparent_optimize(tmp_path): im.putpalette(palette) out = str(tmp_path / "temp.gif") - im.save(out, transparency=253) - with Image.open(out) as reloaded: + im.save(out, transparency=im.getpixel((252, 0))) - assert reloaded.info["transparency"] == 253 + with Image.open(out) as reloaded: + assert reloaded.info["transparency"] == reloaded.getpixel((252, 0)) def test_rgb_transparency(tmp_path): diff --git a/Tests/test_file_im.py b/Tests/test_file_im.py index 675210c30..e458a197c 100644 --- a/Tests/test_file_im.py +++ b/Tests/test_file_im.py @@ -78,15 +78,12 @@ def test_eoferror(): im.seek(n_frames - 1) -def test_roundtrip(tmp_path): - def roundtrip(mode): - out = str(tmp_path / "temp.im") - im = hopper(mode) - im.save(out) - assert_image_equal_tofile(im, out) - - for mode in ["RGB", "P", "PA"]: - roundtrip(mode) +@pytest.mark.parametrize("mode", ("RGB", "P", "PA")) +def test_roundtrip(mode, tmp_path): + out = str(tmp_path / "temp.im") + im = hopper(mode) + im.save(out) + assert_image_equal_tofile(im, out) def test_save_unsupported_mode(tmp_path): diff --git a/Tests/test_file_jpeg2k.py b/Tests/test_file_jpeg2k.py index 677a14981..7942d6b9a 100644 --- a/Tests/test_file_jpeg2k.py +++ b/Tests/test_file_jpeg2k.py @@ -298,6 +298,11 @@ def test_16bit_jp2_roundtrips(): assert_image_equal(im, jp2) +def test_issue_6194(): + with Image.open("Tests/images/issue_6194.j2k") as im: + assert im.getpixel((5, 5)) == 31 + + def test_unbound_local(): # prepatch, a malformed jp2 file could cause an UnboundLocalError exception. with pytest.raises(OSError): diff --git a/Tests/test_file_libtiff.py b/Tests/test_file_libtiff.py index d83c584b5..86a0fda04 100644 --- a/Tests/test_file_libtiff.py +++ b/Tests/test_file_libtiff.py @@ -135,50 +135,50 @@ class TestFileLibTiff(LibTiffTestCase): assert_image_equal_tofile(im, "Tests/images/tiff_adobe_deflate.png") - def test_write_metadata(self, tmp_path): + @pytest.mark.parametrize("legacy_api", (False, True)) + def test_write_metadata(self, legacy_api, tmp_path): """Test metadata writing through libtiff""" - for legacy_api in [False, True]: - f = str(tmp_path / "temp.tiff") - with Image.open("Tests/images/hopper_g4.tif") as img: - img.save(f, tiffinfo=img.tag) + f = str(tmp_path / "temp.tiff") + with Image.open("Tests/images/hopper_g4.tif") as img: + img.save(f, tiffinfo=img.tag) - if legacy_api: - original = img.tag.named() - else: - original = img.tag_v2.named() + if legacy_api: + original = img.tag.named() + else: + original = img.tag_v2.named() - # PhotometricInterpretation is set from SAVE_INFO, - # not the original image. - ignored = [ - "StripByteCounts", - "RowsPerStrip", - "PageNumber", - "PhotometricInterpretation", - ] + # PhotometricInterpretation is set from SAVE_INFO, + # not the original image. + ignored = [ + "StripByteCounts", + "RowsPerStrip", + "PageNumber", + "PhotometricInterpretation", + ] - with Image.open(f) as loaded: - if legacy_api: - reloaded = loaded.tag.named() - else: - reloaded = loaded.tag_v2.named() + with Image.open(f) as loaded: + if legacy_api: + reloaded = loaded.tag.named() + else: + reloaded = loaded.tag_v2.named() - for tag, value in itertools.chain(reloaded.items(), original.items()): - if tag not in ignored: - val = original[tag] - if tag.endswith("Resolution"): - if legacy_api: - assert val[0][0] / val[0][1] == ( - 4294967295 / 113653537 - ), f"{tag} didn't roundtrip" - else: - assert val == 37.79000115940079, f"{tag} didn't roundtrip" + for tag, value in itertools.chain(reloaded.items(), original.items()): + if tag not in ignored: + val = original[tag] + if tag.endswith("Resolution"): + if legacy_api: + assert val[0][0] / val[0][1] == ( + 4294967295 / 113653537 + ), f"{tag} didn't roundtrip" else: - assert val == value, f"{tag} didn't roundtrip" + assert val == 37.79000115940079, f"{tag} didn't roundtrip" + else: + assert val == value, f"{tag} didn't roundtrip" - # https://github.com/python-pillow/Pillow/issues/1561 - requested_fields = ["StripByteCounts", "RowsPerStrip", "StripOffsets"] - for field in requested_fields: - assert field in reloaded, f"{field} not in metadata" + # https://github.com/python-pillow/Pillow/issues/1561 + requested_fields = ["StripByteCounts", "RowsPerStrip", "StripOffsets"] + for field in requested_fields: + assert field in reloaded, f"{field} not in metadata" @pytest.mark.valgrind_known_error(reason="Known invalid metadata") def test_additional_metadata(self, tmp_path): @@ -497,8 +497,8 @@ class TestFileLibTiff(LibTiffTestCase): im.save(out, compression="tiff_adobe_deflate") assert_image_equal_tofile(im, out) - def test_palette_save(self, tmp_path): - im = hopper("P") + @pytest.mark.parametrize("im", (hopper("P"), Image.new("P", (1, 1), "#000"))) + def test_palette_save(self, im, tmp_path): out = str(tmp_path / "temp.tif") TiffImagePlugin.WRITE_LIBTIFF = True @@ -856,7 +856,7 @@ class TestFileLibTiff(LibTiffTestCase): def test_strip_ycbcr_jpeg_2x2_sampling(self): infile = "Tests/images/tiff_strip_ycbcr_jpeg_2x2_sampling.tif" with Image.open(infile) as im: - assert_image_similar_tofile(im, "Tests/images/flower.jpg", 0.5) + assert_image_similar_tofile(im, "Tests/images/flower.jpg", 1.2) @mark_if_feature_version( pytest.mark.valgrind_known_error, "libjpeg_turbo", "2.0", reason="Known Failing" @@ -864,7 +864,7 @@ class TestFileLibTiff(LibTiffTestCase): def test_strip_ycbcr_jpeg_1x1_sampling(self): infile = "Tests/images/tiff_strip_ycbcr_jpeg_1x1_sampling.tif" with Image.open(infile) as im: - assert_image_equal_tofile(im, "Tests/images/flower2.jpg") + assert_image_similar_tofile(im, "Tests/images/flower2.jpg", 0.01) def test_tiled_cmyk_jpeg(self): infile = "Tests/images/tiff_tiled_cmyk_jpeg.tif" @@ -877,7 +877,7 @@ class TestFileLibTiff(LibTiffTestCase): def test_tiled_ycbcr_jpeg_1x1_sampling(self): infile = "Tests/images/tiff_tiled_ycbcr_jpeg_1x1_sampling.tif" with Image.open(infile) as im: - assert_image_equal_tofile(im, "Tests/images/flower2.jpg") + assert_image_similar_tofile(im, "Tests/images/flower2.jpg", 0.01) @mark_if_feature_version( pytest.mark.valgrind_known_error, "libjpeg_turbo", "2.0", reason="Known Failing" @@ -885,7 +885,7 @@ class TestFileLibTiff(LibTiffTestCase): def test_tiled_ycbcr_jpeg_2x2_sampling(self): infile = "Tests/images/tiff_tiled_ycbcr_jpeg_2x2_sampling.tif" with Image.open(infile) as im: - assert_image_similar_tofile(im, "Tests/images/flower.jpg", 0.5) + assert_image_similar_tofile(im, "Tests/images/flower.jpg", 1.5) def test_strip_planar_rgb(self): # gdal_translate -co TILED=no -co INTERLEAVE=BAND -co COMPRESS=LZW \ @@ -1011,14 +1011,18 @@ class TestFileLibTiff(LibTiffTestCase): # Assert that there are multiple strips assert len(im.tag_v2[STRIPOFFSETS]) > 1 - def test_save_single_strip(self, tmp_path): + @pytest.mark.parametrize("argument", (True, False)) + def test_save_single_strip(self, argument, tmp_path): im = hopper("RGB").resize((256, 256)) out = str(tmp_path / "temp.tif") - TiffImagePlugin.STRIP_SIZE = 2**18 + if not argument: + TiffImagePlugin.STRIP_SIZE = 2**18 try: - - im.save(out, compression="tiff_adobe_deflate") + arguments = {"compression": "tiff_adobe_deflate"} + if argument: + arguments["strip_size"] = 2**18 + im.save(out, **arguments) with Image.open(out) as im: assert len(im.tag_v2[STRIPOFFSETS]) == 1 diff --git a/Tests/test_file_mpo.py b/Tests/test_file_mpo.py index ca3ea8419..d94bdaa96 100644 --- a/Tests/test_file_mpo.py +++ b/Tests/test_file_mpo.py @@ -5,15 +5,19 @@ import pytest from PIL import Image -from .helper import assert_image_similar, is_pypy, skip_unless_feature +from .helper import ( + assert_image_equal, + assert_image_similar, + is_pypy, + skip_unless_feature, +) test_files = ["Tests/images/sugarshack.mpo", "Tests/images/frozenpond.mpo"] pytestmark = skip_unless_feature("jpg") -def frame_roundtrip(im, **options): - # Note that for now, there is no MPO saving functionality +def roundtrip(im, **options): out = BytesIO() im.save(out, "MPO", **options) test_bytes = out.tell() @@ -23,13 +27,13 @@ def frame_roundtrip(im, **options): return im -def test_sanity(): - for test_file in test_files: - with Image.open(test_file) as im: - im.load() - assert im.mode == "RGB" - assert im.size == (640, 480) - assert im.format == "MPO" +@pytest.mark.parametrize("test_file", test_files) +def test_sanity(test_file): + with Image.open(test_file) as im: + im.load() + assert im.mode == "RGB" + assert im.size == (640, 480) + assert im.format == "MPO" @pytest.mark.skipif(is_pypy(), reason="Requires CPython") @@ -48,32 +52,39 @@ def test_closed_file(): im.close() +def test_seek_after_close(): + im = Image.open(test_files[0]) + im.close() + + with pytest.raises(ValueError): + im.seek(1) + + def test_context_manager(): with warnings.catch_warnings(): with Image.open(test_files[0]) as im: im.load() -def test_app(): - for test_file in test_files: - # Test APP/COM reader (@PIL135) - with Image.open(test_file) as im: - assert im.applist[0][0] == "APP1" - assert im.applist[1][0] == "APP2" - assert ( - im.applist[1][1][:16] - == b"MPF\x00MM\x00*\x00\x00\x00\x08\x00\x03\xb0\x00" - ) - assert len(im.applist) == 2 +@pytest.mark.parametrize("test_file", test_files) +def test_app(test_file): + # Test APP/COM reader (@PIL135) + with Image.open(test_file) as im: + assert im.applist[0][0] == "APP1" + assert im.applist[1][0] == "APP2" + assert ( + im.applist[1][1][:16] == b"MPF\x00MM\x00*\x00\x00\x00\x08\x00\x03\xb0\x00" + ) + assert len(im.applist) == 2 -def test_exif(): - for test_file in test_files: - with Image.open(test_file) as im: - info = im._getexif() - assert info[272] == "Nintendo 3DS" - assert info[296] == 2 - assert info[34665] == 188 +@pytest.mark.parametrize("test_file", test_files) +def test_exif(test_file): + with Image.open(test_file) as im: + info = im._getexif() + assert info[272] == "Nintendo 3DS" + assert info[296] == 2 + assert info[34665] == 188 def test_frame_size(): @@ -116,12 +127,21 @@ def test_parallax(): assert exif.get_ifd(0x927C)[0xB211] == -3.125 -def test_mp(): - for test_file in test_files: - with Image.open(test_file) as im: - mpinfo = im._getmp() - assert mpinfo[45056] == b"0100" - assert mpinfo[45057] == 2 +def test_reload_exif_after_seek(): + with Image.open("Tests/images/sugarshack.mpo") as im: + exif = im.getexif() + del exif[296] + + im.seek(1) + assert 296 in exif + + +@pytest.mark.parametrize("test_file", test_files) +def test_mp(test_file): + with Image.open(test_file) as im: + mpinfo = im._getmp() + assert mpinfo[45056] == b"0100" + assert mpinfo[45057] == 2 def test_mp_offset(): @@ -141,48 +161,48 @@ def test_mp_no_data(): im.seek(1) -def test_mp_attribute(): - for test_file in test_files: - with Image.open(test_file) as im: - mpinfo = im._getmp() - frame_number = 0 - for mpentry in mpinfo[0xB002]: - mpattr = mpentry["Attribute"] - if frame_number: - assert not mpattr["RepresentativeImageFlag"] - else: - assert mpattr["RepresentativeImageFlag"] - assert not mpattr["DependentParentImageFlag"] - assert not mpattr["DependentChildImageFlag"] - assert mpattr["ImageDataFormat"] == "JPEG" - assert mpattr["MPType"] == "Multi-Frame Image: (Disparity)" - assert mpattr["Reserved"] == 0 - frame_number += 1 +@pytest.mark.parametrize("test_file", test_files) +def test_mp_attribute(test_file): + with Image.open(test_file) as im: + mpinfo = im._getmp() + frame_number = 0 + for mpentry in mpinfo[0xB002]: + mpattr = mpentry["Attribute"] + if frame_number: + assert not mpattr["RepresentativeImageFlag"] + else: + assert mpattr["RepresentativeImageFlag"] + assert not mpattr["DependentParentImageFlag"] + assert not mpattr["DependentChildImageFlag"] + assert mpattr["ImageDataFormat"] == "JPEG" + assert mpattr["MPType"] == "Multi-Frame Image: (Disparity)" + assert mpattr["Reserved"] == 0 + frame_number += 1 -def test_seek(): - for test_file in test_files: - with Image.open(test_file) as im: - assert im.tell() == 0 - # prior to first image raises an error, both blatant and borderline - with pytest.raises(EOFError): - im.seek(-1) - with pytest.raises(EOFError): - im.seek(-523) - # after the final image raises an error, - # both blatant and borderline - with pytest.raises(EOFError): - im.seek(2) - with pytest.raises(EOFError): - im.seek(523) - # bad calls shouldn't change the frame - assert im.tell() == 0 - # this one will work - im.seek(1) - assert im.tell() == 1 - # and this one, too - im.seek(0) - assert im.tell() == 0 +@pytest.mark.parametrize("test_file", test_files) +def test_seek(test_file): + with Image.open(test_file) as im: + assert im.tell() == 0 + # prior to first image raises an error, both blatant and borderline + with pytest.raises(EOFError): + im.seek(-1) + with pytest.raises(EOFError): + im.seek(-523) + # after the final image raises an error, + # both blatant and borderline + with pytest.raises(EOFError): + im.seek(2) + with pytest.raises(EOFError): + im.seek(523) + # bad calls shouldn't change the frame + assert im.tell() == 0 + # this one will work + im.seek(1) + assert im.tell() == 1 + # and this one, too + im.seek(0) + assert im.tell() == 0 def test_n_frames(): @@ -204,29 +224,54 @@ def test_eoferror(): im.seek(n_frames - 1) -def test_image_grab(): +@pytest.mark.parametrize("test_file", test_files) +def test_image_grab(test_file): + with Image.open(test_file) as im: + assert im.tell() == 0 + im0 = im.tobytes() + im.seek(1) + assert im.tell() == 1 + im1 = im.tobytes() + im.seek(0) + assert im.tell() == 0 + im02 = im.tobytes() + assert im0 == im02 + assert im0 != im1 + + +@pytest.mark.parametrize("test_file", test_files) +def test_save(test_file): + with Image.open(test_file) as im: + assert im.tell() == 0 + jpg0 = roundtrip(im) + assert_image_similar(im, jpg0, 30) + im.seek(1) + assert im.tell() == 1 + jpg1 = roundtrip(im) + assert_image_similar(im, jpg1, 30) + + +def test_save_all(): for test_file in test_files: with Image.open(test_file) as im: - assert im.tell() == 0 - im0 = im.tobytes() - im.seek(1) - assert im.tell() == 1 - im1 = im.tobytes() + im_reloaded = roundtrip(im, save_all=True) + im.seek(0) - assert im.tell() == 0 - im02 = im.tobytes() - assert im0 == im02 - assert im0 != im1 + assert_image_similar(im, im_reloaded, 30) - -def test_save(): - # Note that only individual frames can be saved at present - for test_file in test_files: - with Image.open(test_file) as im: - assert im.tell() == 0 - jpg0 = frame_roundtrip(im) - assert_image_similar(im, jpg0, 30) im.seek(1) - assert im.tell() == 1 - jpg1 = frame_roundtrip(im) - assert_image_similar(im, jpg1, 30) + im_reloaded.seek(1) + assert_image_similar(im, im_reloaded, 30) + + im = Image.new("RGB", (1, 1)) + im2 = Image.new("RGB", (1, 1), "#f00") + im_reloaded = roundtrip(im, save_all=True, append_images=[im2]) + + assert_image_equal(im, im_reloaded) + + im_reloaded.seek(1) + assert_image_similar(im2, im_reloaded, 1) + + # Test that a single frame image will not be saved as an MPO + jpg = roundtrip(im, save_all=True) + assert "mp" not in jpg.info diff --git a/Tests/test_file_pcx.py b/Tests/test_file_pcx.py index 61e33a57b..ba6663cd3 100644 --- a/Tests/test_file_pcx.py +++ b/Tests/test_file_pcx.py @@ -20,6 +20,11 @@ def test_sanity(tmp_path): for mode in ("1", "L", "P", "RGB"): _roundtrip(tmp_path, hopper(mode)) + # Test a palette with less than 256 colors + im = Image.new("P", (1, 1)) + im.putpalette((255, 0, 0)) + _roundtrip(tmp_path, im) + # Test an unsupported mode f = str(tmp_path / "temp.pcx") im = hopper("RGBA") diff --git a/Tests/test_file_pdf.py b/Tests/test_file_pdf.py index c71d4f5f2..df0b7abe6 100644 --- a/Tests/test_file_pdf.py +++ b/Tests/test_file_pdf.py @@ -37,13 +37,14 @@ def helper_save_as_pdf(tmp_path, mode, **kwargs): return outfile +@pytest.mark.valgrind_known_error(reason="Temporary skip") def test_monochrome(tmp_path): # Arrange mode = "1" # Act / Assert outfile = helper_save_as_pdf(tmp_path, mode) - assert os.path.getsize(outfile) < 15000 + assert os.path.getsize(outfile) < 5000 def test_greyscale(tmp_path): diff --git a/Tests/test_file_png.py b/Tests/test_file_png.py index 2a40ab7be..1af0223eb 100644 --- a/Tests/test_file_png.py +++ b/Tests/test_file_png.py @@ -635,7 +635,9 @@ class TestFilePng: assert_image_equal_tofile(im, "Tests/images/bw_gradient.png") - @pytest.mark.parametrize("cid", (b"IHDR", b"pHYs", b"acTL", b"fcTL", b"fdAT")) + @pytest.mark.parametrize( + "cid", (b"IHDR", b"sRGB", b"pHYs", b"acTL", b"fcTL", b"fdAT") + ) def test_truncated_chunks(self, cid): fp = BytesIO() with PngImagePlugin.PngStream(fp) as png: diff --git a/Tests/test_file_ppm.py b/Tests/test_file_ppm.py index af1b37b18..5c6376caf 100644 --- a/Tests/test_file_ppm.py +++ b/Tests/test_file_ppm.py @@ -3,7 +3,7 @@ from io import BytesIO import pytest -from PIL import Image, UnidentifiedImageError +from PIL import Image, PpmImagePlugin from .helper import assert_image_equal_tofile, assert_image_similar, hopper @@ -22,6 +22,21 @@ def test_sanity(): @pytest.mark.parametrize( "data, mode, pixels", ( + (b"P2 3 1 4 0 2 4", "L", (0, 128, 255)), + (b"P2 3 1 257 0 128 257", "I", (0, 32640, 65535)), + # P3 with maxval < 255 + ( + b"P3 3 1 17 0 1 2 8 9 10 15 16 17", + "RGB", + ((0, 15, 30), (120, 135, 150), (225, 240, 255)), + ), + # P3 with maxval > 255 + # Scale down to 255, since there is no RGB mode with more than 8-bit + ( + b"P3 3 1 257 0 1 2 128 129 130 256 257 257", + "RGB", + ((0, 1, 2), (127, 128, 129), (254, 255, 255)), + ), (b"P5 3 1 4 \x00\x02\x04", "L", (0, 128, 255)), (b"P5 3 1 257 \x00\x00\x00\x80\x01\x01", "I", (0, 32640, 65535)), # P6 with maxval < 255 @@ -35,7 +50,6 @@ def test_sanity(): ), ), # P6 with maxval > 255 - # Scale down to 255, since there is no RGB mode with more than 8-bit ( b"P6 3 1 257 \x00\x00\x00\x01\x00\x02" b"\x00\x80\x00\x81\x00\x82\x01\x00\x01\x01\xFF\xFF", @@ -85,14 +99,111 @@ def test_pnm(tmp_path): assert_image_equal_tofile(im, f) -def test_magic(tmp_path): +@pytest.mark.parametrize( + "plain_path, raw_path", + ( + ( + "Tests/images/hopper_1bit_plain.pbm", # P1 + "Tests/images/hopper_1bit.pbm", # P4 + ), + ( + "Tests/images/hopper_8bit_plain.pgm", # P2 + "Tests/images/hopper_8bit.pgm", # P5 + ), + ( + "Tests/images/hopper_8bit_plain.ppm", # P3 + "Tests/images/hopper_8bit.ppm", # P6 + ), + ), +) +def test_plain(plain_path, raw_path): + with Image.open(plain_path) as im: + assert_image_equal_tofile(im, raw_path) + + +def test_16bit_plain_pgm(): + # P2 with maxval 2 ** 16 - 1 + with Image.open("Tests/images/hopper_16bit_plain.pgm") as im: + assert im.mode == "I" + assert im.size == (128, 128) + assert im.get_format_mimetype() == "image/x-portable-graymap" + + # P5 with maxval 2 ** 16 - 1 + assert_image_equal_tofile(im, "Tests/images/hopper_16bit.pgm") + + +@pytest.mark.parametrize( + "header, data, comment_count", + ( + (b"P1\n2 2", b"1010", 10**6), + (b"P2\n3 1\n4", b"0 2 4", 1), + (b"P3\n2 2\n255", b"0 0 0 001 1 1 2 2 2 255 255 255", 10**6), + ), +) +def test_plain_data_with_comment(tmp_path, header, data, comment_count): + path1 = str(tmp_path / "temp1.ppm") + path2 = str(tmp_path / "temp2.ppm") + comment = b"# comment" * comment_count + with open(path1, "wb") as f1, open(path2, "wb") as f2: + f1.write(header + b"\n\n" + data) + f2.write(header + b"\n" + comment + b"\n" + data + comment) + + with Image.open(path1) as im: + assert_image_equal_tofile(im, path2) + + +@pytest.mark.parametrize("data", (b"P1\n128 128\n", b"P3\n128 128\n255\n")) +def test_plain_truncated_data(tmp_path, data): path = str(tmp_path / "temp.ppm") with open(path, "wb") as f: - f.write(b"PyInvalid") + f.write(data) - with pytest.raises(UnidentifiedImageError): - with Image.open(path): - pass + with Image.open(path) as im: + with pytest.raises(ValueError): + im.load() + + +@pytest.mark.parametrize("data", (b"P1\n128 128\n1009", b"P3\n128 128\n255\n100A")) +def test_plain_invalid_data(tmp_path, data): + path = str(tmp_path / "temp.ppm") + with open(path, "wb") as f: + f.write(data) + + with Image.open(path) as im: + with pytest.raises(ValueError): + im.load() + + +@pytest.mark.parametrize( + "data", + ( + b"P3\n128 128\n255\n012345678910", # half token too long + b"P3\n128 128\n255\n012345678910 0", # token too long + ), +) +def test_plain_ppm_token_too_long(tmp_path, data): + path = str(tmp_path / "temp.ppm") + with open(path, "wb") as f: + f.write(data) + + with Image.open(path) as im: + with pytest.raises(ValueError): + im.load() + + +def test_plain_ppm_value_too_large(tmp_path): + path = str(tmp_path / "temp.ppm") + with open(path, "wb") as f: + f.write(b"P3\n128 128\n255\n256") + + with Image.open(path) as im: + with pytest.raises(ValueError): + im.load() + + +def test_magic(): + with pytest.raises(SyntaxError): + PpmImagePlugin.PpmImageFile(fp=BytesIO(b"PyInvalid")) def test_header_with_comments(tmp_path): @@ -114,7 +225,7 @@ def test_non_integer_token(tmp_path): pass -def test_token_too_long(tmp_path): +def test_header_token_too_long(tmp_path): path = str(tmp_path / "temp.ppm") with open(path, "wb") as f: f.write(b"P6\n 01234567890") diff --git a/Tests/test_file_psd.py b/Tests/test_file_psd.py index b4b5b7a0c..4f934375c 100644 --- a/Tests/test_file_psd.py +++ b/Tests/test_file_psd.py @@ -4,7 +4,7 @@ import pytest from PIL import Image, PsdImagePlugin -from .helper import assert_image_similar, hopper, is_pypy +from .helper import assert_image_equal_tofile, assert_image_similar, hopper, is_pypy test_file = "Tests/images/hopper.psd" @@ -107,6 +107,11 @@ def test_open_after_exclusive_load(): im.load() +def test_rgba(): + with Image.open("Tests/images/rgba.psd") as im: + assert_image_equal_tofile(im, "Tests/images/imagedraw_square.png") + + def test_icc_profile(): with Image.open(test_file) as im: assert "icc_profile" in im.info diff --git a/Tests/test_file_tga.py b/Tests/test_file_tga.py index aeea3fb42..cbbb7df1d 100644 --- a/Tests/test_file_tga.py +++ b/Tests/test_file_tga.py @@ -18,51 +18,48 @@ _ORIGINS = ("tl", "bl") _ORIGIN_TO_ORIENTATION = {"tl": 1, "bl": -1} -def test_sanity(tmp_path): - for mode in _MODES: +@pytest.mark.parametrize("mode", _MODES) +def test_sanity(mode, tmp_path): + def roundtrip(original_im): + out = str(tmp_path / "temp.tga") - def roundtrip(original_im): - out = str(tmp_path / "temp.tga") + original_im.save(out, rle=rle) + with Image.open(out) as saved_im: + if rle: + assert saved_im.info["compression"] == original_im.info["compression"] + assert saved_im.info["orientation"] == original_im.info["orientation"] + if mode == "P": + assert saved_im.getpalette() == original_im.getpalette() - original_im.save(out, rle=rle) - with Image.open(out) as saved_im: - if rle: + assert_image_equal(saved_im, original_im) + + png_paths = glob(os.path.join(_TGA_DIR_COMMON, f"*x*_{mode.lower()}.png")) + + for png_path in png_paths: + with Image.open(png_path) as reference_im: + assert reference_im.mode == mode + + path_no_ext = os.path.splitext(png_path)[0] + for origin, rle in product(_ORIGINS, (True, False)): + tga_path = "{}_{}_{}.tga".format( + path_no_ext, origin, "rle" if rle else "raw" + ) + + with Image.open(tga_path) as original_im: + assert original_im.format == "TGA" + assert original_im.get_format_mimetype() == "image/x-tga" + if rle: + assert original_im.info["compression"] == "tga_rle" assert ( - saved_im.info["compression"] == original_im.info["compression"] + original_im.info["orientation"] + == _ORIGIN_TO_ORIENTATION[origin] ) - assert saved_im.info["orientation"] == original_im.info["orientation"] - if mode == "P": - assert saved_im.getpalette() == original_im.getpalette() + if mode == "P": + assert original_im.getpalette() == reference_im.getpalette() - assert_image_equal(saved_im, original_im) + assert_image_equal(original_im, reference_im) - png_paths = glob(os.path.join(_TGA_DIR_COMMON, f"*x*_{mode.lower()}.png")) - - for png_path in png_paths: - with Image.open(png_path) as reference_im: - assert reference_im.mode == mode - - path_no_ext = os.path.splitext(png_path)[0] - for origin, rle in product(_ORIGINS, (True, False)): - tga_path = "{}_{}_{}.tga".format( - path_no_ext, origin, "rle" if rle else "raw" - ) - - with Image.open(tga_path) as original_im: - assert original_im.format == "TGA" - assert original_im.get_format_mimetype() == "image/x-tga" - if rle: - assert original_im.info["compression"] == "tga_rle" - assert ( - original_im.info["orientation"] - == _ORIGIN_TO_ORIENTATION[origin] - ) - if mode == "P": - assert original_im.getpalette() == reference_im.getpalette() - - assert_image_equal(original_im, reference_im) - - roundtrip(original_im) + roundtrip(original_im) def test_palette_depth_16(tmp_path): @@ -101,6 +98,10 @@ def test_cross_scan_line(): with Image.open("Tests/images/cross_scan_line.tga") as im: assert_image_equal_tofile(im, "Tests/images/cross_scan_line.png") + with Image.open("Tests/images/cross_scan_line_truncated.tga") as im: + with pytest.raises(OSError): + im.load() + def test_save(tmp_path): test_file = "Tests/images/tga_id_field.tga" diff --git a/Tests/test_file_tiff.py b/Tests/test_file_tiff.py index 87e0c2d25..8706cb950 100644 --- a/Tests/test_file_tiff.py +++ b/Tests/test_file_tiff.py @@ -70,6 +70,15 @@ class TestFileTiff: im.load() im.close() + def test_seek_after_close(self): + im = Image.open("Tests/images/multipage.tiff") + im.close() + + with pytest.raises(ValueError): + im.n_frames + with pytest.raises(ValueError): + im.seek(1) + def test_context_manager(self): with warnings.catch_warnings(): with Image.open("Tests/images/multipage.tiff") as im: @@ -488,6 +497,26 @@ class TestFileTiff: exif = im.getexif() check_exif(exif) + def test_modify_exif(self, tmp_path): + outfile = str(tmp_path / "temp.tif") + with Image.open("Tests/images/ifd_tag_type.tiff") as im: + exif = im.getexif() + exif[256] = 100 + + im.save(outfile, exif=exif) + + with Image.open(outfile) as im: + exif = im.getexif() + assert exif[256] == 100 + + def test_reload_exif_after_seek(self): + with Image.open("Tests/images/multipage.tiff") as im: + exif = im.getexif() + del exif[256] + im.seek(1) + + assert 256 in exif + def test_exif_frames(self): # Test that EXIF data can change across frames with Image.open("Tests/images/g4-multi.tiff") as im: @@ -706,6 +735,13 @@ class TestFileTiff: with Image.open(outfile) as reloaded: assert reloaded.info["icc_profile"] == icc_profile + def test_save_bmp_compression(self, tmp_path): + with Image.open("Tests/images/hopper.bmp") as im: + assert im.info["compression"] == 0 + + outfile = str(tmp_path / "temp.tif") + im.save(outfile) + def test_discard_icc_profile(self, tmp_path): outfile = str(tmp_path / "temp.tif") diff --git a/Tests/test_file_wmf.py b/Tests/test_file_wmf.py index d6769a24b..439cb15bc 100644 --- a/Tests/test_file_wmf.py +++ b/Tests/test_file_wmf.py @@ -66,10 +66,10 @@ def test_load_set_dpi(): assert_image_similar_tofile(im, "Tests/images/drawing_wmf_ref_144.png", 2.1) -def test_save(tmp_path): +@pytest.mark.parametrize("ext", (".wmf", ".emf")) +def test_save(ext, tmp_path): im = hopper() - for ext in [".wmf", ".emf"]: - tmpfile = str(tmp_path / ("temp" + ext)) - with pytest.raises(OSError): - im.save(tmpfile) + tmpfile = str(tmp_path / ("temp" + ext)) + with pytest.raises(OSError): + im.save(tmpfile) diff --git a/Tests/test_font_pcf.py b/Tests/test_font_pcf.py index 288848f26..c217378fb 100644 --- a/Tests/test_font_pcf.py +++ b/Tests/test_font_pcf.py @@ -49,6 +49,14 @@ def test_sanity(request, tmp_path): save_font(request, tmp_path) +def test_less_than_256_characters(): + with open("Tests/fonts/10x20-ISO8859-1-fewer-characters.pcf", "rb") as test_file: + font = PcfFontFile.PcfFontFile(test_file) + assert isinstance(font, FontFile.FontFile) + # check the number of characters in the font + assert len([_f for _f in font.glyph if _f]) == 127 + + def test_invalid_file(): with open("Tests/images/flower.jpg", "rb") as fp: with pytest.raises(SyntaxError): @@ -68,12 +76,19 @@ def test_textsize(request, tmp_path): tempname = save_font(request, tmp_path) font = ImageFont.load(tempname) for i in range(255): - (dx, dy) = font.getsize(chr(i)) + (ox, oy, dx, dy) = font.getbbox(chr(i)) + assert ox == 0 + assert oy == 0 assert dy == 20 assert dx in (0, 10) + assert font.getlength(chr(i)) == dx + with pytest.warns(DeprecationWarning) as log: + assert font.getsize(chr(i)) == (dx, dy) + assert len(log) == 1 for i in range(len(message)): msg = message[: i + 1] - assert font.getsize(msg) == (len(msg) * 10, 20) + assert font.getlength(msg) == len(msg) * 10 + assert font.getbbox(msg) == (0, 0, len(msg) * 10, 20) def _test_high_characters(request, tmp_path, message): diff --git a/Tests/test_font_pcf_charsets.py b/Tests/test_font_pcf_charsets.py index a1036fd28..4477ee29d 100644 --- a/Tests/test_font_pcf_charsets.py +++ b/Tests/test_font_pcf_charsets.py @@ -101,13 +101,17 @@ def _test_textsize(request, tmp_path, encoding): tempname = save_font(request, tmp_path, encoding) font = ImageFont.load(tempname) for i in range(255): - (dx, dy) = font.getsize(bytearray([i])) + (ox, oy, dx, dy) = font.getbbox(bytearray([i])) + assert ox == 0 + assert oy == 0 assert dy == 20 assert dx in (0, 10) + assert font.getlength(bytearray([i])) == dx message = charsets[encoding]["message"].encode(encoding) for i in range(len(message)): msg = message[: i + 1] - assert font.getsize(msg) == (len(msg) * 10, 20) + assert font.getlength(msg) == len(msg) * 10 + assert font.getbbox(msg) == (0, 0, len(msg) * 10, 20) def test_textsize_iso8859_1(request, tmp_path): diff --git a/Tests/test_image.py b/Tests/test_image.py index 5544ae43c..7cebed127 100644 --- a/Tests/test_image.py +++ b/Tests/test_image.py @@ -22,8 +22,9 @@ from .helper import ( class TestImage: - def test_image_modes_success(self): - for mode in [ + @pytest.mark.parametrize( + "mode", + ( "1", "P", "PA", @@ -44,22 +45,18 @@ class TestImage: "YCbCr", "LAB", "HSV", - ]: - Image.new(mode, (1, 1)) + ), + ) + def test_image_modes_success(self, mode): + Image.new(mode, (1, 1)) - def test_image_modes_fail(self): - for mode in [ - "", - "bad", - "very very long", - "BGR;15", - "BGR;16", - "BGR;24", - "BGR;32", - ]: - with pytest.raises(ValueError) as e: - Image.new(mode, (1, 1)) - assert str(e.value) == "unrecognized image mode" + @pytest.mark.parametrize( + "mode", ("", "bad", "very very long", "BGR;15", "BGR;16", "BGR;24", "BGR;32") + ) + def test_image_modes_fail(self, mode): + with pytest.raises(ValueError) as e: + Image.new(mode, (1, 1)) + assert str(e.value) == "unrecognized image mode" def test_exception_inheritance(self): assert issubclass(UnidentifiedImageError, OSError) @@ -539,23 +536,22 @@ class TestImage: with pytest.raises(ValueError): Image.linear_gradient(wrong_mode) - def test_linear_gradient(self): - + @pytest.mark.parametrize("mode", ("L", "P", "I", "F")) + def test_linear_gradient(self, mode): # Arrange target_file = "Tests/images/linear_gradient.png" - for mode in ["L", "P", "I", "F"]: - # Act - im = Image.linear_gradient(mode) + # Act + im = Image.linear_gradient(mode) - # Assert - assert im.size == (256, 256) - assert im.mode == mode - assert im.getpixel((0, 0)) == 0 - assert im.getpixel((255, 255)) == 255 - with Image.open(target_file) as target: - target = target.convert(mode) - assert_image_equal(im, target) + # Assert + assert im.size == (256, 256) + assert im.mode == mode + assert im.getpixel((0, 0)) == 0 + assert im.getpixel((255, 255)) == 255 + with Image.open(target_file) as target: + target = target.convert(mode) + assert_image_equal(im, target) def test_radial_gradient_wrong_mode(self): # Arrange @@ -565,23 +561,22 @@ class TestImage: with pytest.raises(ValueError): Image.radial_gradient(wrong_mode) - def test_radial_gradient(self): - + @pytest.mark.parametrize("mode", ("L", "P", "I", "F")) + def test_radial_gradient(self, mode): # Arrange target_file = "Tests/images/radial_gradient.png" - for mode in ["L", "P", "I", "F"]: - # Act - im = Image.radial_gradient(mode) + # Act + im = Image.radial_gradient(mode) - # Assert - assert im.size == (256, 256) - assert im.mode == mode - assert im.getpixel((0, 0)) == 255 - assert im.getpixel((128, 128)) == 0 - with Image.open(target_file) as target: - target = target.convert(mode) - assert_image_equal(im, target) + # Assert + assert im.size == (256, 256) + assert im.mode == mode + assert im.getpixel((0, 0)) == 255 + assert im.getpixel((128, 128)) == 0 + with Image.open(target_file) as target: + target = target.convert(mode) + assert_image_equal(im, target) def test_register_extensions(self): test_format = "a" @@ -604,11 +599,34 @@ class TestImage: with Image.open("Tests/images/hopper.gif") as im: assert_image_equal(im, im.remap_palette(list(range(256)))) + # Test identity transform with an RGBA palette + im = Image.new("P", (256, 1)) + for x in range(256): + im.putpixel((x, 0), x) + im.putpalette(list(range(256)) * 4, "RGBA") + im_remapped = im.remap_palette(list(range(256))) + assert_image_equal(im, im_remapped) + assert im.palette.palette == im_remapped.palette.palette + # Test illegal image mode with hopper() as im: with pytest.raises(ValueError): im.remap_palette(None) + def test_remap_palette_transparency(self): + im = Image.new("P", (1, 2)) + im.putpixel((0, 1), 1) + im.info["transparency"] = 0 + + im_remapped = im.remap_palette([1, 0]) + assert im_remapped.info["transparency"] == 1 + + # Test unused transparency + im.info["transparency"] = 2 + + im_remapped = im.remap_palette([1, 0]) + assert "transparency" not in im_remapped.info + def test__new(self): im = hopper("RGB") im_p = hopper("P") @@ -826,6 +844,35 @@ class TestImage: im = Image.new("RGB", size) assert im.tobytes() == b"" + def test_apply_transparency(self): + im = Image.new("P", (1, 1)) + im.putpalette((0, 0, 0, 1, 1, 1)) + assert im.palette.colors == {(0, 0, 0): 0, (1, 1, 1): 1} + + # Test that no transformation is applied without transparency + im.apply_transparency() + assert im.palette.colors == {(0, 0, 0): 0, (1, 1, 1): 1} + + # Test that a transparency index is applied + im.info["transparency"] = 0 + im.apply_transparency() + assert "transparency" not in im.info + assert im.palette.colors == {(0, 0, 0, 0): 0, (1, 1, 1, 255): 1} + + # Test that existing transparency is kept + im = Image.new("P", (1, 1)) + im.putpalette((0, 0, 0, 255, 1, 1, 1, 128), "RGBA") + im.info["transparency"] = 0 + im.apply_transparency() + assert im.palette.colors == {(0, 0, 0, 0): 0, (1, 1, 1, 128): 1} + + # Test that transparency bytes are applied + with Image.open("Tests/images/pil123p.png") as im: + assert isinstance(im.info["transparency"], bytes) + assert im.palette.colors[(27, 35, 6)] == 24 + im.apply_transparency() + assert im.palette.colors[(27, 35, 6, 214)] == 24 + def test_categories_deprecation(self): with pytest.warns(DeprecationWarning): assert hopper().category == 0 diff --git a/Tests/test_image_access.py b/Tests/test_image_access.py index 617274a57..bb75eb0b5 100644 --- a/Tests/test_image_access.py +++ b/Tests/test_image_access.py @@ -184,8 +184,9 @@ class TestImageGetPixel(AccessTest): with pytest.raises(error): im.getpixel((-1, -1)) - def test_basic(self): - for mode in ( + @pytest.mark.parametrize( + "mode", + ( "1", "L", "LA", @@ -200,23 +201,25 @@ class TestImageGetPixel(AccessTest): "RGBX", "CMYK", "YCbCr", - ): - self.check(mode) + ), + ) + def test_basic(self, mode): + self.check(mode) - def test_signedness(self): + @pytest.mark.parametrize("mode", ("I;16", "I;16B")) + def test_signedness(self, mode): # see https://github.com/python-pillow/Pillow/issues/452 # pixelaccess is using signed int* instead of uint* - for mode in ("I;16", "I;16B"): - self.check(mode, 2**15 - 1) - self.check(mode, 2**15) - self.check(mode, 2**15 + 1) - self.check(mode, 2**16 - 1) + self.check(mode, 2**15 - 1) + self.check(mode, 2**15) + self.check(mode, 2**15 + 1) + self.check(mode, 2**16 - 1) - def test_p_putpixel_rgb_rgba(self): - for color in [(255, 0, 0), (255, 0, 0, 255)]: - im = Image.new("P", (1, 1), 0) - im.putpixel((0, 0), color) - assert im.convert("RGB").getpixel((0, 0)) == (255, 0, 0) + @pytest.mark.parametrize("color", ((255, 0, 0), (255, 0, 0, 255))) + def test_p_putpixel_rgb_rgba(self, color): + im = Image.new("P", (1, 1), 0) + im.putpixel((0, 0), color) + assert im.convert("RGB").getpixel((0, 0)) == (255, 0, 0) @pytest.mark.skipif(cffi is None, reason="No CFFI") diff --git a/Tests/test_image_array.py b/Tests/test_image_array.py index 5c9cdd7e0..7e5fd6fe1 100644 --- a/Tests/test_image_array.py +++ b/Tests/test_image_array.py @@ -1,4 +1,5 @@ import pytest +from packaging.version import parse as parse_version from PIL import Image @@ -34,9 +35,10 @@ def test_toarray(): test_with_dtype(numpy.float64) test_with_dtype(numpy.uint8) - with Image.open("Tests/images/truncated_jpeg.jpg") as im_truncated: - with pytest.raises(OSError): - numpy.array(im_truncated) + if parse_version(numpy.__version__) >= parse_version("1.23"): + with Image.open("Tests/images/truncated_jpeg.jpg") as im_truncated: + with pytest.raises(OSError): + numpy.array(im_truncated) def test_fromarray(): @@ -80,3 +82,15 @@ def test_fromarray(): with pytest.raises(TypeError): wrapped = Wrapper(test("L"), {"shape": (100, 128)}) Image.fromarray(wrapped) + + +def test_fromarray_palette(): + # Arrange + i = im.convert("L") + a = numpy.array(i) + + # Act + out = Image.fromarray(a, "P") + + # Assert that the Python and C palettes match + assert len(out.palette.colors) == len(out.im.getpalette()) / 3 diff --git a/Tests/test_image_convert.py b/Tests/test_image_convert.py index 96587e4e2..8f4b8b43c 100644 --- a/Tests/test_image_convert.py +++ b/Tests/test_image_convert.py @@ -222,6 +222,20 @@ def test_p_la(): assert_image_similar(alpha, comparable, 5) +def test_p2pa_alpha(): + with Image.open("Tests/images/tiny.png") as im: + assert im.mode == "P" + + im_pa = im.convert("PA") + assert im_pa.mode == "PA" + + im_a = im_pa.getchannel("A") + for x in range(4): + alpha = 255 if x > 1 else 0 + for y in range(4): + assert im_a.getpixel((x, y)) == alpha + + def test_matrix_illegal_conversion(): # Arrange im = hopper("CMYK") @@ -254,36 +268,33 @@ def test_matrix_wrong_mode(): im.convert(mode="L", matrix=matrix) -def test_matrix_xyz(): - def matrix_convert(mode): - # Arrange - im = hopper("RGB") - im.info["transparency"] = (255, 0, 0) - # fmt: off - matrix = ( - 0.412453, 0.357580, 0.180423, 0, - 0.212671, 0.715160, 0.072169, 0, - 0.019334, 0.119193, 0.950227, 0) - # fmt: on - assert im.mode == "RGB" +@pytest.mark.parametrize("mode", ("RGB", "L")) +def test_matrix_xyz(mode): + # Arrange + im = hopper("RGB") + im.info["transparency"] = (255, 0, 0) + # fmt: off + matrix = ( + 0.412453, 0.357580, 0.180423, 0, + 0.212671, 0.715160, 0.072169, 0, + 0.019334, 0.119193, 0.950227, 0) + # fmt: on + assert im.mode == "RGB" - # Act - # Convert an RGB image to the CIE XYZ colour space - converted_im = im.convert(mode=mode, matrix=matrix) + # Act + # Convert an RGB image to the CIE XYZ colour space + converted_im = im.convert(mode=mode, matrix=matrix) - # Assert - assert converted_im.mode == mode - assert converted_im.size == im.size - with Image.open("Tests/images/hopper-XYZ.png") as target: - if converted_im.mode == "RGB": - assert_image_similar(converted_im, target, 3) - assert converted_im.info["transparency"] == (105, 54, 4) - else: - assert_image_similar(converted_im, target.getchannel(0), 1) - assert converted_im.info["transparency"] == 105 - - matrix_convert("RGB") - matrix_convert("L") + # Assert + assert converted_im.mode == mode + assert converted_im.size == im.size + with Image.open("Tests/images/hopper-XYZ.png") as target: + if converted_im.mode == "RGB": + assert_image_similar(converted_im, target, 3) + assert converted_im.info["transparency"] == (105, 54, 4) + else: + assert_image_similar(converted_im, target.getchannel(0), 1) + assert converted_im.info["transparency"] == 105 def test_matrix_identity(): diff --git a/Tests/test_image_copy.py b/Tests/test_image_copy.py index 21e438654..591832147 100644 --- a/Tests/test_image_copy.py +++ b/Tests/test_image_copy.py @@ -1,37 +1,40 @@ import copy +import pytest + from PIL import Image from .helper import hopper -def test_copy(): +@pytest.mark.parametrize("mode", ("1", "P", "L", "RGB", "I", "F")) +def test_copy(mode): cropped_coordinates = (10, 10, 20, 20) cropped_size = (10, 10) - for mode in "1", "P", "L", "RGB", "I", "F": - # Internal copy method - im = hopper(mode) - out = im.copy() - assert out.mode == im.mode - assert out.size == im.size - # Python's copy method - im = hopper(mode) - out = copy.copy(im) - assert out.mode == im.mode - assert out.size == im.size + # Internal copy method + im = hopper(mode) + out = im.copy() + assert out.mode == im.mode + assert out.size == im.size - # Internal copy method on a cropped image - im = hopper(mode) - out = im.crop(cropped_coordinates).copy() - assert out.mode == im.mode - assert out.size == cropped_size + # Python's copy method + im = hopper(mode) + out = copy.copy(im) + assert out.mode == im.mode + assert out.size == im.size - # Python's copy method on a cropped image - im = hopper(mode) - out = copy.copy(im.crop(cropped_coordinates)) - assert out.mode == im.mode - assert out.size == cropped_size + # Internal copy method on a cropped image + im = hopper(mode) + out = im.crop(cropped_coordinates).copy() + assert out.mode == im.mode + assert out.size == cropped_size + + # Python's copy method on a cropped image + im = hopper(mode) + out = copy.copy(im.crop(cropped_coordinates)) + assert out.mode == im.mode + assert out.size == cropped_size def test_copy_zero(): diff --git a/Tests/test_image_crop.py b/Tests/test_image_crop.py index 6574e6efd..4aa41de27 100644 --- a/Tests/test_image_crop.py +++ b/Tests/test_image_crop.py @@ -5,17 +5,14 @@ from PIL import Image from .helper import assert_image_equal, hopper -def test_crop(): - def crop(mode): - im = hopper(mode) - assert_image_equal(im.crop(), im) +@pytest.mark.parametrize("mode", ("1", "P", "L", "RGB", "I", "F")) +def test_crop(mode): + im = hopper(mode) + assert_image_equal(im.crop(), im) - cropped = im.crop((50, 50, 100, 100)) - assert cropped.mode == mode - assert cropped.size == (50, 50) - - for mode in "1", "P", "L", "RGB", "I", "F": - crop(mode) + cropped = im.crop((50, 50, 100, 100)) + assert cropped.mode == mode + assert cropped.size == (50, 50) def test_wide_crop(): diff --git a/Tests/test_image_entropy.py b/Tests/test_image_entropy.py index 876d676fe..ea5886e72 100644 --- a/Tests/test_image_entropy.py +++ b/Tests/test_image_entropy.py @@ -9,7 +9,7 @@ def test_entropy(): assert round(abs(entropy("L") - 7.063008716585465), 7) == 0 assert round(abs(entropy("I") - 7.063008716585465), 7) == 0 assert round(abs(entropy("F") - 7.063008716585465), 7) == 0 - assert round(abs(entropy("P") - 5.0530452472519745), 7) == 0 + assert round(abs(entropy("P") - 5.082506854662517), 7) == 0 assert round(abs(entropy("RGB") - 8.821286587714319), 7) == 0 assert round(abs(entropy("RGBA") - 7.42724306524488), 7) == 0 assert round(abs(entropy("CMYK") - 7.4272430652448795), 7) == 0 diff --git a/Tests/test_image_getcolors.py b/Tests/test_image_getcolors.py index e5b6a7724..7fd0398f9 100644 --- a/Tests/test_image_getcolors.py +++ b/Tests/test_image_getcolors.py @@ -16,7 +16,7 @@ def test_getcolors(): assert getcolors("L") == 255 assert getcolors("I") == 255 assert getcolors("F") == 255 - assert getcolors("P") == 90 # fixed palette + assert getcolors("P") == 96 # fixed palette assert getcolors("RGB") is None assert getcolors("RGBA") is None assert getcolors("CMYK") is None diff --git a/Tests/test_image_histogram.py b/Tests/test_image_histogram.py index 91e02973d..0ee52e724 100644 --- a/Tests/test_image_histogram.py +++ b/Tests/test_image_histogram.py @@ -10,7 +10,7 @@ def test_histogram(): assert histogram("L") == (256, 0, 662) assert histogram("I") == (256, 0, 662) assert histogram("F") == (256, 0, 662) - assert histogram("P") == (256, 0, 1871) + assert histogram("P") == (256, 0, 1551) assert histogram("RGB") == (768, 4, 675) assert histogram("RGBA") == (1024, 0, 16384) assert histogram("CMYK") == (1024, 0, 16384) diff --git a/Tests/test_image_paste.py b/Tests/test_image_paste.py index 4ea1d73ce..1ab02017d 100644 --- a/Tests/test_image_paste.py +++ b/Tests/test_image_paste.py @@ -1,3 +1,5 @@ +import pytest + from PIL import Image from .helper import CachedProperty, assert_image_equal @@ -101,226 +103,226 @@ class TestImagingPaste: ], ) - def test_image_solid(self): - for mode in ("RGBA", "RGB", "L"): - im = Image.new(mode, (200, 200), "red") - im2 = getattr(self, "gradient_" + mode) + @pytest.mark.parametrize("mode", ["RGBA", "RGB", "L"]) + def test_image_solid(self, mode): + im = Image.new(mode, (200, 200), "red") + im2 = getattr(self, "gradient_" + mode) - im.paste(im2, (12, 23)) + im.paste(im2, (12, 23)) - im = im.crop((12, 23, im2.width + 12, im2.height + 23)) - assert_image_equal(im, im2) + im = im.crop((12, 23, im2.width + 12, im2.height + 23)) + assert_image_equal(im, im2) - def test_image_mask_1(self): - for mode in ("RGBA", "RGB", "L"): - im = Image.new(mode, (200, 200), "white") - im2 = getattr(self, "gradient_" + mode) + @pytest.mark.parametrize("mode", ["RGBA", "RGB", "L"]) + def test_image_mask_1(self, mode): + im = Image.new(mode, (200, 200), "white") + im2 = getattr(self, "gradient_" + mode) - self.assert_9points_paste( - im, - im2, - self.mask_1, - [ - (255, 255, 255, 255), - (255, 255, 255, 255), - (127, 254, 127, 0), - (255, 255, 255, 255), - (255, 255, 255, 255), - (191, 190, 63, 64), - (127, 0, 127, 254), - (191, 64, 63, 190), - (255, 255, 255, 255), - ], - ) + self.assert_9points_paste( + im, + im2, + self.mask_1, + [ + (255, 255, 255, 255), + (255, 255, 255, 255), + (127, 254, 127, 0), + (255, 255, 255, 255), + (255, 255, 255, 255), + (191, 190, 63, 64), + (127, 0, 127, 254), + (191, 64, 63, 190), + (255, 255, 255, 255), + ], + ) - def test_image_mask_L(self): - for mode in ("RGBA", "RGB", "L"): - im = Image.new(mode, (200, 200), "white") - im2 = getattr(self, "gradient_" + mode) + @pytest.mark.parametrize("mode", ["RGBA", "RGB", "L"]) + def test_image_mask_L(self, mode): + im = Image.new(mode, (200, 200), "white") + im2 = getattr(self, "gradient_" + mode) - self.assert_9points_paste( - im, - im2, - self.mask_L, - [ - (128, 191, 255, 191), - (208, 239, 239, 208), - (255, 255, 255, 255), - (112, 111, 206, 207), - (192, 191, 191, 191), - (239, 239, 207, 207), - (128, 1, 128, 254), - (207, 113, 112, 207), - (255, 191, 128, 191), - ], - ) + self.assert_9points_paste( + im, + im2, + self.mask_L, + [ + (128, 191, 255, 191), + (208, 239, 239, 208), + (255, 255, 255, 255), + (112, 111, 206, 207), + (192, 191, 191, 191), + (239, 239, 207, 207), + (128, 1, 128, 254), + (207, 113, 112, 207), + (255, 191, 128, 191), + ], + ) - def test_image_mask_LA(self): - for mode in ("RGBA", "RGB", "L"): - im = Image.new(mode, (200, 200), "white") - im2 = getattr(self, "gradient_" + mode) + @pytest.mark.parametrize("mode", ["RGBA", "RGB", "L"]) + def test_image_mask_LA(self, mode): + im = Image.new(mode, (200, 200), "white") + im2 = getattr(self, "gradient_" + mode) - self.assert_9points_paste( - im, - im2, - self.gradient_LA, - [ - (128, 191, 255, 191), - (112, 207, 206, 111), - (128, 254, 128, 1), - (208, 208, 239, 239), - (192, 191, 191, 191), - (207, 207, 112, 113), - (255, 255, 255, 255), - (239, 207, 207, 239), - (255, 191, 128, 191), - ], - ) + self.assert_9points_paste( + im, + im2, + self.gradient_LA, + [ + (128, 191, 255, 191), + (112, 207, 206, 111), + (128, 254, 128, 1), + (208, 208, 239, 239), + (192, 191, 191, 191), + (207, 207, 112, 113), + (255, 255, 255, 255), + (239, 207, 207, 239), + (255, 191, 128, 191), + ], + ) - def test_image_mask_RGBA(self): - for mode in ("RGBA", "RGB", "L"): - im = Image.new(mode, (200, 200), "white") - im2 = getattr(self, "gradient_" + mode) + @pytest.mark.parametrize("mode", ["RGBA", "RGB", "L"]) + def test_image_mask_RGBA(self, mode): + im = Image.new(mode, (200, 200), "white") + im2 = getattr(self, "gradient_" + mode) - self.assert_9points_paste( - im, - im2, - self.gradient_RGBA, - [ - (128, 191, 255, 191), - (208, 239, 239, 208), - (255, 255, 255, 255), - (112, 111, 206, 207), - (192, 191, 191, 191), - (239, 239, 207, 207), - (128, 1, 128, 254), - (207, 113, 112, 207), - (255, 191, 128, 191), - ], - ) + self.assert_9points_paste( + im, + im2, + self.gradient_RGBA, + [ + (128, 191, 255, 191), + (208, 239, 239, 208), + (255, 255, 255, 255), + (112, 111, 206, 207), + (192, 191, 191, 191), + (239, 239, 207, 207), + (128, 1, 128, 254), + (207, 113, 112, 207), + (255, 191, 128, 191), + ], + ) - def test_image_mask_RGBa(self): - for mode in ("RGBA", "RGB", "L"): - im = Image.new(mode, (200, 200), "white") - im2 = getattr(self, "gradient_" + mode) + @pytest.mark.parametrize("mode", ["RGBA", "RGB", "L"]) + def test_image_mask_RGBa(self, mode): + im = Image.new(mode, (200, 200), "white") + im2 = getattr(self, "gradient_" + mode) - self.assert_9points_paste( - im, - im2, - self.gradient_RGBa, - [ - (128, 255, 126, 255), - (0, 127, 126, 255), - (126, 253, 126, 255), - (128, 127, 254, 255), - (0, 255, 254, 255), - (126, 125, 254, 255), - (128, 1, 128, 255), - (0, 129, 128, 255), - (126, 255, 128, 255), - ], - ) + self.assert_9points_paste( + im, + im2, + self.gradient_RGBa, + [ + (128, 255, 126, 255), + (0, 127, 126, 255), + (126, 253, 126, 255), + (128, 127, 254, 255), + (0, 255, 254, 255), + (126, 125, 254, 255), + (128, 1, 128, 255), + (0, 129, 128, 255), + (126, 255, 128, 255), + ], + ) - def test_color_solid(self): - for mode in ("RGBA", "RGB", "L"): - im = Image.new(mode, (200, 200), "black") + @pytest.mark.parametrize("mode", ["RGBA", "RGB", "L"]) + def test_color_solid(self, mode): + im = Image.new(mode, (200, 200), "black") - rect = (12, 23, 128 + 12, 128 + 23) - im.paste("white", rect) + rect = (12, 23, 128 + 12, 128 + 23) + im.paste("white", rect) - hist = im.crop(rect).histogram() - while hist: - head, hist = hist[:256], hist[256:] - assert head[255] == 128 * 128 - assert sum(head[:255]) == 0 + hist = im.crop(rect).histogram() + while hist: + head, hist = hist[:256], hist[256:] + assert head[255] == 128 * 128 + assert sum(head[:255]) == 0 - def test_color_mask_1(self): - for mode in ("RGBA", "RGB", "L"): - im = Image.new(mode, (200, 200), (50, 60, 70, 80)[: len(mode)]) - color = (10, 20, 30, 40)[: len(mode)] + @pytest.mark.parametrize("mode", ["RGBA", "RGB", "L"]) + def test_color_mask_1(self, mode): + im = Image.new(mode, (200, 200), (50, 60, 70, 80)[: len(mode)]) + color = (10, 20, 30, 40)[: len(mode)] - self.assert_9points_paste( - im, - color, - self.mask_1, - [ - (50, 60, 70, 80), - (50, 60, 70, 80), - (10, 20, 30, 40), - (50, 60, 70, 80), - (50, 60, 70, 80), - (10, 20, 30, 40), - (10, 20, 30, 40), - (10, 20, 30, 40), - (50, 60, 70, 80), - ], - ) + self.assert_9points_paste( + im, + color, + self.mask_1, + [ + (50, 60, 70, 80), + (50, 60, 70, 80), + (10, 20, 30, 40), + (50, 60, 70, 80), + (50, 60, 70, 80), + (10, 20, 30, 40), + (10, 20, 30, 40), + (10, 20, 30, 40), + (50, 60, 70, 80), + ], + ) - def test_color_mask_L(self): - for mode in ("RGBA", "RGB", "L"): - im = getattr(self, "gradient_" + mode).copy() - color = "white" + @pytest.mark.parametrize("mode", ["RGBA", "RGB", "L"]) + def test_color_mask_L(self, mode): + im = getattr(self, "gradient_" + mode).copy() + color = "white" - self.assert_9points_paste( - im, - color, - self.mask_L, - [ - (127, 191, 254, 191), - (111, 207, 206, 110), - (127, 254, 127, 0), - (207, 207, 239, 239), - (191, 191, 190, 191), - (207, 206, 111, 112), - (254, 254, 254, 255), - (239, 206, 206, 238), - (254, 191, 127, 191), - ], - ) + self.assert_9points_paste( + im, + color, + self.mask_L, + [ + (127, 191, 254, 191), + (111, 207, 206, 110), + (127, 254, 127, 0), + (207, 207, 239, 239), + (191, 191, 190, 191), + (207, 206, 111, 112), + (254, 254, 254, 255), + (239, 206, 206, 238), + (254, 191, 127, 191), + ], + ) - def test_color_mask_RGBA(self): - for mode in ("RGBA", "RGB", "L"): - im = getattr(self, "gradient_" + mode).copy() - color = "white" + @pytest.mark.parametrize("mode", ["RGBA", "RGB", "L"]) + def test_color_mask_RGBA(self, mode): + im = getattr(self, "gradient_" + mode).copy() + color = "white" - self.assert_9points_paste( - im, - color, - self.gradient_RGBA, - [ - (127, 191, 254, 191), - (111, 207, 206, 110), - (127, 254, 127, 0), - (207, 207, 239, 239), - (191, 191, 190, 191), - (207, 206, 111, 112), - (254, 254, 254, 255), - (239, 206, 206, 238), - (254, 191, 127, 191), - ], - ) + self.assert_9points_paste( + im, + color, + self.gradient_RGBA, + [ + (127, 191, 254, 191), + (111, 207, 206, 110), + (127, 254, 127, 0), + (207, 207, 239, 239), + (191, 191, 190, 191), + (207, 206, 111, 112), + (254, 254, 254, 255), + (239, 206, 206, 238), + (254, 191, 127, 191), + ], + ) - def test_color_mask_RGBa(self): - for mode in ("RGBA", "RGB", "L"): - im = getattr(self, "gradient_" + mode).copy() - color = "white" + @pytest.mark.parametrize("mode", ["RGBA", "RGB", "L"]) + def test_color_mask_RGBa(self, mode): + im = getattr(self, "gradient_" + mode).copy() + color = "white" - self.assert_9points_paste( - im, - color, - self.gradient_RGBa, - [ - (255, 63, 126, 63), - (47, 143, 142, 46), - (126, 253, 126, 255), - (15, 15, 47, 47), - (63, 63, 62, 63), - (142, 141, 46, 47), - (255, 255, 255, 0), - (48, 15, 15, 47), - (126, 63, 255, 63), - ], - ) + self.assert_9points_paste( + im, + color, + self.gradient_RGBa, + [ + (255, 63, 126, 63), + (47, 143, 142, 46), + (126, 253, 126, 255), + (15, 15, 47, 47), + (63, 63, 62, 63), + (142, 141, 46, 47), + (255, 255, 255, 0), + (48, 15, 15, 47), + (126, 63, 255, 63), + ], + ) def test_different_sizes(self): im = Image.new("RGB", (100, 100)) diff --git a/Tests/test_image_point.py b/Tests/test_image_point.py index 428ad116b..157ecb120 100644 --- a/Tests/test_image_point.py +++ b/Tests/test_image_point.py @@ -1,5 +1,7 @@ import pytest +from PIL import Image + from .helper import assert_image_equal, hopper @@ -17,11 +19,24 @@ def test_sanity(): im.point(list(range(256))) im.point(lambda x: x * 1) im.point(lambda x: x + 1) + im.point(lambda x: x - 1) im.point(lambda x: x * 1 + 1) + im.point(lambda x: 0.1 + 0.2 * x) + im.point(lambda x: -x) + im.point(lambda x: x - 0.5) + im.point(lambda x: 1 - x / 2) + im.point(lambda x: (2 + x) / 3) + im.point(lambda x: 0.5) + im.point(lambda x: x / 1) + im.point(lambda x: x + x) with pytest.raises(TypeError): - im.point(lambda x: x - 1) + im.point(lambda x: x * x) with pytest.raises(TypeError): - im.point(lambda x: x / 1) + im.point(lambda x: x / x) + with pytest.raises(TypeError): + im.point(lambda x: 1 / x) + with pytest.raises(TypeError): + im.point(lambda x: x // 2) def test_16bit_lut(): @@ -47,3 +62,8 @@ def test_f_mode(): im = hopper("F") with pytest.raises(ValueError): im.point(None) + + +def test_coerce_e_deprecation(): + with pytest.warns(DeprecationWarning): + assert Image.coerce_e(2).data == 2 diff --git a/Tests/test_image_quantize.py b/Tests/test_image_quantize.py index e9afd9118..981753eb9 100644 --- a/Tests/test_image_quantize.py +++ b/Tests/test_image_quantize.py @@ -65,6 +65,22 @@ def test_quantize_no_dither(): assert converted.palette.palette == palette.palette.palette +def test_quantize_no_dither2(): + im = Image.new("RGB", (9, 1)) + im.putdata(list((p,) * 3 for p in range(0, 36, 4))) + + palette = Image.new("P", (1, 1)) + data = (0, 0, 0, 32, 32, 32) + palette.putpalette(data) + quantized = im.quantize(dither=Image.Dither.NONE, palette=palette) + + assert tuple(quantized.palette.palette) == data + + px = quantized.load() + for x in range(9): + assert px[x, 0] == (0 if x < 5 else 1) + + def test_quantize_dither_diff(): image = hopper() with Image.open("Tests/images/caption_6_33_22.png") as palette: diff --git a/Tests/test_image_resample.py b/Tests/test_image_resample.py index 6d050efcc..5ce98a235 100644 --- a/Tests/test_image_resample.py +++ b/Tests/test_image_resample.py @@ -100,40 +100,41 @@ class TestImagingCoreResampleAccuracy: for y in range(image.size[1]) ) - def test_reduce_box(self): - for mode in ["RGBX", "RGB", "La", "L"]: - case = self.make_case(mode, (8, 8), 0xE1) - case = case.resize((4, 4), Image.Resampling.BOX) - # fmt: off - data = ("e1 e1" - "e1 e1") - # fmt: on - for channel in case.split(): - self.check_case(channel, self.make_sample(data, (4, 4))) + @pytest.mark.parametrize("mode", ("RGBX", "RGB", "La", "L")) + def test_reduce_box(self, mode): + case = self.make_case(mode, (8, 8), 0xE1) + case = case.resize((4, 4), Image.Resampling.BOX) + # fmt: off + data = ("e1 e1" + "e1 e1") + # fmt: on + for channel in case.split(): + self.check_case(channel, self.make_sample(data, (4, 4))) - def test_reduce_bilinear(self): - for mode in ["RGBX", "RGB", "La", "L"]: - case = self.make_case(mode, (8, 8), 0xE1) - case = case.resize((4, 4), Image.Resampling.BILINEAR) - # fmt: off - data = ("e1 c9" - "c9 b7") - # fmt: on - for channel in case.split(): - self.check_case(channel, self.make_sample(data, (4, 4))) + @pytest.mark.parametrize("mode", ("RGBX", "RGB", "La", "L")) + def test_reduce_bilinear(self, mode): + case = self.make_case(mode, (8, 8), 0xE1) + case = case.resize((4, 4), Image.Resampling.BILINEAR) + # fmt: off + data = ("e1 c9" + "c9 b7") + # fmt: on + for channel in case.split(): + self.check_case(channel, self.make_sample(data, (4, 4))) - def test_reduce_hamming(self): - for mode in ["RGBX", "RGB", "La", "L"]: - case = self.make_case(mode, (8, 8), 0xE1) - case = case.resize((4, 4), Image.Resampling.HAMMING) - # fmt: off - data = ("e1 da" - "da d3") - # fmt: on - for channel in case.split(): - self.check_case(channel, self.make_sample(data, (4, 4))) + @pytest.mark.parametrize("mode", ("RGBX", "RGB", "La", "L")) + def test_reduce_hamming(self, mode): + case = self.make_case(mode, (8, 8), 0xE1) + case = case.resize((4, 4), Image.Resampling.HAMMING) + # fmt: off + data = ("e1 da" + "da d3") + # fmt: on + for channel in case.split(): + self.check_case(channel, self.make_sample(data, (4, 4))) - def test_reduce_bicubic(self): + @pytest.mark.parametrize("mode", ("RGBX", "RGB", "La", "L")) + def test_reduce_bicubic(self, mode): for mode in ["RGBX", "RGB", "La", "L"]: case = self.make_case(mode, (12, 12), 0xE1) case = case.resize((6, 6), Image.Resampling.BICUBIC) @@ -145,79 +146,79 @@ class TestImagingCoreResampleAccuracy: for channel in case.split(): self.check_case(channel, self.make_sample(data, (6, 6))) - def test_reduce_lanczos(self): - for mode in ["RGBX", "RGB", "La", "L"]: - case = self.make_case(mode, (16, 16), 0xE1) - case = case.resize((8, 8), Image.Resampling.LANCZOS) - # fmt: off - data = ("e1 e0 e4 d7" - "e0 df e3 d6" - "e4 e3 e7 da" - "d7 d6 d9 ce") - # fmt: on - for channel in case.split(): - self.check_case(channel, self.make_sample(data, (8, 8))) + @pytest.mark.parametrize("mode", ("RGBX", "RGB", "La", "L")) + def test_reduce_lanczos(self, mode): + case = self.make_case(mode, (16, 16), 0xE1) + case = case.resize((8, 8), Image.Resampling.LANCZOS) + # fmt: off + data = ("e1 e0 e4 d7" + "e0 df e3 d6" + "e4 e3 e7 da" + "d7 d6 d9 ce") + # fmt: on + for channel in case.split(): + self.check_case(channel, self.make_sample(data, (8, 8))) - def test_enlarge_box(self): - for mode in ["RGBX", "RGB", "La", "L"]: - case = self.make_case(mode, (2, 2), 0xE1) - case = case.resize((4, 4), Image.Resampling.BOX) - # fmt: off - data = ("e1 e1" - "e1 e1") - # fmt: on - for channel in case.split(): - self.check_case(channel, self.make_sample(data, (4, 4))) + @pytest.mark.parametrize("mode", ("RGBX", "RGB", "La", "L")) + def test_enlarge_box(self, mode): + case = self.make_case(mode, (2, 2), 0xE1) + case = case.resize((4, 4), Image.Resampling.BOX) + # fmt: off + data = ("e1 e1" + "e1 e1") + # fmt: on + for channel in case.split(): + self.check_case(channel, self.make_sample(data, (4, 4))) - def test_enlarge_bilinear(self): - for mode in ["RGBX", "RGB", "La", "L"]: - case = self.make_case(mode, (2, 2), 0xE1) - case = case.resize((4, 4), Image.Resampling.BILINEAR) - # fmt: off - data = ("e1 b0" - "b0 98") - # fmt: on - for channel in case.split(): - self.check_case(channel, self.make_sample(data, (4, 4))) + @pytest.mark.parametrize("mode", ("RGBX", "RGB", "La", "L")) + def test_enlarge_bilinear(self, mode): + case = self.make_case(mode, (2, 2), 0xE1) + case = case.resize((4, 4), Image.Resampling.BILINEAR) + # fmt: off + data = ("e1 b0" + "b0 98") + # fmt: on + for channel in case.split(): + self.check_case(channel, self.make_sample(data, (4, 4))) - def test_enlarge_hamming(self): - for mode in ["RGBX", "RGB", "La", "L"]: - case = self.make_case(mode, (2, 2), 0xE1) - case = case.resize((4, 4), Image.Resampling.HAMMING) - # fmt: off - data = ("e1 d2" - "d2 c5") - # fmt: on - for channel in case.split(): - self.check_case(channel, self.make_sample(data, (4, 4))) + @pytest.mark.parametrize("mode", ("RGBX", "RGB", "La", "L")) + def test_enlarge_hamming(self, mode): + case = self.make_case(mode, (2, 2), 0xE1) + case = case.resize((4, 4), Image.Resampling.HAMMING) + # fmt: off + data = ("e1 d2" + "d2 c5") + # fmt: on + for channel in case.split(): + self.check_case(channel, self.make_sample(data, (4, 4))) - def test_enlarge_bicubic(self): - for mode in ["RGBX", "RGB", "La", "L"]: - case = self.make_case(mode, (4, 4), 0xE1) - case = case.resize((8, 8), Image.Resampling.BICUBIC) - # fmt: off - data = ("e1 e5 ee b9" - "e5 e9 f3 bc" - "ee f3 fd c1" - "b9 bc c1 a2") - # fmt: on - for channel in case.split(): - self.check_case(channel, self.make_sample(data, (8, 8))) + @pytest.mark.parametrize("mode", ("RGBX", "RGB", "La", "L")) + def test_enlarge_bicubic(self, mode): + case = self.make_case(mode, (4, 4), 0xE1) + case = case.resize((8, 8), Image.Resampling.BICUBIC) + # fmt: off + data = ("e1 e5 ee b9" + "e5 e9 f3 bc" + "ee f3 fd c1" + "b9 bc c1 a2") + # fmt: on + for channel in case.split(): + self.check_case(channel, self.make_sample(data, (8, 8))) - def test_enlarge_lanczos(self): - for mode in ["RGBX", "RGB", "La", "L"]: - case = self.make_case(mode, (6, 6), 0xE1) - case = case.resize((12, 12), Image.Resampling.LANCZOS) - data = ( - "e1 e0 db ed f5 b8" - "e0 df da ec f3 b7" - "db db d6 e7 ee b5" - "ed ec e6 fb ff bf" - "f5 f4 ee ff ff c4" - "b8 b7 b4 bf c4 a0" - ) - for channel in case.split(): - self.check_case(channel, self.make_sample(data, (12, 12))) + @pytest.mark.parametrize("mode", ("RGBX", "RGB", "La", "L")) + def test_enlarge_lanczos(self, mode): + case = self.make_case(mode, (6, 6), 0xE1) + case = case.resize((12, 12), Image.Resampling.LANCZOS) + data = ( + "e1 e0 db ed f5 b8" + "e0 df da ec f3 b7" + "db db d6 e7 ee b5" + "ed ec e6 fb ff bf" + "f5 f4 ee ff ff c4" + "b8 b7 b4 bf c4 a0" + ) + for channel in case.split(): + self.check_case(channel, self.make_sample(data, (12, 12))) def test_box_filter_correct_range(self): im = Image.new("RGB", (8, 8), "#1688ff").resize( @@ -419,40 +420,43 @@ class TestCoreResampleCoefficients: class TestCoreResampleBox: - def test_wrong_arguments(self): - im = hopper() - for resample in ( + @pytest.mark.parametrize( + "resample", + ( Image.Resampling.NEAREST, Image.Resampling.BOX, Image.Resampling.BILINEAR, Image.Resampling.HAMMING, Image.Resampling.BICUBIC, Image.Resampling.LANCZOS, - ): - im.resize((32, 32), resample, (0, 0, im.width, im.height)) - im.resize((32, 32), resample, (20, 20, im.width, im.height)) - im.resize((32, 32), resample, (20, 20, 20, 100)) - im.resize((32, 32), resample, (20, 20, 100, 20)) + ), + ) + def test_wrong_arguments(self, resample): + im = hopper() + im.resize((32, 32), resample, (0, 0, im.width, im.height)) + im.resize((32, 32), resample, (20, 20, im.width, im.height)) + im.resize((32, 32), resample, (20, 20, 20, 100)) + im.resize((32, 32), resample, (20, 20, 100, 20)) - with pytest.raises(TypeError, match="must be sequence of length 4"): - im.resize((32, 32), resample, (im.width, im.height)) + with pytest.raises(TypeError, match="must be sequence of length 4"): + im.resize((32, 32), resample, (im.width, im.height)) - with pytest.raises(ValueError, match="can't be negative"): - im.resize((32, 32), resample, (-20, 20, 100, 100)) - with pytest.raises(ValueError, match="can't be negative"): - im.resize((32, 32), resample, (20, -20, 100, 100)) + with pytest.raises(ValueError, match="can't be negative"): + im.resize((32, 32), resample, (-20, 20, 100, 100)) + with pytest.raises(ValueError, match="can't be negative"): + im.resize((32, 32), resample, (20, -20, 100, 100)) - with pytest.raises(ValueError, match="can't be empty"): - im.resize((32, 32), resample, (20.1, 20, 20, 100)) - with pytest.raises(ValueError, match="can't be empty"): - im.resize((32, 32), resample, (20, 20.1, 100, 20)) - with pytest.raises(ValueError, match="can't be empty"): - im.resize((32, 32), resample, (20.1, 20.1, 20, 20)) + with pytest.raises(ValueError, match="can't be empty"): + im.resize((32, 32), resample, (20.1, 20, 20, 100)) + with pytest.raises(ValueError, match="can't be empty"): + im.resize((32, 32), resample, (20, 20.1, 100, 20)) + with pytest.raises(ValueError, match="can't be empty"): + im.resize((32, 32), resample, (20.1, 20.1, 20, 20)) - with pytest.raises(ValueError, match="can't exceed"): - im.resize((32, 32), resample, (0, 0, im.width + 1, im.height)) - with pytest.raises(ValueError, match="can't exceed"): - im.resize((32, 32), resample, (0, 0, im.width, im.height + 1)) + with pytest.raises(ValueError, match="can't exceed"): + im.resize((32, 32), resample, (0, 0, im.width + 1, im.height)) + with pytest.raises(ValueError, match="can't exceed"): + im.resize((32, 32), resample, (0, 0, im.width, im.height + 1)) def resize_tiled(self, im, dst_size, xtiles, ytiles): def split_range(size, tiles): @@ -509,14 +513,16 @@ class TestCoreResampleBox: with pytest.raises(AssertionError, match=r"difference 29\."): assert_image_similar(reference, without_box, 5) - def test_formats(self): - for resample in [Image.Resampling.NEAREST, Image.Resampling.BILINEAR]: - for mode in ["RGB", "L", "RGBA", "LA", "I", ""]: - im = hopper(mode) - box = (20, 20, im.size[0] - 20, im.size[1] - 20) - with_box = im.resize((32, 32), resample, box) - cropped = im.crop(box).resize((32, 32), resample) - assert_image_similar(cropped, with_box, 0.4) + @pytest.mark.parametrize("mode", ("RGB", "L", "RGBA", "LA", "I", "")) + @pytest.mark.parametrize( + "resample", (Image.Resampling.NEAREST, Image.Resampling.BILINEAR) + ) + def test_formats(self, mode, resample): + im = hopper(mode) + box = (20, 20, im.size[0] - 20, im.size[1] - 20) + with_box = im.resize((32, 32), resample, box) + cropped = im.crop(box).resize((32, 32), resample) + assert_image_similar(cropped, with_box, 0.4) def test_passthrough(self): # When no resize is required diff --git a/Tests/test_image_resize.py b/Tests/test_image_resize.py index 8347fabb9..83c54cf62 100644 --- a/Tests/test_image_resize.py +++ b/Tests/test_image_resize.py @@ -22,24 +22,15 @@ class TestImagingCoreResize: im.load() return im._new(im.im.resize(size, f)) - def test_nearest_mode(self): - for mode in [ - "1", - "P", - "L", - "I", - "F", - "RGB", - "RGBA", - "CMYK", - "YCbCr", - "I;16", - ]: # exotic mode - im = hopper(mode) - r = self.resize(im, (15, 12), Image.Resampling.NEAREST) - assert r.mode == mode - assert r.size == (15, 12) - assert r.im.bands == im.im.bands + @pytest.mark.parametrize( + "mode", ("1", "P", "L", "I", "F", "RGB", "RGBA", "CMYK", "YCbCr", "I;16") + ) + def test_nearest_mode(self, mode): + im = hopper(mode) + r = self.resize(im, (15, 12), Image.Resampling.NEAREST) + assert r.mode == mode + assert r.size == (15, 12) + assert r.im.bands == im.im.bands def test_convolution_modes(self): with pytest.raises(ValueError): @@ -55,33 +46,58 @@ class TestImagingCoreResize: assert r.size == (15, 12) assert r.im.bands == im.im.bands - def test_reduce_filters(self): - for f in [ + @pytest.mark.parametrize( + "resample", + ( Image.Resampling.NEAREST, Image.Resampling.BOX, Image.Resampling.BILINEAR, Image.Resampling.HAMMING, Image.Resampling.BICUBIC, Image.Resampling.LANCZOS, - ]: - r = self.resize(hopper("RGB"), (15, 12), f) - assert r.mode == "RGB" - assert r.size == (15, 12) + ), + ) + def test_reduce_filters(self, resample): + r = self.resize(hopper("RGB"), (15, 12), resample) + assert r.mode == "RGB" + assert r.size == (15, 12) - def test_enlarge_filters(self): - for f in [ + @pytest.mark.parametrize( + "resample", + ( Image.Resampling.NEAREST, Image.Resampling.BOX, Image.Resampling.BILINEAR, Image.Resampling.HAMMING, Image.Resampling.BICUBIC, Image.Resampling.LANCZOS, - ]: - r = self.resize(hopper("RGB"), (212, 195), f) - assert r.mode == "RGB" - assert r.size == (212, 195) + ), + ) + def test_enlarge_filters(self, resample): + r = self.resize(hopper("RGB"), (212, 195), resample) + assert r.mode == "RGB" + assert r.size == (212, 195) - def test_endianness(self): + @pytest.mark.parametrize( + "resample", + ( + Image.Resampling.NEAREST, + Image.Resampling.BOX, + Image.Resampling.BILINEAR, + Image.Resampling.HAMMING, + Image.Resampling.BICUBIC, + Image.Resampling.LANCZOS, + ), + ) + @pytest.mark.parametrize( + "mode, channels_set", + ( + ("RGB", ("blank", "filled", "dirty")), + ("RGBA", ("blank", "blank", "filled", "dirty")), + ("LA", ("filled", "dirty")), + ), + ) + def test_endianness(self, resample, mode, channels_set): # Make an image with one colored pixel, in one channel. # When resized, that channel should be the same as a GS image. # Other channels should be unaffected. @@ -95,47 +111,37 @@ class TestImagingCoreResize: } samples["dirty"].putpixel((1, 1), 128) - for f in [ + # samples resized with current filter + references = { + name: self.resize(ch, (4, 4), resample) for name, ch in samples.items() + } + + for channels in set(permutations(channels_set)): + # compile image from different channels permutations + im = Image.merge(mode, [samples[ch] for ch in channels]) + resized = self.resize(im, (4, 4), resample) + + for i, ch in enumerate(resized.split()): + # check what resized channel in image is the same + # as separately resized channel + assert_image_equal(ch, references[channels[i]]) + + @pytest.mark.parametrize( + "resample", + ( Image.Resampling.NEAREST, Image.Resampling.BOX, Image.Resampling.BILINEAR, Image.Resampling.HAMMING, Image.Resampling.BICUBIC, Image.Resampling.LANCZOS, - ]: - # samples resized with current filter - references = { - name: self.resize(ch, (4, 4), f) for name, ch in samples.items() - } - - for mode, channels_set in [ - ("RGB", ("blank", "filled", "dirty")), - ("RGBA", ("blank", "blank", "filled", "dirty")), - ("LA", ("filled", "dirty")), - ]: - for channels in set(permutations(channels_set)): - # compile image from different channels permutations - im = Image.merge(mode, [samples[ch] for ch in channels]) - resized = self.resize(im, (4, 4), f) - - for i, ch in enumerate(resized.split()): - # check what resized channel in image is the same - # as separately resized channel - assert_image_equal(ch, references[channels[i]]) - - def test_enlarge_zero(self): - for f in [ - Image.Resampling.NEAREST, - Image.Resampling.BOX, - Image.Resampling.BILINEAR, - Image.Resampling.HAMMING, - Image.Resampling.BICUBIC, - Image.Resampling.LANCZOS, - ]: - r = self.resize(Image.new("RGB", (0, 0), "white"), (212, 195), f) - assert r.mode == "RGB" - assert r.size == (212, 195) - assert r.getdata()[0] == (0, 0, 0) + ), + ) + def test_enlarge_zero(self, resample): + r = self.resize(Image.new("RGB", (0, 0), "white"), (212, 195), resample) + assert r.mode == "RGB" + assert r.size == (212, 195) + assert r.getdata()[0] == (0, 0, 0) def test_unknown_filter(self): with pytest.raises(ValueError): @@ -179,74 +185,71 @@ class TestReducingGapResize: (52, 34), Image.Resampling.BICUBIC, reducing_gap=0.99 ) - def test_reducing_gap_1(self, gradients_image): - for box, epsilon in [ - (None, 4), - ((1.1, 2.2, 510.8, 510.9), 4), - ((3, 10, 410, 256), 10), - ]: - ref = gradients_image.resize((52, 34), Image.Resampling.BICUBIC, box=box) - im = gradients_image.resize( - (52, 34), Image.Resampling.BICUBIC, box=box, reducing_gap=1.0 - ) - - with pytest.raises(AssertionError): - assert_image_equal(ref, im) - - assert_image_similar(ref, im, epsilon) - - def test_reducing_gap_2(self, gradients_image): - for box, epsilon in [ - (None, 1.5), - ((1.1, 2.2, 510.8, 510.9), 1.5), - ((3, 10, 410, 256), 1), - ]: - ref = gradients_image.resize((52, 34), Image.Resampling.BICUBIC, box=box) - im = gradients_image.resize( - (52, 34), Image.Resampling.BICUBIC, box=box, reducing_gap=2.0 - ) - - with pytest.raises(AssertionError): - assert_image_equal(ref, im) - - assert_image_similar(ref, im, epsilon) - - def test_reducing_gap_3(self, gradients_image): - for box, epsilon in [ - (None, 1), - ((1.1, 2.2, 510.8, 510.9), 1), - ((3, 10, 410, 256), 0.5), - ]: - ref = gradients_image.resize((52, 34), Image.Resampling.BICUBIC, box=box) - im = gradients_image.resize( - (52, 34), Image.Resampling.BICUBIC, box=box, reducing_gap=3.0 - ) - - with pytest.raises(AssertionError): - assert_image_equal(ref, im) - - assert_image_similar(ref, im, epsilon) - - def test_reducing_gap_8(self, gradients_image): - for box in [None, (1.1, 2.2, 510.8, 510.9), (3, 10, 410, 256)]: - ref = gradients_image.resize((52, 34), Image.Resampling.BICUBIC, box=box) - im = gradients_image.resize( - (52, 34), Image.Resampling.BICUBIC, box=box, reducing_gap=8.0 - ) + @pytest.mark.parametrize( + "box, epsilon", + ((None, 4), ((1.1, 2.2, 510.8, 510.9), 4), ((3, 10, 410, 256), 10)), + ) + def test_reducing_gap_1(self, gradients_image, box, epsilon): + ref = gradients_image.resize((52, 34), Image.Resampling.BICUBIC, box=box) + im = gradients_image.resize( + (52, 34), Image.Resampling.BICUBIC, box=box, reducing_gap=1.0 + ) + with pytest.raises(AssertionError): assert_image_equal(ref, im) - def test_box_filter(self, gradients_image): - for box, epsilon in [ - ((0, 0, 512, 512), 5.5), - ((0.9, 1.7, 128, 128), 9.5), - ]: - ref = gradients_image.resize((52, 34), Image.Resampling.BOX, box=box) - im = gradients_image.resize( - (52, 34), Image.Resampling.BOX, box=box, reducing_gap=1.0 - ) + assert_image_similar(ref, im, epsilon) - assert_image_similar(ref, im, epsilon) + @pytest.mark.parametrize( + "box, epsilon", + ((None, 1.5), ((1.1, 2.2, 510.8, 510.9), 1.5), ((3, 10, 410, 256), 1)), + ) + def test_reducing_gap_2(self, gradients_image, box, epsilon): + ref = gradients_image.resize((52, 34), Image.Resampling.BICUBIC, box=box) + im = gradients_image.resize( + (52, 34), Image.Resampling.BICUBIC, box=box, reducing_gap=2.0 + ) + + with pytest.raises(AssertionError): + assert_image_equal(ref, im) + + assert_image_similar(ref, im, epsilon) + + @pytest.mark.parametrize( + "box, epsilon", + ((None, 1), ((1.1, 2.2, 510.8, 510.9), 1), ((3, 10, 410, 256), 0.5)), + ) + def test_reducing_gap_3(self, gradients_image, box, epsilon): + ref = gradients_image.resize((52, 34), Image.Resampling.BICUBIC, box=box) + im = gradients_image.resize( + (52, 34), Image.Resampling.BICUBIC, box=box, reducing_gap=3.0 + ) + + with pytest.raises(AssertionError): + assert_image_equal(ref, im) + + assert_image_similar(ref, im, epsilon) + + @pytest.mark.parametrize("box", (None, (1.1, 2.2, 510.8, 510.9), (3, 10, 410, 256))) + def test_reducing_gap_8(self, gradients_image, box): + ref = gradients_image.resize((52, 34), Image.Resampling.BICUBIC, box=box) + im = gradients_image.resize( + (52, 34), Image.Resampling.BICUBIC, box=box, reducing_gap=8.0 + ) + + assert_image_equal(ref, im) + + @pytest.mark.parametrize( + "box, epsilon", + (((0, 0, 512, 512), 5.5), ((0.9, 1.7, 128, 128), 9.5)), + ) + def test_box_filter(self, gradients_image, box, epsilon): + ref = gradients_image.resize((52, 34), Image.Resampling.BOX, box=box) + im = gradients_image.resize( + (52, 34), Image.Resampling.BOX, box=box, reducing_gap=1.0 + ) + + assert_image_similar(ref, im, epsilon) class TestImageResize: @@ -273,15 +276,14 @@ class TestImageResize: im = im.resize((64, 64)) assert im.size == (64, 64) - def test_default_filter(self): - for mode in "L", "RGB", "I", "F": - im = hopper(mode) - assert im.resize((20, 20), Image.Resampling.BICUBIC) == im.resize((20, 20)) + @pytest.mark.parametrize("mode", ("L", "RGB", "I", "F")) + def test_default_filter_bicubic(self, mode): + im = hopper(mode) + assert im.resize((20, 20), Image.Resampling.BICUBIC) == im.resize((20, 20)) - for mode in "1", "P": - im = hopper(mode) - assert im.resize((20, 20), Image.Resampling.NEAREST) == im.resize((20, 20)) - - for mode in "I;16", "I;16L", "I;16B", "BGR;15", "BGR;16": - im = hopper(mode) - assert im.resize((20, 20), Image.Resampling.NEAREST) == im.resize((20, 20)) + @pytest.mark.parametrize( + "mode", ("1", "P", "I;16", "I;16L", "I;16B", "BGR;15", "BGR;16") + ) + def test_default_filter_nearest(self, mode): + im = hopper(mode) + assert im.resize((20, 20), Image.Resampling.NEAREST) == im.resize((20, 20)) diff --git a/Tests/test_image_rotate.py b/Tests/test_image_rotate.py index f96864c53..a19f19831 100644 --- a/Tests/test_image_rotate.py +++ b/Tests/test_image_rotate.py @@ -1,3 +1,5 @@ +import pytest + from PIL import Image from .helper import ( @@ -22,26 +24,26 @@ def rotate(im, mode, angle, center=None, translate=None): assert out.size != im.size -def test_mode(): - for mode in ("1", "P", "L", "RGB", "I", "F"): - im = hopper(mode) - rotate(im, mode, 45) +@pytest.mark.parametrize("mode", ("1", "P", "L", "RGB", "I", "F")) +def test_mode(mode): + im = hopper(mode) + rotate(im, mode, 45) -def test_angle(): - for angle in (0, 90, 180, 270): - with Image.open("Tests/images/test-card.png") as im: - rotate(im, im.mode, angle) - - im = hopper() - assert_image_equal(im.rotate(angle), im.rotate(angle, expand=1)) - - -def test_zero(): - for angle in (0, 45, 90, 180, 270): - im = Image.new("RGB", (0, 0)) +@pytest.mark.parametrize("angle", (0, 90, 180, 270)) +def test_angle(angle): + with Image.open("Tests/images/test-card.png") as im: rotate(im, im.mode, angle) + im = hopper() + assert_image_equal(im.rotate(angle), im.rotate(angle, expand=1)) + + +@pytest.mark.parametrize("angle", (0, 45, 90, 180, 270)) +def test_zero(angle): + im = Image.new("RGB", (0, 0)) + rotate(im, im.mode, angle) + def test_resample(): # Target image creation, inspected by eye. diff --git a/Tests/test_image_transpose.py b/Tests/test_image_transpose.py index 6408e1564..877f439ca 100644 --- a/Tests/test_image_transpose.py +++ b/Tests/test_image_transpose.py @@ -1,3 +1,5 @@ +import pytest + from PIL.Image import Transpose from . import helper @@ -9,157 +11,136 @@ HOPPER = { } -def test_flip_left_right(): - def transpose(mode): - im = HOPPER[mode] - out = im.transpose(Transpose.FLIP_LEFT_RIGHT) - assert out.mode == mode - assert out.size == im.size +@pytest.mark.parametrize("mode", HOPPER) +def test_flip_left_right(mode): + im = HOPPER[mode] + out = im.transpose(Transpose.FLIP_LEFT_RIGHT) + assert out.mode == mode + assert out.size == im.size - x, y = im.size - assert im.getpixel((1, 1)) == out.getpixel((x - 2, 1)) - assert im.getpixel((x - 2, 1)) == out.getpixel((1, 1)) - assert im.getpixel((1, y - 2)) == out.getpixel((x - 2, y - 2)) - assert im.getpixel((x - 2, y - 2)) == out.getpixel((1, y - 2)) - - for mode in HOPPER: - transpose(mode) + x, y = im.size + assert im.getpixel((1, 1)) == out.getpixel((x - 2, 1)) + assert im.getpixel((x - 2, 1)) == out.getpixel((1, 1)) + assert im.getpixel((1, y - 2)) == out.getpixel((x - 2, y - 2)) + assert im.getpixel((x - 2, y - 2)) == out.getpixel((1, y - 2)) -def test_flip_top_bottom(): - def transpose(mode): - im = HOPPER[mode] - out = im.transpose(Transpose.FLIP_TOP_BOTTOM) - assert out.mode == mode - assert out.size == im.size +@pytest.mark.parametrize("mode", HOPPER) +def test_flip_top_bottom(mode): + im = HOPPER[mode] + out = im.transpose(Transpose.FLIP_TOP_BOTTOM) + assert out.mode == mode + assert out.size == im.size - x, y = im.size - assert im.getpixel((1, 1)) == out.getpixel((1, y - 2)) - assert im.getpixel((x - 2, 1)) == out.getpixel((x - 2, y - 2)) - assert im.getpixel((1, y - 2)) == out.getpixel((1, 1)) - assert im.getpixel((x - 2, y - 2)) == out.getpixel((x - 2, 1)) - - for mode in HOPPER: - transpose(mode) + x, y = im.size + assert im.getpixel((1, 1)) == out.getpixel((1, y - 2)) + assert im.getpixel((x - 2, 1)) == out.getpixel((x - 2, y - 2)) + assert im.getpixel((1, y - 2)) == out.getpixel((1, 1)) + assert im.getpixel((x - 2, y - 2)) == out.getpixel((x - 2, 1)) -def test_rotate_90(): - def transpose(mode): - im = HOPPER[mode] - out = im.transpose(Transpose.ROTATE_90) - assert out.mode == mode - assert out.size == im.size[::-1] +@pytest.mark.parametrize("mode", HOPPER) +def test_rotate_90(mode): + im = HOPPER[mode] + out = im.transpose(Transpose.ROTATE_90) + assert out.mode == mode + assert out.size == im.size[::-1] - x, y = im.size - assert im.getpixel((1, 1)) == out.getpixel((1, x - 2)) - assert im.getpixel((x - 2, 1)) == out.getpixel((1, 1)) - assert im.getpixel((1, y - 2)) == out.getpixel((y - 2, x - 2)) - assert im.getpixel((x - 2, y - 2)) == out.getpixel((y - 2, 1)) - - for mode in HOPPER: - transpose(mode) + x, y = im.size + assert im.getpixel((1, 1)) == out.getpixel((1, x - 2)) + assert im.getpixel((x - 2, 1)) == out.getpixel((1, 1)) + assert im.getpixel((1, y - 2)) == out.getpixel((y - 2, x - 2)) + assert im.getpixel((x - 2, y - 2)) == out.getpixel((y - 2, 1)) -def test_rotate_180(): - def transpose(mode): - im = HOPPER[mode] - out = im.transpose(Transpose.ROTATE_180) - assert out.mode == mode - assert out.size == im.size +@pytest.mark.parametrize("mode", HOPPER) +def test_rotate_180(mode): + im = HOPPER[mode] + out = im.transpose(Transpose.ROTATE_180) + assert out.mode == mode + assert out.size == im.size - x, y = im.size - assert im.getpixel((1, 1)) == out.getpixel((x - 2, y - 2)) - assert im.getpixel((x - 2, 1)) == out.getpixel((1, y - 2)) - assert im.getpixel((1, y - 2)) == out.getpixel((x - 2, 1)) - assert im.getpixel((x - 2, y - 2)) == out.getpixel((1, 1)) - - for mode in HOPPER: - transpose(mode) + x, y = im.size + assert im.getpixel((1, 1)) == out.getpixel((x - 2, y - 2)) + assert im.getpixel((x - 2, 1)) == out.getpixel((1, y - 2)) + assert im.getpixel((1, y - 2)) == out.getpixel((x - 2, 1)) + assert im.getpixel((x - 2, y - 2)) == out.getpixel((1, 1)) -def test_rotate_270(): - def transpose(mode): - im = HOPPER[mode] - out = im.transpose(Transpose.ROTATE_270) - assert out.mode == mode - assert out.size == im.size[::-1] +@pytest.mark.parametrize("mode", HOPPER) +def test_rotate_270(mode): + im = HOPPER[mode] + out = im.transpose(Transpose.ROTATE_270) + assert out.mode == mode + assert out.size == im.size[::-1] - x, y = im.size - assert im.getpixel((1, 1)) == out.getpixel((y - 2, 1)) - assert im.getpixel((x - 2, 1)) == out.getpixel((y - 2, x - 2)) - assert im.getpixel((1, y - 2)) == out.getpixel((1, 1)) - assert im.getpixel((x - 2, y - 2)) == out.getpixel((1, x - 2)) - - for mode in HOPPER: - transpose(mode) + x, y = im.size + assert im.getpixel((1, 1)) == out.getpixel((y - 2, 1)) + assert im.getpixel((x - 2, 1)) == out.getpixel((y - 2, x - 2)) + assert im.getpixel((1, y - 2)) == out.getpixel((1, 1)) + assert im.getpixel((x - 2, y - 2)) == out.getpixel((1, x - 2)) -def test_transpose(): - def transpose(mode): - im = HOPPER[mode] - out = im.transpose(Transpose.TRANSPOSE) - assert out.mode == mode - assert out.size == im.size[::-1] +@pytest.mark.parametrize("mode", HOPPER) +def test_transpose(mode): + im = HOPPER[mode] + out = im.transpose(Transpose.TRANSPOSE) + assert out.mode == mode + assert out.size == im.size[::-1] - x, y = im.size - assert im.getpixel((1, 1)) == out.getpixel((1, 1)) - assert im.getpixel((x - 2, 1)) == out.getpixel((1, x - 2)) - assert im.getpixel((1, y - 2)) == out.getpixel((y - 2, 1)) - assert im.getpixel((x - 2, y - 2)) == out.getpixel((y - 2, x - 2)) - - for mode in HOPPER: - transpose(mode) + x, y = im.size + assert im.getpixel((1, 1)) == out.getpixel((1, 1)) + assert im.getpixel((x - 2, 1)) == out.getpixel((1, x - 2)) + assert im.getpixel((1, y - 2)) == out.getpixel((y - 2, 1)) + assert im.getpixel((x - 2, y - 2)) == out.getpixel((y - 2, x - 2)) -def test_tranverse(): - def transpose(mode): - im = HOPPER[mode] - out = im.transpose(Transpose.TRANSVERSE) - assert out.mode == mode - assert out.size == im.size[::-1] +@pytest.mark.parametrize("mode", HOPPER) +def test_tranverse(mode): + im = HOPPER[mode] + out = im.transpose(Transpose.TRANSVERSE) + assert out.mode == mode + assert out.size == im.size[::-1] - x, y = im.size - assert im.getpixel((1, 1)) == out.getpixel((y - 2, x - 2)) - assert im.getpixel((x - 2, 1)) == out.getpixel((y - 2, 1)) - assert im.getpixel((1, y - 2)) == out.getpixel((1, x - 2)) - assert im.getpixel((x - 2, y - 2)) == out.getpixel((1, 1)) - - for mode in HOPPER: - transpose(mode) + x, y = im.size + assert im.getpixel((1, 1)) == out.getpixel((y - 2, x - 2)) + assert im.getpixel((x - 2, 1)) == out.getpixel((y - 2, 1)) + assert im.getpixel((1, y - 2)) == out.getpixel((1, x - 2)) + assert im.getpixel((x - 2, y - 2)) == out.getpixel((1, 1)) -def test_roundtrip(): - for mode in HOPPER: - im = HOPPER[mode] +@pytest.mark.parametrize("mode", HOPPER) +def test_roundtrip(mode): + im = HOPPER[mode] - def transpose(first, second): - return im.transpose(first).transpose(second) + def transpose(first, second): + return im.transpose(first).transpose(second) - assert_image_equal( - im, transpose(Transpose.FLIP_LEFT_RIGHT, Transpose.FLIP_LEFT_RIGHT) - ) - assert_image_equal( - im, transpose(Transpose.FLIP_TOP_BOTTOM, Transpose.FLIP_TOP_BOTTOM) - ) - assert_image_equal(im, transpose(Transpose.ROTATE_90, Transpose.ROTATE_270)) - assert_image_equal(im, transpose(Transpose.ROTATE_180, Transpose.ROTATE_180)) - assert_image_equal( - im.transpose(Transpose.TRANSPOSE), - transpose(Transpose.ROTATE_90, Transpose.FLIP_TOP_BOTTOM), - ) - assert_image_equal( - im.transpose(Transpose.TRANSPOSE), - transpose(Transpose.ROTATE_270, Transpose.FLIP_LEFT_RIGHT), - ) - assert_image_equal( - im.transpose(Transpose.TRANSVERSE), - transpose(Transpose.ROTATE_90, Transpose.FLIP_LEFT_RIGHT), - ) - assert_image_equal( - im.transpose(Transpose.TRANSVERSE), - transpose(Transpose.ROTATE_270, Transpose.FLIP_TOP_BOTTOM), - ) - assert_image_equal( - im.transpose(Transpose.TRANSVERSE), - transpose(Transpose.ROTATE_180, Transpose.TRANSPOSE), - ) + assert_image_equal( + im, transpose(Transpose.FLIP_LEFT_RIGHT, Transpose.FLIP_LEFT_RIGHT) + ) + assert_image_equal( + im, transpose(Transpose.FLIP_TOP_BOTTOM, Transpose.FLIP_TOP_BOTTOM) + ) + assert_image_equal(im, transpose(Transpose.ROTATE_90, Transpose.ROTATE_270)) + assert_image_equal(im, transpose(Transpose.ROTATE_180, Transpose.ROTATE_180)) + assert_image_equal( + im.transpose(Transpose.TRANSPOSE), + transpose(Transpose.ROTATE_90, Transpose.FLIP_TOP_BOTTOM), + ) + assert_image_equal( + im.transpose(Transpose.TRANSPOSE), + transpose(Transpose.ROTATE_270, Transpose.FLIP_LEFT_RIGHT), + ) + assert_image_equal( + im.transpose(Transpose.TRANSVERSE), + transpose(Transpose.ROTATE_90, Transpose.FLIP_LEFT_RIGHT), + ) + assert_image_equal( + im.transpose(Transpose.TRANSVERSE), + transpose(Transpose.ROTATE_270, Transpose.FLIP_TOP_BOTTOM), + ) + assert_image_equal( + im.transpose(Transpose.TRANSVERSE), + transpose(Transpose.ROTATE_180, Transpose.TRANSPOSE), + ) diff --git a/Tests/test_imagecms.py b/Tests/test_imagecms.py index 66a72a90e..3d8dbe6bb 100644 --- a/Tests/test_imagecms.py +++ b/Tests/test_imagecms.py @@ -174,19 +174,24 @@ def test_exceptions(): psRGB = ImageCms.createProfile("sRGB") pLab = ImageCms.createProfile("LAB") t = ImageCms.buildTransform(pLab, psRGB, "LAB", "RGB") - with pytest.raises(ValueError): + with pytest.raises(ValueError, match="mode mismatch"): t.apply_in_place(hopper("RGBA")) # the procedural pyCMS API uses PyCMSError for all sorts of errors with hopper() as im: - with pytest.raises(ImageCms.PyCMSError): + with pytest.raises(ImageCms.PyCMSError, match="cannot open profile file"): ImageCms.profileToProfile(im, "foo", "bar") - with pytest.raises(ImageCms.PyCMSError): + + with pytest.raises(ImageCms.PyCMSError, match="cannot open profile file"): ImageCms.buildTransform("foo", "bar", "RGB", "RGB") - with pytest.raises(ImageCms.PyCMSError): + + with pytest.raises(ImageCms.PyCMSError, match="Invalid type for Profile"): ImageCms.getProfileName(None) skip_missing() - with pytest.raises(ImageCms.PyCMSError): + + # Python <= 3.9: "an integer is required (got type NoneType)" + # Python > 3.9: "'NoneType' object cannot be interpreted as an integer" + with pytest.raises(ImageCms.PyCMSError, match="integer"): ImageCms.isIntentSupported(SRGB, None, None) @@ -201,15 +206,32 @@ def test_lab_color_profile(): def test_unsupported_color_space(): - with pytest.raises(ImageCms.PyCMSError): + with pytest.raises( + ImageCms.PyCMSError, + match=re.escape( + "Color space not supported for on-the-fly profile creation (unsupported)" + ), + ): ImageCms.createProfile("unsupported") def test_invalid_color_temperature(): - with pytest.raises(ImageCms.PyCMSError): + with pytest.raises( + ImageCms.PyCMSError, + match='Color temperature must be numeric, "invalid" not valid', + ): ImageCms.createProfile("LAB", "invalid") +@pytest.mark.parametrize("flag", ("my string", -1)) +def test_invalid_flag(flag): + with hopper() as im: + with pytest.raises( + ImageCms.PyCMSError, match="flags must be an integer between 0 and " + ): + ImageCms.profileToProfile(im, "foo", "bar", flags=flag) + + def test_simple_lab(): i = Image.new("RGB", (10, 10), (128, 128, 128)) @@ -461,9 +483,9 @@ def test_profile_typesafety(): prepatch, these would segfault, postpatch they should emit a typeerror """ - with pytest.raises(TypeError): + with pytest.raises(TypeError, match="Invalid type for Profile"): ImageCms.ImageCmsProfile(0).tobytes() - with pytest.raises(TypeError): + with pytest.raises(TypeError, match="Invalid type for Profile"): ImageCms.ImageCmsProfile(1).tobytes() diff --git a/Tests/test_imagedraw.py b/Tests/test_imagedraw.py index 6755d94b8..d1dd1e47c 100644 --- a/Tests/test_imagedraw.py +++ b/Tests/test_imagedraw.py @@ -625,20 +625,20 @@ def test_polygon2(): helper_polygon(POINTS2) -def test_polygon_kite(): +@pytest.mark.parametrize("mode", ("RGB", "L")) +def test_polygon_kite(mode): # Test drawing lines of different gradients (dx>dy, dy>dx) and # vertical (dx==0) and horizontal (dy==0) lines - for mode in ["RGB", "L"]: - # Arrange - im = Image.new(mode, (W, H)) - draw = ImageDraw.Draw(im) - expected = f"Tests/images/imagedraw_polygon_kite_{mode}.png" + # Arrange + im = Image.new(mode, (W, H)) + draw = ImageDraw.Draw(im) + expected = f"Tests/images/imagedraw_polygon_kite_{mode}.png" - # Act - draw.polygon(KITE_POINTS, fill="blue", outline="yellow") + # Act + draw.polygon(KITE_POINTS, fill="blue", outline="yellow") - # Assert - assert_image_equal_tofile(im, expected) + # Assert + assert_image_equal_tofile(im, expected) def test_polygon_1px_high(): @@ -655,6 +655,20 @@ def test_polygon_1px_high(): assert_image_equal_tofile(im, expected) +def test_polygon_1px_high_translucent(): + # Test drawing a translucent 1px high polygon + # Arrange + im = Image.new("RGB", (4, 3)) + draw = ImageDraw.Draw(im, "RGBA") + expected = "Tests/images/imagedraw_polygon_1px_high_translucent.png" + + # Act + draw.polygon([(1, 1), (1, 1), (3, 1), (3, 1)], (255, 0, 0, 127)) + + # Assert + assert_image_equal_tofile(im, expected) + + def test_polygon_translucent(): # Arrange im = Image.new("RGB", (W, H)) @@ -1218,21 +1232,39 @@ def test_textsize_empty_string(): # Act # Should not cause 'SystemError: returned NULL without setting an error' - draw.textsize("") - draw.textsize("\n") - draw.textsize("test\n") + draw.textbbox((0, 0), "") + draw.textbbox((0, 0), "\n") + draw.textbbox((0, 0), "test\n") + draw.textlength("") @skip_unless_feature("freetype2") -def test_textsize_stroke(): +def test_textbbox_stroke(): # Arrange im = Image.new("RGB", (W, H)) draw = ImageDraw.Draw(im) font = ImageFont.truetype("Tests/fonts/FreeMono.ttf", 20) # Act / Assert - assert draw.textsize("A", font, stroke_width=2) == (16, 20) - assert draw.multiline_textsize("ABC\nAaaa", font, stroke_width=2) == (52, 44) + assert draw.textbbox((2, 2), "A", font, stroke_width=2) == (0, 4, 16, 20) + assert draw.textbbox((2, 2), "A", font, stroke_width=4) == (-2, 2, 18, 22) + assert draw.textbbox((2, 2), "ABC\nAaaa", font, stroke_width=2) == (0, 4, 52, 44) + assert draw.textbbox((2, 2), "ABC\nAaaa", font, stroke_width=4) == (-2, 2, 54, 50) + + +def test_textsize_deprecation(): + im = Image.new("RGB", (W, H)) + draw = ImageDraw.Draw(im) + + with pytest.warns(DeprecationWarning) as log: + draw.textsize("Hello") + assert len(log) == 1 + with pytest.warns(DeprecationWarning) as log: + draw.textsize("Hello\nWorld") + assert len(log) == 1 + with pytest.warns(DeprecationWarning) as log: + draw.multiline_textsize("Hello\nWorld") + assert len(log) == 1 @skip_unless_feature("freetype2") @@ -1282,6 +1314,23 @@ def test_stroke_multiline(): assert_image_similar_tofile(im, "Tests/images/imagedraw_stroke_multiline.png", 3.3) +def test_setting_default_font(): + # Arrange + im = Image.new("RGB", (100, 250)) + draw = ImageDraw.Draw(im) + font = ImageFont.truetype("Tests/fonts/FreeMono.ttf", 120) + + # Act + ImageDraw.ImageDraw.font = font + + # Assert + try: + assert draw.getfont() == font + finally: + ImageDraw.ImageDraw.font = None + assert isinstance(draw.getfont(), ImageFont.ImageFont) + + def test_same_color_outline(): # Prepare shape x0, y0 = 5, 5 @@ -1452,3 +1501,11 @@ def test_discontiguous_corners_polygon(): ) expected = os.path.join(IMAGES_PATH, "discontiguous_corners_polygon.png") assert_image_similar_tofile(img, expected, 1) + + +def test_polygon(): + im = Image.new("RGB", (W, H)) + draw = ImageDraw.Draw(im) + draw.polygon([(18, 30), (19, 31), (18, 30), (85, 30), (60, 72)], "red") + expected = "Tests/images/imagedraw_outline_polygon_RGB.png" + assert_image_similar_tofile(im, expected, 1) diff --git a/Tests/test_imagedraw2.py b/Tests/test_imagedraw2.py index 3a70176ce..e4e8a38cb 100644 --- a/Tests/test_imagedraw2.py +++ b/Tests/test_imagedraw2.py @@ -1,5 +1,7 @@ import os.path +import pytest + from PIL import Image, ImageDraw, ImageDraw2 from .helper import ( @@ -205,7 +207,9 @@ def test_textsize(): font = ImageDraw2.Font("white", FONT_PATH) # Act - size = draw.textsize("ImageDraw2", font) + with pytest.warns(DeprecationWarning) as log: + size = draw.textsize("ImageDraw2", font) + assert len(log) == 1 # Assert assert size[1] == 12 @@ -221,9 +225,10 @@ def test_textsize_empty_string(): # Act # Should not cause 'SystemError: returned NULL without setting an error' - draw.textsize("", font) - draw.textsize("\n", font) - draw.textsize("test\n", font) + draw.textbbox((0, 0), "", font) + draw.textbbox((0, 0), "\n", font) + draw.textbbox((0, 0), "test\n", font) + draw.textlength("", font) @skip_unless_feature("freetype2") diff --git a/Tests/test_imagefont.py b/Tests/test_imagefont.py index 0e1d1e637..16da87d46 100644 --- a/Tests/test_imagefont.py +++ b/Tests/test_imagefont.py @@ -65,9 +65,12 @@ class TestImageFont: return font_bytes def test_font_with_filelike(self): - ImageFont.truetype( + ttf = ImageFont.truetype( self._font_as_bytes(), FONT_SIZE, layout_engine=self.LAYOUT_ENGINE ) + ttf_copy = ttf.font_variant() + assert ttf_copy.font_bytes == ttf.font_bytes + self._render(self._font_as_bytes()) # Usage note: making two fonts from the same buffer fails. # shared_bytes = self._font_as_bytes() @@ -91,7 +94,7 @@ class TestImageFont: def _render(self, font): txt = "Hello World!" ttf = ImageFont.truetype(font, FONT_SIZE, layout_engine=self.LAYOUT_ENGINE) - ttf.getsize(txt) + ttf.getbbox(txt) img = Image.new("RGB", (256, 64), "white") d = ImageDraw.Draw(img) @@ -132,15 +135,15 @@ class TestImageFont: target = "Tests/images/transparent_background_text_L.png" assert_image_similar_tofile(im.convert("L"), target, 0.01) - def test_textsize_equal(self): + def test_textbbox_equal(self): im = Image.new(mode="RGB", size=(300, 100)) draw = ImageDraw.Draw(im) ttf = self.get_font() txt = "Hello World!" - size = draw.textsize(txt, ttf) + bbox = draw.textbbox((10, 10), txt, ttf) draw.text((10, 10), txt, font=ttf) - draw.rectangle((10, 10, 10 + size[0], 10 + size[1])) + draw.rectangle(bbox) assert_image_similar_tofile( im, "Tests/images/rectangle_surrounding_text.png", 2.5 @@ -181,7 +184,7 @@ class TestImageFont: im = Image.new(mode="RGB", size=(300, 100)) draw = ImageDraw.Draw(im) ttf = self.get_font() - line_spacing = draw.textsize("A", font=ttf)[1] + 4 + line_spacing = ttf.getbbox("A")[3] + 4 lines = TEST_TEXT.split("\n") y = 0 for line in lines: @@ -242,19 +245,39 @@ class TestImageFont: im = Image.new(mode="RGB", size=(300, 100)) draw = ImageDraw.Draw(im) - # Test that textsize() correctly connects to multiline_textsize() - assert draw.textsize(TEST_TEXT, font=ttf) == draw.multiline_textsize( - TEST_TEXT, font=ttf + with pytest.warns(DeprecationWarning) as log: + # Test that textsize() correctly connects to multiline_textsize() + assert draw.textsize(TEST_TEXT, font=ttf) == draw.multiline_textsize( + TEST_TEXT, font=ttf + ) + + # Test that multiline_textsize corresponds to ImageFont.textsize() + # for single line text + assert ttf.getsize("A") == draw.multiline_textsize("A", font=ttf) + + # Test that textsize() can pass on additional arguments + # to multiline_textsize() + draw.textsize(TEST_TEXT, font=ttf, spacing=4) + draw.textsize(TEST_TEXT, ttf, 4) + assert len(log) == 6 + + def test_multiline_bbox(self): + ttf = self.get_font() + im = Image.new(mode="RGB", size=(300, 100)) + draw = ImageDraw.Draw(im) + + # Test that textbbox() correctly connects to multiline_textbbox() + assert draw.textbbox((0, 0), TEST_TEXT, font=ttf) == draw.multiline_textbbox( + (0, 0), TEST_TEXT, font=ttf ) - # Test that multiline_textsize corresponds to ImageFont.textsize() + # Test that multiline_textbbox corresponds to ImageFont.textbbox() # for single line text - assert ttf.getsize("A") == draw.multiline_textsize("A", font=ttf) + assert ttf.getbbox("A") == draw.multiline_textbbox((0, 0), "A", font=ttf) - # Test that textsize() can pass on additional arguments - # to multiline_textsize() - draw.textsize(TEST_TEXT, font=ttf, spacing=4) - draw.textsize(TEST_TEXT, ttf, 4) + # Test that textbbox() can pass on additional arguments + # to multiline_textbbox() + draw.textbbox((0, 0), TEST_TEXT, font=ttf, spacing=4) def test_multiline_width(self): ttf = self.get_font() @@ -262,9 +285,15 @@ class TestImageFont: draw = ImageDraw.Draw(im) assert ( - draw.textsize("longest line", font=ttf)[0] - == draw.multiline_textsize("longest line\nline", font=ttf)[0] + draw.textbbox((0, 0), "longest line", font=ttf)[2] + == draw.multiline_textbbox((0, 0), "longest line\nline", font=ttf)[2] ) + with pytest.warns(DeprecationWarning) as log: + assert ( + draw.textsize("longest line", font=ttf)[0] + == draw.multiline_textsize("longest line\nline", font=ttf)[0] + ) + assert len(log) == 2 def test_multiline_spacing(self): ttf = self.get_font() @@ -286,16 +315,33 @@ class TestImageFont: # Original font draw.font = font - box_size_a = draw.textsize(word) + with pytest.warns(DeprecationWarning) as log: + box_size_a = draw.textsize(word) + assert box_size_a == font.getsize(word) + assert len(log) == 2 + bbox_a = draw.textbbox((10, 10), word) # Rotated font draw.font = transposed_font - box_size_b = draw.textsize(word) + with pytest.warns(DeprecationWarning) as log: + box_size_b = draw.textsize(word) + assert box_size_b == transposed_font.getsize(word) + assert len(log) == 2 + bbox_b = draw.textbbox((20, 20), word) # Check (w,h) of box a is (h,w) of box b assert box_size_a[0] == box_size_b[1] assert box_size_a[1] == box_size_b[0] + # Check bbox b is (20, 20, 20 + h, 20 + w) + assert bbox_b[0] == 20 + assert bbox_b[1] == 20 + assert bbox_b[2] == 20 + bbox_a[3] - bbox_a[1] + assert bbox_b[3] == 20 + bbox_a[2] - bbox_a[0] + + # text length is undefined for vertical text + pytest.raises(ValueError, draw.textlength, word) + def test_unrotated_transposed_font(self): img_grey = Image.new("L", (100, 100)) draw = ImageDraw.Draw(img_grey) @@ -307,15 +353,31 @@ class TestImageFont: # Original font draw.font = font - box_size_a = draw.textsize(word) + with pytest.warns(DeprecationWarning) as log: + box_size_a = draw.textsize(word) + assert len(log) == 1 + bbox_a = draw.textbbox((10, 10), word) + length_a = draw.textlength(word) # Rotated font draw.font = transposed_font - box_size_b = draw.textsize(word) + with pytest.warns(DeprecationWarning) as log: + box_size_b = draw.textsize(word) + assert len(log) == 1 + bbox_b = draw.textbbox((20, 20), word) + length_b = draw.textlength(word) # Check boxes a and b are same size assert box_size_a == box_size_b + # Check bbox b is (20, 20, 20 + w, 20 + h) + assert bbox_b[0] == 20 + assert bbox_b[1] == 20 + assert bbox_b[2] == 20 + bbox_a[2] - bbox_a[0] + assert bbox_b[3] == 20 + bbox_a[3] - bbox_a[1] + + assert length_a == length_b + def test_rotated_transposed_font_get_mask(self): # Arrange text = "mask this" @@ -370,9 +432,11 @@ class TestImageFont: text = "offset this" # Act - offset = font.getoffset(text) + with pytest.warns(DeprecationWarning) as log: + offset = font.getoffset(text) # Assert + assert len(log) == 1 assert offset == (0, 3) def test_free_type_font_get_mask(self): @@ -414,11 +478,11 @@ class TestImageFont: # Assert assert_image_equal_tofile(im, "Tests/images/default_font.png") - def test_getsize_empty(self): + def test_getbbox_empty(self): # issue #2614 font = self.get_font() # should not crash. - assert (0, 0) == font.getsize("") + assert (0, 0, 0, 0) == font.getbbox("") def test_render_empty(self): # issue 2666 @@ -435,7 +499,7 @@ class TestImageFont: # issue #2826 font = ImageFont.load_default() with pytest.raises(UnicodeEncodeError): - font.getsize("’") + font.getbbox("’") def test_unicode_extended(self): # issue #3777 @@ -560,17 +624,29 @@ class TestImageFont: assert t.font.x_ppem == 20 assert t.font.y_ppem == 20 assert t.font.glyphs == 4177 - assert t.getsize("A") == (12, 16) - assert t.getsize("AB") == (24, 16) - assert t.getsize("M") == (12, 16) - assert t.getsize("y") == (12, 20) - assert t.getsize("a") == (12, 16) - assert t.getsize_multiline("A") == (12, 16) - assert t.getsize_multiline("AB") == (24, 16) - assert t.getsize_multiline("a") == (12, 16) - assert t.getsize_multiline("ABC\n") == (36, 36) - assert t.getsize_multiline("ABC\nA") == (36, 36) - assert t.getsize_multiline("ABC\nAaaa") == (48, 36) + assert t.getbbox("A") == (0, 4, 12, 16) + assert t.getbbox("AB") == (0, 4, 24, 16) + assert t.getbbox("M") == (0, 4, 12, 16) + assert t.getbbox("y") == (0, 7, 12, 20) + assert t.getbbox("a") == (0, 7, 12, 16) + assert t.getlength("A") == 12 + assert t.getlength("AB") == 24 + assert t.getlength("M") == 12 + assert t.getlength("y") == 12 + assert t.getlength("a") == 12 + with pytest.warns(DeprecationWarning) as log: + assert t.getsize("A") == (12, 16) + assert t.getsize("AB") == (24, 16) + assert t.getsize("M") == (12, 16) + assert t.getsize("y") == (12, 20) + assert t.getsize("a") == (12, 16) + assert t.getsize_multiline("A") == (12, 16) + assert t.getsize_multiline("AB") == (24, 16) + assert t.getsize_multiline("a") == (12, 16) + assert t.getsize_multiline("ABC\n") == (36, 36) + assert t.getsize_multiline("ABC\nA") == (36, 36) + assert t.getsize_multiline("ABC\nAaaa") == (48, 36) + assert len(log) == 11 def test_getsize_stroke(self): # Arrange @@ -578,14 +654,22 @@ class TestImageFont: # Act / Assert for stroke_width in [0, 2]: - assert t.getsize("A", stroke_width=stroke_width) == ( - 12 + stroke_width * 2, - 16 + stroke_width * 2, - ) - assert t.getsize_multiline("ABC\nAaaa", stroke_width=stroke_width) == ( - 48 + stroke_width * 2, - 36 + stroke_width * 4, + assert t.getbbox("A", stroke_width=stroke_width) == ( + 0 - stroke_width, + 4 - stroke_width, + 12 + stroke_width, + 16 + stroke_width, ) + with pytest.warns(DeprecationWarning) as log: + assert t.getsize("A", stroke_width=stroke_width) == ( + 12 + stroke_width * 2, + 16 + stroke_width * 2, + ) + assert t.getsize_multiline("ABC\nAaaa", stroke_width=stroke_width) == ( + 48 + stroke_width * 2, + 36 + stroke_width * 4, + ) + assert len(log) == 2 def test_complex_font_settings(self): # Arrange @@ -717,8 +801,11 @@ class TestImageFont: im = Image.new("RGB", (200, 200)) d = ImageDraw.Draw(im) default_font = ImageFont.load_default() - with pytest.raises(ValueError): - d.textbbox((0, 0), "test", font=default_font) + with pytest.warns(DeprecationWarning) as log: + width, height = d.textsize("test", font=default_font) + assert len(log) == 1 + assert d.textlength("test", font=default_font) == width + assert d.textbbox((0, 0), "test", font=default_font) == (0, 0, width, height) @pytest.mark.parametrize( "anchor, left, top", @@ -865,7 +952,7 @@ class TestImageFont: def test_standard_embedded_color(self): txt = "Hello World!" ttf = ImageFont.truetype(FONT_PATH, 40, layout_engine=self.LAYOUT_ENGINE) - ttf.getsize(txt) + ttf.getbbox(txt) im = Image.new("RGB", (300, 64), "white") d = ImageDraw.Draw(im) diff --git a/Tests/test_imagefontctl.py b/Tests/test_imagefontctl.py index ffb70cf17..cf039e86e 100644 --- a/Tests/test_imagefontctl.py +++ b/Tests/test_imagefontctl.py @@ -140,8 +140,8 @@ def test_ligature_features(): target = "Tests/images/test_ligature_features.png" assert_image_similar_tofile(im, target, 0.5) - liga_size = ttf.getsize("fi", features=["-liga"]) - assert liga_size == (13, 19) + liga_bbox = ttf.getbbox("fi", features=["-liga"]) + assert liga_bbox == (0, 4, 13, 19) def test_kerning_features(): diff --git a/Tests/test_imageops.py b/Tests/test_imageops.py index 87fffa7b7..01e40e6d4 100644 --- a/Tests/test_imageops.py +++ b/Tests/test_imageops.py @@ -345,11 +345,15 @@ def test_exif_transpose(): check(orientation_im) # Orientation from "XML:com.adobe.xmp" info key - with Image.open("Tests/images/xmp_tags_orientation.png") as im: - assert im.getexif()[0x0112] == 3 + for suffix in ("", "_exiftool"): + with Image.open("Tests/images/xmp_tags_orientation" + suffix + ".png") as im: + assert im.getexif()[0x0112] == 3 - transposed_im = ImageOps.exif_transpose(im) - assert 0x0112 not in transposed_im.getexif() + transposed_im = ImageOps.exif_transpose(im) + assert 0x0112 not in transposed_im.getexif() + + transposed_im._reload_exif() + assert 0x0112 not in transposed_im.getexif() # Orientation from "Raw profile type exif" info key # This test image has been manually hexedited from exif_imagemagick.png diff --git a/Tests/test_qt_image_toqimage.py b/Tests/test_qt_image_toqimage.py index 60bfaeb9b..c1983031a 100644 --- a/Tests/test_qt_image_toqimage.py +++ b/Tests/test_qt_image_toqimage.py @@ -16,32 +16,32 @@ if ImageQt.qt_is_installed: from PIL.ImageQt import QImage -def test_sanity(tmp_path): - for mode in ("RGB", "RGBA", "L", "P", "1"): - src = hopper(mode) - data = ImageQt.toqimage(src) +@pytest.mark.parametrize("mode", ("RGB", "RGBA", "L", "P", "1")) +def test_sanity(mode, tmp_path): + src = hopper(mode) + data = ImageQt.toqimage(src) - assert isinstance(data, QImage) - assert not data.isNull() + assert isinstance(data, QImage) + assert not data.isNull() - # reload directly from the qimage - rt = ImageQt.fromqimage(data) - if mode in ("L", "P", "1"): - assert_image_equal(rt, src.convert("RGB")) - else: - assert_image_equal(rt, src) + # reload directly from the qimage + rt = ImageQt.fromqimage(data) + if mode in ("L", "P", "1"): + assert_image_equal(rt, src.convert("RGB")) + else: + assert_image_equal(rt, src) - if mode == "1": - # BW appears to not save correctly on QT4 and QT5 - # kicks out errors on console: - # libpng warning: Invalid color type/bit depth combination - # in IHDR - # libpng error: Invalid IHDR data - continue + if mode == "1": + # BW appears to not save correctly on QT5 + # kicks out errors on console: + # libpng warning: Invalid color type/bit depth combination + # in IHDR + # libpng error: Invalid IHDR data + return - # Test saving the file - tempfile = str(tmp_path / f"temp_{mode}.png") - data.save(tempfile) + # Test saving the file + tempfile = str(tmp_path / f"temp_{mode}.png") + data.save(tempfile) - # Check that it actually worked. - assert_image_equal_tofile(src, tempfile) + # Check that it actually worked. + assert_image_equal_tofile(src, tempfile) diff --git a/depends/install_imagequant.sh b/depends/install_imagequant.sh index 31fc2adaa..64dd024bd 100755 --- a/depends/install_imagequant.sh +++ b/depends/install_imagequant.sh @@ -1,7 +1,7 @@ #!/bin/bash # install libimagequant -archive=libimagequant-4.0.0 +archive=libimagequant-4.0.4 ./download-and-extract.sh $archive https://raw.githubusercontent.com/python-pillow/pillow-depends/main/$archive.tar.gz diff --git a/depends/install_openjpeg.sh b/depends/install_openjpeg.sh index 914e71e53..4f4b81a62 100755 --- a/depends/install_openjpeg.sh +++ b/depends/install_openjpeg.sh @@ -1,7 +1,7 @@ #!/bin/bash # install openjpeg -archive=openjpeg-2.4.0 +archive=openjpeg-2.5.0 ./download-and-extract.sh $archive https://raw.githubusercontent.com/python-pillow/pillow-depends/main/$archive.tar.gz diff --git a/depends/install_webp.sh b/depends/install_webp.sh index a419a7646..05867b7d4 100755 --- a/depends/install_webp.sh +++ b/depends/install_webp.sh @@ -1,7 +1,7 @@ #!/bin/bash # install webp -archive=libwebp-1.2.2 +archive=libwebp-1.2.4 ./download-and-extract.sh $archive https://raw.githubusercontent.com/python-pillow/pillow-depends/main/$archive.tar.gz diff --git a/docs/Makefile b/docs/Makefile index 0d352302f..f11d6b189 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -2,8 +2,9 @@ # # You can set these variables from the command line. +PYTHON = python3 SPHINXOPTS = -SPHINXBUILD = python3 -m sphinx.cmd.build +SPHINXBUILD = $(PYTHON) -m sphinx.cmd.build PAPER = BUILDDIR = _build @@ -42,7 +43,8 @@ clean: -rm -rf $(BUILDDIR)/* install-sphinx: - python3 -c "import sphinx" > /dev/null 2>&1 || python3 -m pip install sphinx + $(PYTHON) -c "import sphinx" > /dev/null 2>&1 || $(PYTHON) -m pip install sphinx + $(PYTHON) -c "import furo" > /dev/null 2>&1 || $(PYTHON) -m pip install furo html: $(MAKE) install-sphinx @@ -178,4 +180,4 @@ livehtml: html livereload $(BUILDDIR)/html -p 33233 serve: - cd $(BUILDDIR)/html; python3 -m http.server + cd $(BUILDDIR)/html; $(PYTHON) -m http.server diff --git a/docs/conf.py b/docs/conf.py index 2ed236b18..bc67d9368 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -68,7 +68,7 @@ release = PIL.__version__ # # This is also used if you do content translation via gettext catalogs. # Usually you set "language" from the command line for these cases. -language = None +language = "en" # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: diff --git a/docs/deprecations.rst b/docs/deprecations.rst index ad030acd0..9be92770a 100644 --- a/docs/deprecations.rst +++ b/docs/deprecations.rst @@ -170,6 +170,33 @@ in Pillow 10 (2023-07-01). Upgrade to `PyQt6 `_ or `PySide6 `_ instead. +Image.coerce_e +~~~~~~~~~~~~~~ + +.. deprecated:: 9.2.0 + +This undocumented method has been deprecated and will be removed in Pillow 10 +(2023-07-01). + +Font size and offset methods +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. deprecated:: 9.2.0 + +Several functions for computing the size and offset of rendered text +have been deprecated and will be removed in Pillow 10 (2023-07-01): + +=========================================================================== ============================================================================================================= +Deprecated Use instead +=========================================================================== ============================================================================================================= +:py:meth:`.FreeTypeFont.getsize` and :py:meth:`.FreeTypeFont.getoffset` :py:meth:`.FreeTypeFont.getbbox` and :py:meth:`.FreeTypeFont.getlength` +:py:meth:`.FreeTypeFont.getsize_multiline` :py:meth:`.ImageDraw.multiline_textbbox` +:py:meth:`.ImageFont.getsize` :py:meth:`.ImageFont.getbbox` and :py:meth:`.ImageFont.getlength` +:py:meth:`.TransposedFont.getsize` :py:meth:`.TransposedFont.getbbox` and :py:meth:`.TransposedFont.getlength` +:py:meth:`.ImageDraw.textsize` and :py:meth:`.ImageDraw.multiline_textsize` :py:meth:`.ImageDraw.textbbox`, :py:meth:`.ImageDraw.textlength` and :py:meth:`.ImageDraw.multiline_textbbox` +:py:meth:`.ImageDraw2.Draw.textsize` :py:meth:`.ImageDraw2.Draw.textbbox` and :py:meth:`.ImageDraw2.Draw.textlength` +=========================================================================== ============================================================================================================= + Removed features ---------------- diff --git a/docs/handbook/image-file-formats.rst b/docs/handbook/image-file-formats.rst index c02965a05..7db7b117a 100644 --- a/docs/handbook/image-file-formats.rst +++ b/docs/handbook/image-file-formats.rst @@ -17,9 +17,9 @@ When an image is opened from a file, only that instance of the image is consider have the format. Copies of the image will contain data loaded from the file, but not the file itself, meaning that it can no longer be considered to be in the original format. So if :py:meth:`~PIL.Image.Image.copy` is called on an image, or another method -internally creates a copy of the image, the ``fp`` (file pointer), along with any -methods and attributes specific to a format. The :py:attr:`~PIL.Image.Image.format` -attribute will be ``None``. +internally creates a copy of the image, then any methods or attributes specific to the +format will no longer be present. The ``fp`` (file pointer) attribute will no longer be +present, and the :py:attr:`~PIL.Image.Image.format` attribute will be ``None``. Fully supported formats ----------------------- @@ -101,8 +101,8 @@ GIF ^^^ Pillow reads GIF87a and GIF89a versions of the GIF file format. The library -writes LZW encoded files in GIF87a by default, unless GIF89a features -are used or GIF89a is already in use. +writes files in GIF87a by default, unless GIF89a features are used or GIF89a is +already in use. Files are written with LZW encoding. GIF files are initially read as grayscale (``L``) or palette mode (``P``) images. Seeking to later frames in a ``P`` image will change the image to @@ -156,7 +156,8 @@ The :py:meth:`~PIL.Image.open` method sets the following it will loop forever. **comment** - May not be present. A comment about the image. + May not be present. A comment about the image. This is the last comment found + before the current frame's image. **extension** May not be present. Contains application specific information. @@ -245,17 +246,14 @@ Reading local images The GIF loader creates an image memory the same size as the GIF file’s *logical screen size*, and pastes the actual pixel data (the *local image*) into this -image. If you only want the actual pixel rectangle, you can manipulate the -:py:attr:`~PIL.Image.Image.size` and :py:attr:`~PIL.ImageFile.ImageFile.tile` -attributes before loading the file:: +image. If you only want the actual pixel rectangle, you can crop the image:: im = Image.open(...) if im.tile[0][0] == "gif": # only read the first "local image" from this GIF file - tag, (x0, y0, x1, y1), offset, extra = im.tile[0] - im.size = (x1 - x0, y1 - y0) - im.tile = [(tag, (0, 0) + im.size, offset, extra)] + box = im.tile[0][1] + im = im.crop(box) ICNS ^^^^ @@ -829,11 +827,8 @@ the output format must be specified explicitly:: im.save('newimage.spi', format='SPIDER') -For more information about the SPIDER image processing package, see the -`SPIDER homepage`_ at `Wadsworth Center`_. - -.. _SPIDER homepage: https://spider.wadsworth.org/spider_doc/spider/docs/spider.html -.. _Wadsworth Center: https://www.wadsworth.org/ +For more information about the SPIDER image processing package, see +https://github.com/spider-em/SPIDER TGA ^^^ @@ -973,7 +968,7 @@ The :py:meth:`~PIL.Image.Image.save` method can take the following keyword argum methods are: :data:`None`, ``"group3"``, ``"group4"``, ``"jpeg"``, ``"lzma"``, ``"packbits"``, ``"tiff_adobe_deflate"``, ``"tiff_ccitt"``, ``"tiff_lzw"``, ``"tiff_raw_16"``, ``"tiff_sgilog"``, ``"tiff_sgilog24"``, ``"tiff_thunderscan"``, - ``"webp"`, ``"zstd"`` + ``"webp"``, ``"zstd"`` **quality** The image quality for JPEG compression, on a scale from 0 (worst) to 100 @@ -1214,6 +1209,17 @@ image when first opened. The :py:meth:`~PIL.Image.Image.seek` and :py:meth:`~PIL methods may be used to read other pictures from the file. The pictures are zero-indexed and random access is supported. +When calling :py:meth:`~PIL.Image.Image.save` to write an MPO file, by default +only the first frame of a multiframe image will be saved. If the ``save_all`` +argument is present and true, then all frames will be saved, and the following +option will also be available. + +**append_images** + A list of images to append as additional pictures. Each of the + images in the list can be single or multiframe images. + + .. versionadded:: 9.3.0 + PCD ^^^ @@ -1235,6 +1241,11 @@ PSD Pillow identifies and reads PSD files written by Adobe Photoshop 2.5 and 3.0. +SUN +^^^ + +Pillow identifies and reads Sun raster files. + WAL ^^^ @@ -1249,13 +1260,13 @@ this format. By default, a Quake2 standard palette is attached to the texture. To override the palette, use the putpalette method. -WMF -^^^ +WMF, EMF +^^^^^^^^ -Pillow can identify WMF files. +Pillow can identify WMF and EMF files. -On Windows, it can read WMF files. By default, it will load the image at 72 -dpi. To load it at another resolution: +On Windows, it can read WMF and EMF files. By default, it will load the image +at 72 dpi. To load it at another resolution: .. code-block:: python @@ -1265,7 +1276,8 @@ dpi. To load it at another resolution: im.load(dpi=144) To add other read or write support, use -:py:func:`PIL.WmfImagePlugin.register_handler` to register a WMF handler. +:py:func:`PIL.WmfImagePlugin.register_handler` to register a WMF and EMF +handler. .. code-block:: python diff --git a/docs/handbook/writing-your-own-image-plugin.rst b/docs/handbook/writing-your-own-image-plugin.rst index 80138742d..323127e5b 100644 --- a/docs/handbook/writing-your-own-image-plugin.rst +++ b/docs/handbook/writing-your-own-image-plugin.rst @@ -141,6 +141,10 @@ The fields are used as follows: uncompressed data, in a variety of pixel formats. For more information on this decoder, see the description below. + A list of C decoders can be seen under codecs section of the function array + in :file:`_imaging.c`. Python decoders are registered within the relevant + plugins. + **region** A 4-tuple specifying where to store data in the image. diff --git a/docs/index.rst b/docs/index.rst index f1a721c6a..c731e2746 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -29,6 +29,10 @@ Pillow for enterprise is available via the Tidelift Subscription. `Learn more = 9.0 | Yes | Yes | Yes | Yes | | | | | -+----------------------+-----+-----+-----+-----+-----+-----+-----+-----+ -| Pillow 8.3.2 - 8.4 | Yes | Yes | Yes | Yes | Yes | | | | -+----------------------+-----+-----+-----+-----+-----+-----+-----+-----+ -| Pillow 8.0 - 8.3.1 | | Yes | Yes | Yes | Yes | | | | -+----------------------+-----+-----+-----+-----+-----+-----+-----+-----+ -| Pillow 7.0 - 7.2 | | | Yes | Yes | Yes | Yes | | | -+----------------------+-----+-----+-----+-----+-----+-----+-----+-----+ -| Pillow 6.2.1 - 6.2.2 | | | Yes | Yes | Yes | Yes | | Yes | -+----------------------+-----+-----+-----+-----+-----+-----+-----+-----+ -| Pillow 6.0 - 6.2.0 | | | | Yes | Yes | Yes | | Yes | -+----------------------+-----+-----+-----+-----+-----+-----+-----+-----+ -| Pillow 5.2 - 5.4 | | | | Yes | Yes | Yes | Yes | Yes | -+----------------------+-----+-----+-----+-----+-----+-----+-----+-----+ +.. csv-table:: Newer versions + :file: newer-versions.csv + :header-rows: 1 -+------------------+-----+-----+-----+-----+-----+-----+-----+-----+-----+ -| Python | 3.6 | 3.5 | 3.4 | 3.3 | 3.2 | 2.7 | 2.6 | 2.5 | 2.4 | -+==================+=====+=====+=====+=====+=====+=====+=====+=====+=====+ -| Pillow 5.0 - 5.1 | Yes | Yes | Yes | | | Yes | | | | -+------------------+-----+-----+-----+-----+-----+-----+-----+-----+-----+ -| Pillow 4 | Yes | Yes | Yes | Yes | | Yes | | | | -+------------------+-----+-----+-----+-----+-----+-----+-----+-----+-----+ -| Pillow 2 - 3 | | Yes | Yes | Yes | Yes | Yes | Yes | | | -+------------------+-----+-----+-----+-----+-----+-----+-----+-----+-----+ -| Pillow < 2 | | | | | | Yes | Yes | Yes | Yes | -+------------------+-----+-----+-----+-----+-----+-----+-----+-----+-----+ +.. csv-table:: Older versions + :file: older-versions.csv + :header-rows: 1 Basic Installation ------------------ @@ -162,7 +140,7 @@ Many of Pillow's features require external libraries: * **libtiff** provides compressed TIFF functionality - * Pillow has been tested with libtiff versions **3.x** and **4.0-4.3** + * Pillow has been tested with libtiff versions **3.x** and **4.0-4.4** * **libfreetype** provides type related services @@ -181,13 +159,14 @@ Many of Pillow's features require external libraries: * **openjpeg** provides JPEG 2000 functionality. - * Pillow has been tested with openjpeg **2.0.0**, **2.1.0**, **2.3.1** and **2.4.0**. + * Pillow has been tested with openjpeg **2.0.0**, **2.1.0**, **2.3.1**, + **2.4.0** and **2.5.0**. * 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.0** + * Pillow has been tested with libimagequant **2.6-4.0.4** * Libimagequant is licensed GPLv3, which is more restrictive than the Pillow license, therefore we will not be distributing binaries with libimagequant support enabled. @@ -388,7 +367,7 @@ In Alpine, the command is:: .. Note:: ``redhat-rpm-config`` is required on Fedora 23, but not earlier versions. -Prerequisites for **Ubuntu 16.04 LTS - 20.04 LTS** are installed with:: +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 \ @@ -463,6 +442,8 @@ These platforms are built and tested for every change. +----------------------------------+----------------------------+---------------------+ | Fedora 35 | 3.10 | x86-64 | +----------------------------------+----------------------------+---------------------+ +| Fedora 36 | 3.10 | x86-64 | ++----------------------------------+----------------------------+---------------------+ | Gentoo | 3.9 | x86-64 | +----------------------------------+----------------------------+---------------------+ | macOS 11 Big Sur | 3.7, 3.8, 3.9, 3.10, 3.11, | x86-64 | @@ -472,18 +453,18 @@ These platforms are built and tested for every change. +----------------------------------+----------------------------+---------------------+ | Ubuntu Linux 20.04 LTS (Focal) | 3.7, 3.8, 3.9, 3.10, 3.11, | x86-64 | | | PyPy3 | | -| +----------------------------+---------------------+ -| | 3.8 | arm64v8, ppc64le, | -| | | s390x | +----------------------------------+----------------------------+---------------------+ -| Ubuntu Linux 22.04 LTS (Jammy) | 3.10 | x86-64 | +| Ubuntu Linux 22.04 LTS (Jammy) | 3.10 | arm64v8, ppc64le, | +| | | s390x, x86-64 | +----------------------------------+----------------------------+---------------------+ | Windows Server 2016 | 3.7 | x86-64 | +----------------------------------+----------------------------+---------------------+ | Windows Server 2022 | 3.7, 3.8, 3.9, 3.10, 3.11, | x86, x86-64 | | | PyPy3 | | | +----------------------------+---------------------+ -| | 3.9/MinGW | x86, x86-64 | +| | 3.9 (MinGW) | x86, x86-64 | +| +----------------------------+---------------------+ +| | 3.7, 3.8, 3.9 (Cygwin) | x86-64 | +----------------------------------+----------------------------+---------------------+ @@ -501,13 +482,13 @@ These platforms have been reported to work at the versions mentioned. | Operating system | | Tested Python | | Latest tested | | Tested | | | | versions | | Pillow version | | processors | +==================================+===========================+==================+==============+ -| macOS 12 Big Sur | 3.7, 3.8, 3.9, 3.10 | 9.0.1 |arm | +| macOS 12 Big Sur | 3.7, 3.8, 3.9, 3.10 | 9.2.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 | 9.0.1 |x86-64 | -| +---------------------------+------------------+--------------+ -| | 3.6 | 8.4.0 |x86-64 | +| | 3.7, 3.8, 3.9, 3.10 | 9.2.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 | | +---------------------------+------------------+ | @@ -568,6 +549,8 @@ These platforms have been reported to work at the versions mentioned. +----------------------------------+---------------------------+------------------+--------------+ | 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 | diff --git a/docs/newer-versions.csv b/docs/newer-versions.csv new file mode 100644 index 000000000..ed2369259 --- /dev/null +++ b/docs/newer-versions.csv @@ -0,0 +1,6 @@ +Python,3.11,3.10,3.9,3.8,3.7,3.6,3.5 +Pillow >= 9.3,Yes,Yes,Yes,Yes,Yes,, +Pillow 9.0 - 9.2,,Yes,Yes,Yes,Yes,, +Pillow 8.3.2 - 8.4,,Yes,Yes,Yes,Yes,Yes, +Pillow 8.0 - 8.3.1,,,Yes,Yes,Yes,Yes, +Pillow 7.0 - 7.2,,,,Yes,Yes,Yes,Yes diff --git a/docs/older-versions.csv b/docs/older-versions.csv new file mode 100644 index 000000000..6058f0524 --- /dev/null +++ b/docs/older-versions.csv @@ -0,0 +1,8 @@ +Python,3.8,3.7,3.6,3.5,3.4,3.3,3.2,2.7,2.6,2.5,2.4 +Pillow 6.2.1 - 6.2.2,Yes,Yes,Yes,Yes,,,,Yes,,, +Pillow 6.0 - 6.2.0,,Yes,Yes,Yes,,,,Yes,,, +Pillow 5.2 - 5.4,,Yes,Yes,Yes,Yes,,,Yes,,, +Pillow 5.0 - 5.1,,,Yes,Yes,Yes,,,Yes,,, +Pillow 4,,,Yes,Yes,Yes,Yes,,Yes,,, +Pillow 2 - 3,,,,Yes,Yes,Yes,Yes,Yes,Yes,, +Pillow < 2,,,,,,,,Yes,Yes,Yes,Yes \ No newline at end of file diff --git a/docs/reference/Image.rst b/docs/reference/Image.rst index 2613b6585..ed37521fd 100644 --- a/docs/reference/Image.rst +++ b/docs/reference/Image.rst @@ -123,6 +123,7 @@ methods. Unless otherwise stated, all methods return a new instance of the .. automethod:: PIL.Image.Image.alpha_composite +.. automethod:: PIL.Image.Image.apply_transparency .. automethod:: PIL.Image.Image.convert The following example converts an RGB image (linearly calibrated according to diff --git a/docs/reference/ImageDraw.rst b/docs/reference/ImageDraw.rst index b95d8d591..1ef9079fb 100644 --- a/docs/reference/ImageDraw.rst +++ b/docs/reference/ImageDraw.rst @@ -64,7 +64,7 @@ Fonts PIL can use bitmap fonts or OpenType/TrueType fonts. -Bitmap fonts are stored in PIL’s own format, where each font typically consists +Bitmap fonts are stored in PIL's own format, where each font typically consists of two files, one named .pil and the other usually named .pbm. The former contains font metrics, the latter raster data. @@ -146,6 +146,11 @@ Methods Get the current default font. + To set the default font for all future ImageDraw instances:: + + from PIL import ImageDraw, ImageFont + ImageDraw.ImageDraw.font = ImageFont.truetype("Tests/fonts/FreeMono.ttf") + :returns: An image font. .. py:method:: ImageDraw.arc(xy, start, end, fill=None, width=0) @@ -436,12 +441,14 @@ Methods .. py:method:: ImageDraw.textsize(text, font=None, spacing=4, direction=None, features=None, language=None, stroke_width=0) - Return the size of the given string, in pixels. + .. deprecated:: 9.2.0 Use :py:meth:`textlength()` to measure the offset of following text with 1/64 pixel precision. Use :py:meth:`textbbox()` to get the exact bounding box based on an anchor. + Return the size of the given string, in pixels. + .. note:: For historical reasons this function measures text height from the ascender line instead of the top, see :ref:`text-anchors`. If you wish to measure text height from the top, it is recommended @@ -484,6 +491,10 @@ Methods .. py:method:: ImageDraw.multiline_textsize(text, font=None, spacing=4, direction=None, features=None, language=None, stroke_width=0) + .. deprecated:: 9.2.0 + + Use :py:meth:`.multiline_textbbox` instead. + Return the size of the given string, in pixels. Use :py:meth:`textlength()` to measure the offset of following text with diff --git a/docs/reference/ImageFont.rst b/docs/reference/ImageFont.rst index 8efef7cfd..516fa63a7 100644 --- a/docs/reference/ImageFont.rst +++ b/docs/reference/ImageFont.rst @@ -56,6 +56,7 @@ Methods .. autoclass:: PIL.ImageFont.TransposedFont :members: + :undoc-members: Constants --------- diff --git a/docs/reference/ImageGrab.rst b/docs/reference/ImageGrab.rst index ac83b2255..3086ba8c3 100644 --- a/docs/reference/ImageGrab.rst +++ b/docs/reference/ImageGrab.rst @@ -15,7 +15,10 @@ or the clipboard to a PIL image memory. returned as an "RGBA" on macOS, or an "RGB" image otherwise. If the bounding box is omitted, the entire screen is copied. - .. versionadded:: 1.1.3 (Windows), 3.0.0 (macOS), 7.1.0 (Linux (X11)) + On Linux, if ``xdisplay`` is ``None`` then ``gnome-screenshot`` will be used if it + is installed. To capture the default X11 display instead, pass ``xdisplay=""``. + + .. versionadded:: 1.1.3 (Windows), 3.0.0 (macOS), 7.1.0 (Linux) :param bbox: What region to copy. Default is the entire screen. Note that on Windows OS, the top-left point may be negative if ``all_screens=True`` is used. diff --git a/docs/releasenotes/8.0.0.rst b/docs/releasenotes/8.0.0.rst index 2ff9b3799..fe2658047 100644 --- a/docs/releasenotes/8.0.0.rst +++ b/docs/releasenotes/8.0.0.rst @@ -174,7 +174,7 @@ Previously, if a BMP file was too large, an ``OSError`` would be raised. Now, Dark theme for docs ^^^^^^^^^^^^^^^^^^^ -The https://pillow.readthedocs.io documentation will use a dark theme if the the user has requested the system use one. Uses the ``prefers-color-scheme`` CSS media query. +The https://pillow.readthedocs.io documentation will use a dark theme if the user has requested the system use one. Uses the ``prefers-color-scheme`` CSS media query. diff --git a/docs/releasenotes/9.0.0.rst b/docs/releasenotes/9.0.0.rst index dd993d39e..a19da361a 100644 --- a/docs/releasenotes/9.0.0.rst +++ b/docs/releasenotes/9.0.0.rst @@ -45,7 +45,7 @@ Support for FreeType 2.7 has been removed; FreeType 2.8 is the minimum supported We recommend upgrading to at least `FreeType`_ 2.10.4, which fixed a severe vulnerability introduced in FreeType 2.6 (:cve:`CVE-2020-15999`). -.. _FreeType: https://www.freetype.org +.. _FreeType: https://freetype.org/ Image.show command parameter ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/docs/releasenotes/9.1.1.rst b/docs/releasenotes/9.1.1.rst new file mode 100644 index 000000000..f8b155f3d --- /dev/null +++ b/docs/releasenotes/9.1.1.rst @@ -0,0 +1,16 @@ +9.1.1 +----- + +Security +======== + +This release addresses several security problems. + +:cve:`CVE-2022-30595`: When reading a TGA file with RLE packets that cross scan lines, +Pillow reads the information past the end of the first line without deducting that +from the length of the remaining file data. This vulnerability was introduced in Pillow +9.1.0, and can cause a heap buffer overflow. + +Opening an image with a zero or negative height has been found to bypass a +decompression bomb check. This will now raise a :py:exc:`SyntaxError` instead, in turn +raising a ``PIL.UnidentifiedImageError``. diff --git a/docs/releasenotes/9.2.0.rst b/docs/releasenotes/9.2.0.rst index c38944b10..9c102f177 100644 --- a/docs/releasenotes/9.2.0.rst +++ b/docs/releasenotes/9.2.0.rst @@ -1,12 +1,6 @@ 9.2.0 ----- -Backwards Incompatible Changes -============================== - -TODO -^^^^ - Deprecations ============ @@ -31,34 +25,62 @@ FreeTypeFont.getmask2 fill parameter The undocumented ``fill`` parameter of :py:meth:`.FreeTypeFont.getmask2` has been deprecated and will be removed in Pillow 10 (2023-07-01). -API Changes -=========== +PhotoImage.paste box parameter +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -TODO -^^^^ +.. deprecated:: 9.2.0 -TODO +The ``box`` parameter is unused. It will be removed in Pillow 10.0.0 (2023-07-01). + +Image.coerce_e +^^^^^^^^^^^^^^ + +.. deprecated:: 9.2.0 + +This undocumented method has been deprecated and will be removed in Pillow 10 +(2023-07-01). + +Font size and offset methods +^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. deprecated:: 9.2.0 + +Several functions for computing the size and offset of rendered text +have been deprecated and will be removed in Pillow 10 (2023-07-01): + +=========================================================================== ============================================================================================================= +Deprecated Use instead +=========================================================================== ============================================================================================================= +:py:meth:`.FreeTypeFont.getsize` and :py:meth:`.FreeTypeFont.getoffset` :py:meth:`.FreeTypeFont.getbbox` and :py:meth:`.FreeTypeFont.getlength` +:py:meth:`.FreeTypeFont.getsize_multiline` :py:meth:`.ImageDraw.multiline_textbbox` +:py:meth:`.ImageFont.getsize` :py:meth:`.ImageFont.getbbox` and :py:meth:`.ImageFont.getlength` +:py:meth:`.TransposedFont.getsize` :py:meth:`.TransposedFont.getbbox` and :py:meth:`.TransposedFont.getlength` +:py:meth:`.ImageDraw.textsize` and :py:meth:`.ImageDraw.multiline_textsize` :py:meth:`.ImageDraw.textbbox`, :py:meth:`.ImageDraw.textlength` and :py:meth:`.ImageDraw.multiline_textbbox` +:py:meth:`.ImageDraw2.Draw.textsize` :py:meth:`.ImageDraw2.Draw.textbbox` and :py:meth:`.ImageDraw2.Draw.textlength` +=========================================================================== ============================================================================================================= API Additions ============= -TODO -^^^^ +Image.apply_transparency +^^^^^^^^^^^^^^^^^^^^^^^^ -TODO +Added :py:meth:`~PIL.Image.Image.apply_transparency`, a method to take a P mode image +with "transparency" in ``im.info``, and apply the transparency to the palette instead. +The image's palette mode will become "RGBA", and "transparency" will be removed from +``im.info``. Security ======== -TODO -^^^^ - -TODO +An additional decompression bomb check has been added for the GIF format. Other Changes ============= -TODO -^^^^ +Using gnome-screenshot on Linux +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -TODO +In :py:meth:`~PIL.ImageGrab.grab` on Linux, if ``xdisplay`` is ``None`` then +``gnome-screenshot`` will be used to capture the display if it is installed. To capture +the default X11 display instead, pass ``xdisplay=""``. diff --git a/docs/releasenotes/9.3.0.rst b/docs/releasenotes/9.3.0.rst new file mode 100644 index 000000000..7109a09f2 --- /dev/null +++ b/docs/releasenotes/9.3.0.rst @@ -0,0 +1,69 @@ +9.3.0 +----- + +Backwards Incompatible Changes +============================== + +TODO +^^^^ + +Deprecations +============ + +TODO +^^^^ + +TODO + +API Changes +=========== + +TODO +^^^^ + +TODO + +API Additions +============= + +Allow default ImageDraw font to be set +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Rather than specifying a font when calling text-related ImageDraw methods, or +setting a font on each ImageDraw instance, the default font can now be set for +all future ImageDraw operations:: + + from PIL import ImageDraw, ImageFont + ImageDraw.ImageDraw.font = ImageFont.truetype("Tests/fonts/FreeMono.ttf") + +Saving multiple MPO frames +^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Multiple MPO frames can now be saved. Using the ``save_all`` argument, all of +an image's frames will be saved to file:: + + from PIL import Image + im = Image.open("frozenpond.mpo") + im.save(out, save_all=True) + +Additional images can also be appended when saving, by combining the +``save_all`` argument with the ``append_images`` argument:: + + im.save(out, save_all=True, append_images=[im1, im2, ...]) + + +Security +======== + +TODO +^^^^ + +TODO + +Other Changes +============= + +Added DDS ATI1 and ATI2 reading +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Support has been added to read the ATI1 and ATI2 formats of DDS images. diff --git a/docs/releasenotes/index.rst b/docs/releasenotes/index.rst index db578bdb7..8c436be3b 100644 --- a/docs/releasenotes/index.rst +++ b/docs/releasenotes/index.rst @@ -14,7 +14,9 @@ expected to be backported to earlier versions. .. toctree:: :maxdepth: 2 + 9.3.0 9.2.0 + 9.1.1 9.1.0 9.0.1 9.0.0 diff --git a/setup.cfg b/setup.cfg index 82873fce9..be3bc4b4f 100644 --- a/setup.cfg +++ b/setup.cfg @@ -16,6 +16,7 @@ classifiers = Programming Language :: Python :: 3.8 Programming Language :: Python :: 3.9 Programming Language :: Python :: 3.10 + Programming Language :: Python :: 3.11 Programming Language :: Python :: Implementation :: CPython Programming Language :: Python :: Implementation :: PyPy Topic :: Multimedia :: Graphics diff --git a/setup.py b/setup.py index 2701aa1ce..a2b2c6910 100755 --- a/setup.py +++ b/setup.py @@ -15,7 +15,9 @@ import subprocess import sys import warnings -from setuptools import Extension, setup +from setuptools import Extension +from setuptools import __version__ as setuptools_version +from setuptools import setup from setuptools.command.build_ext import build_ext @@ -38,7 +40,7 @@ TIFF_ROOT = None ZLIB_ROOT = None FUZZING_BUILD = "LIB_FUZZING_ENGINE" in os.environ -if sys.platform == "win32" and sys.version_info >= (3, 11): +if sys.platform == "win32" and sys.version_info >= (3, 12): import atexit atexit.register( @@ -850,6 +852,7 @@ class pil_build_ext(build_ext): sys.platform == "win32" and sys.version_info < (3, 9) and not (PLATFORM_PYPY or PLATFORM_MINGW) + and int(setuptools_version.split(".")[0]) < 60 ): defs.append(("PILLOW_VERSION", f'"\\"{PILLOW_VERSION}\\""')) else: diff --git a/src/PIL/BmpImagePlugin.py b/src/PIL/BmpImagePlugin.py index 4dc2b93c3..7bb73fc93 100644 --- a/src/PIL/BmpImagePlugin.py +++ b/src/PIL/BmpImagePlugin.py @@ -172,10 +172,11 @@ class BmpImageFile(ImageFile.ImageFile): SUPPORTED = { 32: [ (0xFF0000, 0xFF00, 0xFF, 0x0), - (0xFF0000, 0xFF00, 0xFF, 0xFF000000), - (0xFF, 0xFF00, 0xFF0000, 0xFF000000), - (0x0, 0x0, 0x0, 0x0), (0xFF000000, 0xFF0000, 0xFF00, 0x0), + (0xFF000000, 0xFF0000, 0xFF00, 0xFF), + (0xFF, 0xFF00, 0xFF0000, 0xFF000000), + (0xFF0000, 0xFF00, 0xFF, 0xFF000000), + (0x0, 0x0, 0x0, 0x0), ], 24: [(0xFF0000, 0xFF00, 0xFF)], 16: [(0xF800, 0x7E0, 0x1F), (0x7C00, 0x3E0, 0x1F)], @@ -183,6 +184,7 @@ class BmpImageFile(ImageFile.ImageFile): MASK_MODES = { (32, (0xFF0000, 0xFF00, 0xFF, 0x0)): "BGRX", (32, (0xFF000000, 0xFF0000, 0xFF00, 0x0)): "XBGR", + (32, (0xFF000000, 0xFF0000, 0xFF00, 0xFF)): "ABGR", (32, (0xFF, 0xFF00, 0xFF0000, 0xFF000000)): "RGBA", (32, (0xFF0000, 0xFF00, 0xFF, 0xFF000000)): "BGRA", (32, (0x0, 0x0, 0x0, 0x0)): "BGRA", @@ -321,7 +323,8 @@ class BmpRleDecoder(ImageFile.PyDecoder): # align to 16-bit word boundary if self.fd.tell() % 2 != 0: self.fd.seek(1, os.SEEK_CUR) - self.set_as_raw(bytes(data), ("P", 0, self.args[-1])) + rawmode = "L" if self.mode == "L" else "P" + self.set_as_raw(bytes(data), (rawmode, 0, self.args[-1])) return -1, 0 diff --git a/src/PIL/DcxImagePlugin.py b/src/PIL/DcxImagePlugin.py index de21db8f0..aeed1e7c7 100644 --- a/src/PIL/DcxImagePlugin.py +++ b/src/PIL/DcxImagePlugin.py @@ -57,7 +57,7 @@ class DcxImageFile(PcxImageFile): break self._offset.append(offset) - self.__fp = self.fp + self._fp = self.fp self.frame = None self.n_frames = len(self._offset) self.is_animated = self.n_frames > 1 @@ -67,22 +67,13 @@ class DcxImageFile(PcxImageFile): if not self._seek_check(frame): return self.frame = frame - self.fp = self.__fp + self.fp = self._fp self.fp.seek(self._offset[frame]) PcxImageFile._open(self) def tell(self): return self.frame - def _close__fp(self): - try: - if self.__fp != self.fp: - self.__fp.close() - except AttributeError: - pass - finally: - self.__fp = None - Image.register_open(DcxImageFile.format, DcxImageFile, _accept) diff --git a/src/PIL/DdsImagePlugin.py b/src/PIL/DdsImagePlugin.py index 3a04bdb5d..bba480161 100644 --- a/src/PIL/DdsImagePlugin.py +++ b/src/PIL/DdsImagePlugin.py @@ -156,6 +156,14 @@ class DdsImageFile(ImageFile.ImageFile): elif fourcc == b"DXT5": self.pixel_format = "DXT5" n = 3 + elif fourcc == b"ATI1": + self.pixel_format = "BC4" + n = 4 + self.mode = "L" + elif fourcc == b"ATI2": + self.pixel_format = "BC5" + n = 5 + self.mode = "RGB" elif fourcc == b"BC5S": self.pixel_format = "BC5S" n = 5 diff --git a/src/PIL/FliImagePlugin.py b/src/PIL/FliImagePlugin.py index ea9503305..e13b1779c 100644 --- a/src/PIL/FliImagePlugin.py +++ b/src/PIL/FliImagePlugin.py @@ -91,7 +91,7 @@ class FliImageFile(ImageFile.ImageFile): # set things up to decode first frame self.__frame = -1 - self.__fp = self.fp + self._fp = self.fp self.__rewind = self.fp.tell() self.seek(0) @@ -125,7 +125,7 @@ class FliImageFile(ImageFile.ImageFile): def _seek(self, frame): if frame == 0: self.__frame = -1 - self.__fp.seek(self.__rewind) + self._fp.seek(self.__rewind) self.__offset = 128 else: # ensure that the previous frame was loaded @@ -136,7 +136,7 @@ class FliImageFile(ImageFile.ImageFile): self.__frame = frame # move to next frame - self.fp = self.__fp + self.fp = self._fp self.fp.seek(self.__offset) s = self.fp.read(4) @@ -153,15 +153,6 @@ class FliImageFile(ImageFile.ImageFile): def tell(self): return self.__frame - def _close__fp(self): - try: - if self.__fp != self.fp: - self.__fp.close() - except AttributeError: - pass - finally: - self.__fp = None - # # registry diff --git a/src/PIL/FpxImagePlugin.py b/src/PIL/FpxImagePlugin.py index f955b2347..a55376d0e 100644 --- a/src/PIL/FpxImagePlugin.py +++ b/src/PIL/FpxImagePlugin.py @@ -154,13 +154,16 @@ class FpxImageFile(ImageFile.ImageFile): for i in range(0, len(s), length): + x1 = min(xsize, x + xtile) + y1 = min(ysize, y + ytile) + compression = i32(s, i + 8) if compression == 0: self.tile.append( ( "raw", - (x, y, x + xtile, y + ytile), + (x, y, x1, y1), i32(s, i) + 28, (self.rawmode,), ) @@ -172,7 +175,7 @@ class FpxImageFile(ImageFile.ImageFile): self.tile.append( ( "fill", - (x, y, x + xtile, y + ytile), + (x, y, x1, y1), i32(s, i) + 28, (self.rawmode, s[12:16]), ) @@ -201,7 +204,7 @@ class FpxImageFile(ImageFile.ImageFile): self.tile.append( ( "jpeg", - (x, y, x + xtile, y + ytile), + (x, y, x1, y1), i32(s, i) + 28, (rawmode, jpegmode), ) diff --git a/src/PIL/GifImagePlugin.py b/src/PIL/GifImagePlugin.py index 9b34a3b0e..2e11df54c 100644 --- a/src/PIL/GifImagePlugin.py +++ b/src/PIL/GifImagePlugin.py @@ -102,7 +102,7 @@ class GifImageFile(ImageFile.ImageFile): p = ImagePalette.raw("RGB", p) self.global_palette = self.palette = p - self.__fp = self.fp # FIXME: hack + self._fp = self.fp # FIXME: hack self.__rewind = self.fp.tell() self._n_frames = None self._is_animated = None @@ -161,8 +161,10 @@ class GifImageFile(ImageFile.ImageFile): self.__offset = 0 self.dispose = None self.__frame = -1 - self.__fp.seek(self.__rewind) + self._fp.seek(self.__rewind) self.disposal_method = 0 + if "comment" in self.info: + del self.info["comment"] else: # ensure that the previous frame was loaded if self.tile and update_image: @@ -171,7 +173,7 @@ class GifImageFile(ImageFile.ImageFile): if frame != self.__frame + 1: raise ValueError(f"cannot seek to frame {frame}") - self.fp = self.__fp + self.fp = self._fp if self.__offset: # backup to last frame self.fp.seek(self.__offset) @@ -183,10 +185,6 @@ class GifImageFile(ImageFile.ImageFile): if not s or s == b";": raise EOFError - self.__frame = frame - - self.tile = [] - palette = None info = {} @@ -228,15 +226,21 @@ class GifImageFile(ImageFile.ImageFile): # # comment extension # + comment = b"" + + # Read this comment block while block: - if "comment" in info: - info["comment"] += block - else: - info["comment"] = block + comment += block block = self.data() + + if "comment" in info: + # If multiple comment blocks in frame, separate with \n + info["comment"] += b"\n" + comment + else: + info["comment"] = comment s = None continue - elif s[0] == 255: + elif s[0] == 255 and frame == 0: # # application extension # @@ -244,7 +248,7 @@ class GifImageFile(ImageFile.ImageFile): if block[:11] == b"NETSCAPE2.0": block = self.data() if len(block) >= 3 and block[0] == 1: - info["loop"] = i16(block, 1) + self.info["loop"] = i16(block, 1) while self.data(): pass @@ -259,6 +263,7 @@ class GifImageFile(ImageFile.ImageFile): x1, y1 = x0 + i16(s, 4), y0 + i16(s, 6) if (x1 > self.size[0] or y1 > self.size[1]) and update_image: self._size = max(x1, self.size[0]), max(y1, self.size[1]) + Image._decompression_bomb_check(self._size) frame_dispose_extent = x0, y0, x1, y1 flags = s[8] @@ -281,11 +286,15 @@ class GifImageFile(ImageFile.ImageFile): s = None if interlace is None: - # self.__fp = None + # self._fp = None raise EOFError + + self.__frame = frame if not update_image: return + self.tile = [] + if self.dispose: self.im.paste(self.dispose, self.dispose_extent) @@ -389,7 +398,9 @@ class GifImageFile(ImageFile.ImageFile): ) ] - for k in ["duration", "comment", "extension", "loop"]: + if info.get("comment"): + self.info["comment"] = info["comment"] + for k in ["duration", "extension"]: if k in info: self.info[k] = info[k] elif k in self.info: @@ -443,15 +454,6 @@ class GifImageFile(ImageFile.ImageFile): def tell(self): return self.__frame - def _close__fp(self): - try: - if self.__fp != self.fp: - self.__fp.close() - except AttributeError: - pass - finally: - self.__fp = None - # -------------------------------------------------------------------- # Write GIF files @@ -573,10 +575,14 @@ def _write_multiple_frames(im, fp, palette): im_frame = _normalize_mode(im_frame.copy()) if frame_count == 0: for k, v in im_frame.info.items(): + if k == "transparency": + continue im.encoderinfo.setdefault(k, v) - im_frame = _normalize_palette(im_frame, palette, im.encoderinfo) encoderinfo = im.encoderinfo.copy() + im_frame = _normalize_palette(im_frame, palette, encoderinfo) + if "transparency" in im_frame.info: + encoderinfo.setdefault("transparency", im_frame.info["transparency"]) if isinstance(duration, (list, tuple)): encoderinfo["duration"] = duration[frame_count] elif duration is None and "duration" in im_frame.info: @@ -715,27 +721,6 @@ def _write_local_header(fp, im, offset, flags): + o8(0) ) - if "comment" in im.encoderinfo and 1 <= len(im.encoderinfo["comment"]): - fp.write(b"!" + o8(254)) # extension intro - comment = im.encoderinfo["comment"] - if isinstance(comment, str): - comment = comment.encode() - for i in range(0, len(comment), 255): - subblock = comment[i : i + 255] - fp.write(o8(len(subblock)) + subblock) - fp.write(o8(0)) - if "loop" in im.encoderinfo: - number_of_loops = im.encoderinfo["loop"] - fp.write( - b"!" - + o8(255) # extension intro - + o8(11) - + b"NETSCAPE2.0" - + o8(3) - + o8(1) - + o16(number_of_loops) # number of loops - + o8(0) - ) include_color_table = im.encoderinfo.get("include_color_table") if include_color_table: palette_bytes = _get_palette_bytes(im) @@ -840,9 +825,18 @@ def _get_optimize(im, info): if count: used_palette_colors.append(i) - if optimise or ( - len(used_palette_colors) <= 128 - and max(used_palette_colors) > len(used_palette_colors) + if optimise or max(used_palette_colors) >= len(used_palette_colors): + return used_palette_colors + + num_palette_colors = len(im.palette.palette) // Image.getmodebands( + im.palette.mode + ) + current_palette_size = 1 << (num_palette_colors - 1).bit_length() + if ( + # check that the palette would become smaller when saved + len(used_palette_colors) <= current_palette_size // 2 + # check that the palette is not already the smallest possible size + and current_palette_size > 2 ): return used_palette_colors @@ -912,24 +906,23 @@ def _get_global_header(im, info): # https://www.matthewflickinger.com/lab/whatsinagif/bits_and_bytes.asp version = b"87a" - for extensionKey in ["transparency", "duration", "loop", "comment"]: - if info and extensionKey in info: - if (extensionKey == "duration" and info[extensionKey] == 0) or ( - extensionKey == "comment" and not (1 <= len(info[extensionKey]) <= 255) - ): - continue - version = b"89a" - break - else: - if im.info.get("version") == b"89a": - version = b"89a" + if im.info.get("version") == b"89a" or ( + info + and ( + "transparency" in info + or "loop" in info + or info.get("duration") + or info.get("comment") + ) + ): + version = b"89a" background = _get_background(im, info.get("background")) palette_bytes = _get_palette_bytes(im) color_table_size = _get_color_table_size(palette_bytes) - return [ + header = [ b"GIF" # signature + version # version + o16(im.size[0]) # canvas width @@ -942,6 +935,30 @@ def _get_global_header(im, info): # Global Color Table _get_header_palette(palette_bytes), ] + if "loop" in info: + header.append( + b"!" + + o8(255) # extension intro + + o8(11) + + b"NETSCAPE2.0" + + o8(3) + + o8(1) + + o16(info["loop"]) # number of loops + + o8(0) + ) + if info.get("comment"): + comment_block = b"!" + o8(254) # extension intro + + comment = info["comment"] + if isinstance(comment, str): + comment = comment.encode() + for i in range(0, len(comment), 255): + subblock = comment[i : i + 255] + comment_block += o8(len(subblock)) + subblock + + comment_block += o8(0) + header.append(comment_block) + return header def _write_frame_data(fp, im_frame, offset, params): diff --git a/src/PIL/ImImagePlugin.py b/src/PIL/ImImagePlugin.py index 5563da4f5..78ccfb9cf 100644 --- a/src/PIL/ImImagePlugin.py +++ b/src/PIL/ImImagePlugin.py @@ -245,7 +245,7 @@ class ImImageFile(ImageFile.ImageFile): self.__offset = offs = self.fp.tell() - self.__fp = self.fp # FIXME: hack + self._fp = self.fp # FIXME: hack if self.rawmode[:2] == "F;": @@ -294,22 +294,13 @@ class ImImageFile(ImageFile.ImageFile): size = ((self.size[0] * bits + 7) // 8) * self.size[1] offs = self.__offset + frame * size - self.fp = self.__fp + self.fp = self._fp self.tile = [("raw", (0, 0) + self.size, offs, (self.rawmode, 0, -1))] def tell(self): return self.frame - def _close__fp(self): - try: - if self.__fp != self.fp: - self.__fp.close() - except AttributeError: - pass - finally: - self.__fp = None - # # -------------------------------------------------------------------- diff --git a/src/PIL/Image.py b/src/PIL/Image.py index 99c7ba0d1..4eb2dead6 100644 --- a/src/PIL/Image.py +++ b/src/PIL/Image.py @@ -29,7 +29,6 @@ import builtins import io import logging import math -import numbers import os import re import struct @@ -432,44 +431,50 @@ def _getencoder(mode, encoder_name, args, extra=()): def coerce_e(value): - return value if isinstance(value, _E) else _E(value) + deprecate("coerce_e", 10) + return value if isinstance(value, _E) else _E(1, value) +# _E(scale, offset) represents the affine transformation scale * x + offset. +# The "data" field is named for compatibility with the old implementation, +# and should be renamed once coerce_e is removed. class _E: - def __init__(self, data): + def __init__(self, scale, data): + self.scale = scale self.data = data + def __neg__(self): + return _E(-self.scale, -self.data) + def __add__(self, other): - return _E((self.data, "__add__", coerce_e(other).data)) + if isinstance(other, _E): + return _E(self.scale + other.scale, self.data + other.data) + return _E(self.scale, self.data + other) + + __radd__ = __add__ + + def __sub__(self, other): + return self + -other + + def __rsub__(self, other): + return other + -self def __mul__(self, other): - return _E((self.data, "__mul__", coerce_e(other).data)) + if isinstance(other, _E): + return NotImplemented + return _E(self.scale * other, self.data * other) + + __rmul__ = __mul__ + + def __truediv__(self, other): + if isinstance(other, _E): + return NotImplemented + return _E(self.scale / other, self.data / other) def _getscaleoffset(expr): - stub = ["stub"] - data = expr(_E(stub)).data - try: - (a, b, c) = data # simplified syntax - if a is stub and b == "__mul__" and isinstance(c, numbers.Number): - return c, 0.0 - if a is stub and b == "__add__" and isinstance(c, numbers.Number): - return 1.0, c - except TypeError: - pass - try: - ((a, b, c), d, e) = data # full syntax - if ( - a is stub - and b == "__mul__" - and isinstance(c, numbers.Number) - and d == "__add__" - and isinstance(e, numbers.Number) - ): - return c, e - except TypeError: - pass - raise ValueError("illegal expression") + a = expr(_E(1, 0)) + return (a.scale, a.data) if isinstance(a, _E) else (0, a) # -------------------------------------------------------------------- @@ -544,8 +549,10 @@ class Image: def __exit__(self, *args): if hasattr(self, "fp") and getattr(self, "_exclusive_fp", False): - if hasattr(self, "_close__fp"): - self._close__fp() + if getattr(self, "_fp", False): + if self._fp != self.fp: + self._fp.close() + self._fp = DeferredError(ValueError("Operation on closed image")) if self.fp: self.fp.close() self.fp = None @@ -563,8 +570,10 @@ class Image: more information. """ try: - if hasattr(self, "_close__fp"): - self._close__fp() + if getattr(self, "_fp", False): + if self._fp != self.fp: + self._fp.close() + self._fp = DeferredError(ValueError("Operation on closed image")) if self.fp: self.fp.close() self.fp = None @@ -637,7 +646,7 @@ class Image: def _repr_pretty_(self, p, cycle): """IPython plain text display support""" - # Same as __repr__ but without unpredicatable id(self), + # Same as __repr__ but without unpredictable id(self), # to keep Jupyter notebook `text/plain` output stable. p.text( "<%s.%s image mode=%s size=%dx%d>" @@ -662,14 +671,9 @@ class Image: raise ValueError("Could not save to PNG for display") from e return b.getvalue() - class _ArrayData: - def __init__(self, new): - self.__array_interface__ = new - - def __array__(self, dtype=None): + @property + def __array_interface__(self): # numpy array interface support - import numpy as np - new = {} shape, typestr = _conv_type_shape(self) new["shape"] = shape @@ -681,8 +685,7 @@ class Image: new["data"] = self.tobytes("raw", "L") else: new["data"] = self.tobytes() - - return np.array(self._ArrayData(new), dtype) + return new def __getstate__(self): return [self.info, self.mode, self.size, self.getpalette(), self.tobytes()] @@ -712,6 +715,11 @@ class Image: :param encoder_name: What encoder to use. The default is to use the standard "raw" encoder. + + A list of C encoders can be seen under + codecs section of the function array in + :file:`_imaging.c`. Python encoders are + registered within the relevant plugins. :param args: Extra arguments to the encoder. :returns: A :py:class:`bytes` object. """ @@ -1324,7 +1332,7 @@ class Image: def getextrema(self): """ - Gets the the minimum and maximum pixel values for each band in + Gets the minimum and maximum pixel values for each band in the image. :returns: For a single-band image, a 2-tuple containing the @@ -1374,6 +1382,10 @@ class Image: def getexif(self): if self._exif is None: self._exif = Exif() + self._exif._loaded = False + elif self._exif._loaded: + return self._exif + self._exif._loaded = True exif_info = self.info.get("exif") if exif_info is None: @@ -1392,12 +1404,18 @@ class Image: if 0x0112 not in self._exif: xmp_tags = self.info.get("XML:com.adobe.xmp") if xmp_tags: - match = re.search(r'tiff:Orientation="([0-9])"', xmp_tags) + match = re.search(r'tiff:Orientation(="|>)([0-9])', xmp_tags) if match: - self._exif[0x0112] = int(match[1]) + self._exif[0x0112] = int(match[2]) return self._exif + def _reload_exif(self): + if self._exif is None or not self._exif._loaded: + return + self._exif._loaded = False + self.getexif() + def getim(self): """ Returns a capsule that points to the internal image memory. @@ -1430,6 +1448,28 @@ class Image: rawmode = mode return list(self.im.getpalette(mode, rawmode)) + def apply_transparency(self): + """ + If a P mode image has a "transparency" key in the info dictionary, + remove the key and apply the transparency to the palette instead. + """ + if self.mode != "P" or "transparency" not in self.info: + return + + from . import ImagePalette + + palette = self.getpalette("RGBA") + transparency = self.info["transparency"] + if isinstance(transparency, bytes): + for i, alpha in enumerate(transparency): + palette[i * 4 + 3] = alpha + else: + palette[transparency * 4 + 3] = 0 + self.palette = ImagePalette.ImagePalette("RGBA", bytes(palette)) + self.palette.dirty = 1 + + del self.info["transparency"] + def getpixel(self, xy): """ Returns the pixel value at a given position. @@ -1848,10 +1888,15 @@ class Image: if self.mode not in ("L", "P"): raise ValueError("illegal image mode") + bands = 3 + palette_mode = "RGB" if source_palette is None: if self.mode == "P": self.load() - source_palette = self.im.getpalette("RGB")[:768] + palette_mode = self.im.getpalettemode() + if palette_mode == "RGBA": + bands = 4 + source_palette = self.im.getpalette(palette_mode, palette_mode) else: # L-mode source_palette = bytearray(i // 3 for i in range(768)) @@ -1860,7 +1905,9 @@ class Image: # pick only the used colors from the palette for i, oldPosition in enumerate(dest_map): - palette_bytes += source_palette[oldPosition * 3 : oldPosition * 3 + 3] + palette_bytes += source_palette[ + oldPosition * bands : oldPosition * bands + bands + ] new_positions[oldPosition] = i # replace the palette color id of all pixel with the new id @@ -1886,19 +1933,30 @@ class Image: m_im = self.copy() m_im.mode = "P" - m_im.palette = ImagePalette.ImagePalette("RGB", palette=mapping_palette * 3) + m_im.palette = ImagePalette.ImagePalette( + palette_mode, palette=mapping_palette * bands + ) # possibly set palette dirty, then # m_im.putpalette(mapping_palette, 'L') # converts to 'P' # or just force it. # UNDONE -- this is part of the general issue with palettes - m_im.im.putpalette("RGB;L", m_im.palette.tobytes()) + m_im.im.putpalette(palette_mode + ";L", m_im.palette.tobytes()) m_im = m_im.convert("L") - # Internally, we require 768 bytes for a palette. - new_palette_bytes = palette_bytes + (768 - len(palette_bytes)) * b"\x00" - m_im.putpalette(new_palette_bytes) - m_im.palette = ImagePalette.ImagePalette("RGB", palette=palette_bytes) + # Internally, we require 256 palette entries. + new_palette_bytes = ( + palette_bytes + ((256 * bands) - len(palette_bytes)) * b"\x00" + ) + m_im.putpalette(new_palette_bytes, palette_mode) + m_im.palette = ImagePalette.ImagePalette(palette_mode, palette=palette_bytes) + + if "transparency" in self.info: + try: + m_im.info["transparency"] = dest_map.index(self.info["transparency"]) + except ValueError: + if "transparency" in m_im.info: + del m_im.info["transparency"] return m_im @@ -2838,6 +2896,10 @@ def frombuffer(mode, size, data, decoder_name="raw", *args): if args[0] in _MAPMODES: im = new(mode, (1, 1)) im = im._new(core.map_buffer(data, size, decoder_name, 0, args)) + if mode == "P": + from . import ImagePalette + + im.palette = ImagePalette.ImagePalette("RGB", im.im.getpalette("RGB")) im.readonly = 1 return im diff --git a/src/PIL/ImageCms.py b/src/PIL/ImageCms.py index 50ec3b5ef..605252d5d 100644 --- a/src/PIL/ImageCms.py +++ b/src/PIL/ImageCms.py @@ -377,7 +377,7 @@ def profileToProfile( raise PyCMSError("renderingIntent must be an integer between 0 and 3") if not isinstance(flags, int) or not (0 <= flags <= _MAX_FLAG): - raise PyCMSError("flags must be an integer between 0 and %s" + _MAX_FLAG) + raise PyCMSError(f"flags must be an integer between 0 and {_MAX_FLAG}") try: if not isinstance(inputProfile, ImageCmsProfile): diff --git a/src/PIL/ImageDraw.py b/src/PIL/ImageDraw.py index f9782bc50..e84dafb12 100644 --- a/src/PIL/ImageDraw.py +++ b/src/PIL/ImageDraw.py @@ -32,8 +32,10 @@ import math import numbers +import warnings -from . import Image, ImageColor, ImageFont +from . import Image, ImageColor +from ._deprecate import deprecate """ A simple 2D drawing interface for PIL images. @@ -44,6 +46,8 @@ directly. class ImageDraw: + font = None + def __init__(self, im, mode=None): """ Create a drawing instance. @@ -84,12 +88,16 @@ class ImageDraw: else: self.fontmode = "L" # aliasing is okay for other modes self.fill = 0 - self.font = None def getfont(self): """ Get the current default font. + To set the default font for all future ImageDraw instances:: + + from PIL import ImageDraw, ImageFont + ImageDraw.ImageDraw.font = ImageFont.truetype("Tests/fonts/FreeMono.ttf") + :returns: An image font.""" if not self.font: # FIXME: should add a font repository @@ -372,6 +380,19 @@ class ImageDraw: return text.split(split_character) + def _multiline_spacing(self, font, spacing, stroke_width): + # this can be replaced with self.textbbox(...)[3] when textsize is removed + with warnings.catch_warnings(): + warnings.filterwarnings("ignore", category=DeprecationWarning) + return ( + self.textsize( + "A", + font=font, + stroke_width=stroke_width, + )[1] + + spacing + ) + def text( self, xy, @@ -511,9 +532,7 @@ class ImageDraw: widths = [] max_width = 0 lines = self._multiline_split(text) - line_spacing = ( - self.textsize("A", font=font, stroke_width=stroke_width)[1] + spacing - ) + line_spacing = self._multiline_spacing(font, spacing, stroke_width) for line in lines: line_width = self.textlength( line, font, direction=direction, features=features, language=language @@ -573,14 +592,31 @@ class ImageDraw: stroke_width=0, ): """Get the size of a given string, in pixels.""" + deprecate("textsize", 10, "textbbox or textlength") if self._multiline_check(text): - return self.multiline_textsize( - text, font, spacing, direction, features, language, stroke_width - ) + with warnings.catch_warnings(): + warnings.filterwarnings("ignore", category=DeprecationWarning) + return self.multiline_textsize( + text, + font, + spacing, + direction, + features, + language, + stroke_width, + ) if font is None: font = self.getfont() - return font.getsize(text, direction, features, language, stroke_width) + with warnings.catch_warnings(): + warnings.filterwarnings("ignore", category=DeprecationWarning) + return font.getsize( + text, + direction, + features, + language, + stroke_width, + ) def multiline_textsize( self, @@ -592,16 +628,23 @@ class ImageDraw: language=None, stroke_width=0, ): + deprecate("multiline_textsize", 10, "multiline_textbbox") max_width = 0 lines = self._multiline_split(text) - line_spacing = ( - self.textsize("A", font=font, stroke_width=stroke_width)[1] + spacing - ) - for line in lines: - line_width, line_height = self.textsize( - line, font, spacing, direction, features, language, stroke_width - ) - max_width = max(max_width, line_width) + line_spacing = self._multiline_spacing(font, spacing, stroke_width) + with warnings.catch_warnings(): + warnings.filterwarnings("ignore", category=DeprecationWarning) + for line in lines: + line_width, line_height = self.textsize( + line, + font, + spacing, + direction, + features, + language, + stroke_width, + ) + max_width = max(max_width, line_width) return max_width, len(lines) * line_spacing - spacing def textlength( @@ -625,9 +668,16 @@ class ImageDraw: try: return font.getlength(text, mode, direction, features, language) except AttributeError: - size = self.textsize( - text, font, direction=direction, features=features, language=language - ) + deprecate("textlength support for fonts without getlength", 10) + with warnings.catch_warnings(): + warnings.filterwarnings("ignore", category=DeprecationWarning) + size = self.textsize( + text, + font, + direction=direction, + features=features, + language=language, + ) if direction == "ttb": return size[1] return size[0] @@ -667,8 +717,6 @@ class ImageDraw: if font is None: font = self.getfont() - if not isinstance(font, ImageFont.FreeTypeFont): - raise ValueError("Only supported for TrueType fonts") mode = "RGBA" if embedded_color else self.fontmode bbox = font.getbbox( text, mode, direction, features, language, stroke_width, anchor @@ -702,9 +750,7 @@ class ImageDraw: widths = [] max_width = 0 lines = self._multiline_split(text) - line_spacing = ( - self.textsize("A", font=font, stroke_width=stroke_width)[1] + spacing - ) + line_spacing = self._multiline_spacing(font, spacing, stroke_width) for line in lines: line_width = self.textlength( line, diff --git a/src/PIL/ImageDraw2.py b/src/PIL/ImageDraw2.py index 1f63110fd..2667b77dd 100644 --- a/src/PIL/ImageDraw2.py +++ b/src/PIL/ImageDraw2.py @@ -24,7 +24,10 @@ """ +import warnings + from . import Image, ImageColor, ImageDraw, ImageFont, ImagePath +from ._deprecate import deprecate class Pen: @@ -172,8 +175,35 @@ class Draw: def textsize(self, text, font): """ + .. deprecated:: 9.2.0 + Return the size of the given string, in pixels. .. seealso:: :py:meth:`PIL.ImageDraw.ImageDraw.textsize` """ - return self.draw.textsize(text, font=font.font) + deprecate("textsize", 10, "textbbox or textlength") + with warnings.catch_warnings(): + warnings.filterwarnings("ignore", category=DeprecationWarning) + return self.draw.textsize(text, font=font.font) + + def textbbox(self, xy, text, font): + """ + Returns bounding box (in pixels) of given text. + + :return: ``(left, top, right, bottom)`` bounding box + + .. seealso:: :py:meth:`PIL.ImageDraw.ImageDraw.textbbox` + """ + if self.transform: + xy = ImagePath.Path(xy) + xy.transform(self.transform) + return self.draw.textbbox(xy, text, font=font.font) + + def textlength(self, text, font): + """ + Returns length (in pixels) of given text. + This is the amount by which following text should be offset. + + .. seealso:: :py:meth:`PIL.ImageDraw.ImageDraw.textlength` + """ + return self.draw.textlength(text, font=font.font) diff --git a/src/PIL/ImageFile.py b/src/PIL/ImageFile.py index 99b77a37f..9f08493c1 100644 --- a/src/PIL/ImageFile.py +++ b/src/PIL/ImageFile.py @@ -499,9 +499,14 @@ def _save(im, fp, tile, bufsize=0): try: fh = fp.fileno() fp.flush() - exc = None - except (AttributeError, io.UnsupportedOperation) as e: - exc = e + _encode_tile(im, fp, tile, bufsize, fh) + except (AttributeError, io.UnsupportedOperation) as exc: + _encode_tile(im, fp, tile, bufsize, None, exc) + if hasattr(fp, "flush"): + fp.flush() + + +def _encode_tile(im, fp, tile, bufsize, fh, exc=None): for e, b, o, a in tile: if o > 0: fp.seek(o) @@ -526,8 +531,6 @@ def _save(im, fp, tile, bufsize=0): raise OSError(f"encoder error {s} when writing image file") from exc finally: encoder.cleanup() - if hasattr(fp, "flush"): - fp.flush() def _safe_read(fp, size): diff --git a/src/PIL/ImageFont.py b/src/PIL/ImageFont.py index 86a8ad5af..9386d0086 100644 --- a/src/PIL/ImageFont.py +++ b/src/PIL/ImageFont.py @@ -137,12 +137,17 @@ class ImageFont: def getsize(self, text, *args, **kwargs): """ + .. deprecated:: 9.2.0 + + Use :py:meth:`.getbbox` or :py:meth:`.getlength` instead. + Returns width and height (in pixels) of given text. :param text: Text to measure. :return: (width, height) """ + deprecate("getsize", 10, "getbbox or getlength") return self.font.getsize(text) def getmask(self, text, mode="", *args, **kwargs): @@ -165,6 +170,33 @@ class ImageFont: """ return self.font.getmask(text, mode) + def getbbox(self, text, *args, **kwargs): + """ + Returns bounding box (in pixels) of given text. + + .. versionadded:: 9.2.0 + + :param text: Text to render. + :param mode: Used by some graphics drivers to indicate what mode the + driver prefers; if empty, the renderer may return either + mode. Note that the mode is always a string, to simplify + C-level implementations. + + :return: ``(left, top, right, bottom)`` bounding box + """ + width, height = self.font.getsize(text) + return 0, 0, width, height + + def getlength(self, text, *args, **kwargs): + """ + Returns length (in pixels) of given text. + This is the amount by which following text should be offset. + + .. versionadded:: 9.2.0 + """ + width, height = self.font.getsize(text) + return width + ## # Wrapper for FreeType fonts. Application code should use the @@ -386,16 +418,23 @@ class FreeTypeFont: return left, top, left + width, top + height def getsize( - self, text, direction=None, features=None, language=None, stroke_width=0 + self, + text, + direction=None, + features=None, + language=None, + stroke_width=0, ): """ - Returns width and height (in pixels) of given text if rendered in font with - provided direction, features, and language. + .. deprecated:: 9.2.0 Use :py:meth:`getlength()` to measure the offset of following text with 1/64 pixel precision. Use :py:meth:`getbbox()` to get the exact bounding box based on an anchor. + Returns width and height (in pixels) of given text if rendered in font with + provided direction, features, and language. + .. note:: For historical reasons this function measures text height from the ascender line instead of the top, see :ref:`text-anchors`. If you wish to measure text height from the top, it is recommended @@ -438,6 +477,7 @@ class FreeTypeFont: :return: (width, height) """ + deprecate("getsize", 10, "getbbox or getlength") # vertical offset is added for historical reasons # see https://github.com/python-pillow/Pillow/pull/4910#discussion_r486682929 size, offset = self.font.getsize(text, "L", direction, features, language) @@ -456,6 +496,10 @@ class FreeTypeFont: stroke_width=0, ): """ + .. deprecated:: 9.2.0 + + Use :py:meth:`.ImageDraw.multiline_textbbox` instead. + Returns width and height (in pixels) of given text if rendered in font with provided direction, features, and language, while respecting newline characters. @@ -495,19 +539,26 @@ class FreeTypeFont: :return: (width, height) """ + deprecate("getsize_multiline", 10, "ImageDraw.multiline_textbbox") max_width = 0 lines = self._multiline_split(text) - line_spacing = self.getsize("A", stroke_width=stroke_width)[1] + spacing - for line in lines: - line_width, line_height = self.getsize( - line, direction, features, language, stroke_width - ) - max_width = max(max_width, line_width) + with warnings.catch_warnings(): + warnings.filterwarnings("ignore", category=DeprecationWarning) + line_spacing = self.getsize("A", stroke_width=stroke_width)[1] + spacing + for line in lines: + line_width, line_height = self.getsize( + line, direction, features, language, stroke_width + ) + max_width = max(max_width, line_width) return max_width, len(lines) * line_spacing - spacing def getoffset(self, text): """ + .. deprecated:: 9.2.0 + + Use :py:meth:`.getbbox` instead. + Returns the offset of given text. This is the gap between the starting coordinate and the first marking. Note that this gap is included in the result of :py:func:`~PIL.ImageFont.FreeTypeFont.getsize`. @@ -516,6 +567,7 @@ class FreeTypeFont: :return: A tuple of the x and y offset """ + deprecate("getoffset", 10, "getbbox") return self.font.getsize(text)[1] def getmask( @@ -711,8 +763,13 @@ class FreeTypeFont: :return: A FreeTypeFont object. """ + if font is None: + try: + font = BytesIO(self.font_bytes) + except AttributeError: + font = self.path return FreeTypeFont( - font=self.path if font is None else font, + font=font, size=self.size if size is None else size, index=self.index if index is None else index, encoding=self.encoding if encoding is None else encoding, @@ -791,7 +848,15 @@ class TransposedFont: self.orientation = orientation # any 'transpose' argument, or None def getsize(self, text, *args, **kwargs): - w, h = self.font.getsize(text) + """ + .. deprecated:: 9.2.0 + + Use :py:meth:`.getbbox` or :py:meth:`.getlength` instead. + """ + deprecate("getsize", 10, "getbbox or getlength") + with warnings.catch_warnings(): + warnings.filterwarnings("ignore", category=DeprecationWarning) + w, h = self.font.getsize(text) if self.orientation in (Image.Transpose.ROTATE_90, Image.Transpose.ROTATE_270): return h, w return w, h @@ -802,6 +867,23 @@ class TransposedFont: return im.transpose(self.orientation) return im + def getbbox(self, text, *args, **kwargs): + # TransposedFont doesn't support getmask2, move top-left point to (0, 0) + # this has no effect on ImageFont and simulates anchor="lt" for FreeTypeFont + left, top, right, bottom = self.font.getbbox(text, *args, **kwargs) + width = right - left + height = bottom - top + if self.orientation in (Image.Transpose.ROTATE_90, Image.Transpose.ROTATE_270): + return 0, 0, height, width + return 0, 0, width, height + + def getlength(self, text, *args, **kwargs): + if self.orientation in (Image.Transpose.ROTATE_90, Image.Transpose.ROTATE_270): + raise ValueError( + "text length is undefined for text rotated by 90 or 270 degrees" + ) + return self.font.getlength(text, *args, **kwargs) + def load(filename): """ @@ -824,10 +906,12 @@ def truetype(font=None, size=10, index=0, encoding="", layout_engine=None): This function loads a font object from the given file or file-like object, and creates a font object for a font of the given size. - Pillow uses FreeType to open font files. If you are opening many fonts - simultaneously on Windows, be aware that Windows limits the number of files - that can be open in C at once to 512. If you approach that limit, an + Pillow uses FreeType to open font files. On Windows, be aware that FreeType + will keep the file open as long as the FreeTypeFont object exists. Windows + limits the number of files that can be open in C at once to 512, so if many + fonts are opened simultaneously and that limit is approached, an ``OSError`` may be thrown, reporting that FreeType "cannot open resource". + A workaround would be to copy the file(s) into memory, and open that instead. This function requires the _imagingft service. diff --git a/src/PIL/ImageGrab.py b/src/PIL/ImageGrab.py index eb21ac399..38074cb1b 100644 --- a/src/PIL/ImageGrab.py +++ b/src/PIL/ImageGrab.py @@ -15,15 +15,14 @@ # See the README file for information on usage and redistribution. # +import os +import shutil +import subprocess import sys +import tempfile from . import Image -if sys.platform == "darwin": - import os - import subprocess - import tempfile - def grab(bbox=None, include_layered_windows=False, all_screens=False, xdisplay=None): if xdisplay is None: @@ -62,6 +61,18 @@ def grab(bbox=None, include_layered_windows=False, all_screens=False, xdisplay=N left, top, right, bottom = bbox im = im.crop((left - x0, top - y0, right - x0, bottom - y0)) return im + elif shutil.which("gnome-screenshot"): + fh, filepath = tempfile.mkstemp(".png") + os.close(fh) + subprocess.call(["gnome-screenshot", "-f", filepath]) + im = Image.open(filepath) + im.load() + os.unlink(filepath) + if bbox: + im_cropped = im.crop(bbox) + im.close() + return im_cropped + return im # use xdisplay=None for default display on non-win32/macOS systems if not Image.core.HAVE_XCB: raise OSError("Pillow was built without XCB support") diff --git a/src/PIL/ImageOps.py b/src/PIL/ImageOps.py index f0d4545ba..0c3f900ca 100644 --- a/src/PIL/ImageOps.py +++ b/src/PIL/ImageOps.py @@ -572,8 +572,11 @@ def solarize(image, threshold=128): def exif_transpose(image): """ - If an image has an EXIF Orientation tag, return a new image that is - transposed accordingly. Otherwise, return a copy of the image. + If an image has an EXIF Orientation tag, other than 1, return a new image + that is transposed accordingly. The new image will have the orientation + data removed. + + Otherwise, return a copy of the image. :param image: The image to transpose. :return: An image. @@ -601,10 +604,12 @@ def exif_transpose(image): "Raw profile type exif" ] = transposed_exif.tobytes().hex() elif "XML:com.adobe.xmp" in transposed_image.info: - transposed_image.info["XML:com.adobe.xmp"] = re.sub( + for pattern in ( r'tiff:Orientation="([0-9])"', - "", - transposed_image.info["XML:com.adobe.xmp"], - ) + r"([0-9])", + ): + transposed_image.info["XML:com.adobe.xmp"] = re.sub( + pattern, "", transposed_image.info["XML:com.adobe.xmp"] + ) return transposed_image return image.copy() diff --git a/src/PIL/ImageShow.py b/src/PIL/ImageShow.py index 9117f57e5..9f9a551fb 100644 --- a/src/PIL/ImageShow.py +++ b/src/PIL/ImageShow.py @@ -178,14 +178,16 @@ class MacViewer(Viewer): else: raise TypeError("Missing required argument: 'path'") subprocess.call(["open", "-a", "Preview.app", path]) - subprocess.Popen( - [ - sys.executable, - "-c", - "import os, sys, time; time.sleep(20); os.remove(sys.argv[1])", - path, - ] - ) + executable = sys.executable or shutil.which("python3") + if executable: + subprocess.Popen( + [ + executable, + "-c", + "import os, sys, time; time.sleep(20); os.remove(sys.argv[1])", + path, + ] + ) return 1 diff --git a/src/PIL/JpegImagePlugin.py b/src/PIL/JpegImagePlugin.py index 4efe6281a..a6ed223bc 100644 --- a/src/PIL/JpegImagePlugin.py +++ b/src/PIL/JpegImagePlugin.py @@ -711,7 +711,7 @@ def _save(im, fp, filename): qtables = getattr(im, "quantization", None) qtables = validate_qtables(qtables) - extra = b"" + extra = info.get("extra", b"") icc_profile = info.get("icc_profile") if icc_profile: diff --git a/src/PIL/MicImagePlugin.py b/src/PIL/MicImagePlugin.py index 9248b1b65..d4f6c90f7 100644 --- a/src/PIL/MicImagePlugin.py +++ b/src/PIL/MicImagePlugin.py @@ -62,7 +62,6 @@ class MicImageFile(TiffImagePlugin.TiffImageFile): if not self.images: raise SyntaxError("not an MIC file; no image entries") - self.__fp = self.fp self.frame = None self._n_frames = len(self.images) self.is_animated = self._n_frames > 1 @@ -89,15 +88,6 @@ class MicImageFile(TiffImagePlugin.TiffImageFile): def tell(self): return self.frame - def _close__fp(self): - try: - if self.__fp != self.fp: - self.__fp.close() - except AttributeError: - pass - finally: - self.__fp = None - # # -------------------------------------------------------------------- diff --git a/src/PIL/MpoImagePlugin.py b/src/PIL/MpoImagePlugin.py index 88c1bfcc5..5bfd8efc1 100644 --- a/src/PIL/MpoImagePlugin.py +++ b/src/PIL/MpoImagePlugin.py @@ -18,16 +18,66 @@ # See the README file for information on usage and redistribution. # -from . import Image, ImageFile, JpegImagePlugin +import itertools +import os +import struct + +from . import Image, ImageFile, ImageSequence, JpegImagePlugin, TiffImagePlugin from ._binary import i16be as i16 +from ._binary import o32le # def _accept(prefix): # return JpegImagePlugin._accept(prefix) def _save(im, fp, filename): - # Note that we can only save the current frame at present - return JpegImagePlugin._save(im, fp, filename) + JpegImagePlugin._save(im, fp, filename) + + +def _save_all(im, fp, filename): + append_images = im.encoderinfo.get("append_images", []) + if not append_images: + try: + animated = im.is_animated + except AttributeError: + animated = False + if not animated: + _save(im, fp, filename) + return + + offsets = [] + for imSequence in itertools.chain([im], append_images): + for im_frame in ImageSequence.Iterator(imSequence): + if not offsets: + # APP2 marker + im.encoderinfo["extra"] = ( + b"\xFF\xE2" + struct.pack(">H", 6 + 70) + b"MPF\0" + b" " * 70 + ) + JpegImagePlugin._save(im_frame, fp, filename) + offsets.append(fp.tell()) + else: + im_frame.save(fp, "JPEG") + offsets.append(fp.tell() - offsets[-1]) + + ifd = TiffImagePlugin.ImageFileDirectory_v2() + ifd[0xB001] = len(offsets) + + mpentries = b"" + data_offset = 0 + for i, size in enumerate(offsets): + if i == 0: + mptype = 0x030000 # Baseline MP Primary Image + else: + mptype = 0x000000 # Undefined + mpentries += struct.pack(" 1 - self.__fp = self.fp # FIXME: hack - self.__fp.seek(self.__mpoffsets[0]) # get ready to read first frame + self._fp = self.fp # FIXME: hack + self._fp.seek(self.__mpoffsets[0]) # get ready to read first frame self.__frame = 0 self.offset = 0 # for now we can only handle reading and individual frame extraction self.readonly = 1 def load_seek(self, pos): - self.__fp.seek(pos) + self._fp.seek(pos) def seek(self, frame): if not self._seek_check(frame): return - self.fp = self.__fp + self.fp = self._fp self.offset = self.__mpoffsets[frame] self.fp.seek(self.offset + 2) # skip SOI marker @@ -82,6 +132,7 @@ class MpoImageFile(JpegImagePlugin.JpegImageFile): if i16(segment) == 0xFFE1: # APP1 n = i16(self.fp.read(2)) - 2 self.info["exif"] = ImageFile._safe_read(self.fp, n) + self._reload_exif() mptype = self.mpinfo[0xB002][frame]["Attribute"]["MPType"] if mptype.startswith("Large Thumbnail"): @@ -90,6 +141,7 @@ class MpoImageFile(JpegImagePlugin.JpegImageFile): self._size = (exif[40962], exif[40963]) elif "exif" in self.info: del self.info["exif"] + self._reload_exif() self.tile = [("jpeg", (0, 0) + self.size, self.offset, (self.mode, ""))] self.__frame = frame @@ -97,15 +149,6 @@ class MpoImageFile(JpegImagePlugin.JpegImageFile): def tell(self): return self.__frame - def _close__fp(self): - try: - if self.__fp != self.fp: - self.__fp.close() - except AttributeError: - pass - finally: - self.__fp = None - @staticmethod def adopt(jpeg_instance, mpheader=None): """ @@ -131,6 +174,7 @@ class MpoImageFile(JpegImagePlugin.JpegImageFile): # Image.register_open(MpoImageFile.format, # JpegImagePlugin.jpeg_factory, _accept) Image.register_save(MpoImageFile.format, _save) +Image.register_save_all(MpoImageFile.format, _save_all) Image.register_extension(MpoImageFile.format, ".mpo") diff --git a/src/PIL/PSDraw.py b/src/PIL/PSDraw.py index 743c35f01..13b3048f6 100644 --- a/src/PIL/PSDraw.py +++ b/src/PIL/PSDraw.py @@ -86,16 +86,10 @@ class PSDraw: """ Draws a rectangle. - :param box: A 4-tuple of integers whose order and function is currently - undocumented. - - Hint: the tuple is passed into this format string: - - .. code-block:: python - - %d %d M %d %d 0 Vr\n + :param box: A tuple of four integers, specifying left, bottom, width and + height. """ - self.fp.write(b"%d %d M %d %d 0 Vr\n" % box) + self.fp.write(b"%d %d M 0 %d %d Vr\n" % box) def text(self, xy, text): """ @@ -188,10 +182,10 @@ VDI_PS = b"""\ /Vl { moveto lineto stroke } bind def /Vc { newpath 0 360 arc closepath } bind def /Vr { exch dup 0 rlineto - exch dup neg 0 exch rlineto + exch dup 0 exch rlineto exch neg 0 rlineto - 0 exch rlineto - 100 div setgray fill 0 setgray } bind def + 0 exch neg rlineto + setgray fill } bind def /Tm matrix def /Ve { Tm currentmatrix pop translate scale newpath 0 0 .5 0 360 arc closepath diff --git a/src/PIL/PcfFontFile.py b/src/PIL/PcfFontFile.py index 0556c2bbc..442ac70c4 100644 --- a/src/PIL/PcfFontFile.py +++ b/src/PIL/PcfFontFile.py @@ -84,8 +84,7 @@ class PcfFontFile(FontFile.FontFile): # # create glyph structure - for ch in range(256): - ix = encoding[ch] + for ch, ix in enumerate(encoding): if ix is not None: x, y, l, r, w, a, d, f = metrics[ix] glyph = (w, 0), (l, d - y, x + l, d), (0, 0, x, y), bitmaps[ix] @@ -219,10 +218,6 @@ class PcfFontFile(FontFile.FontFile): return bitmaps def _load_encoding(self): - - # map character code to bitmap index - encoding = [None] * 256 - fp, format, i16, i32 = self._getformat(PCF_BDF_ENCODINGS) first_col, last_col = i16(fp.read(2)), i16(fp.read(2)) @@ -232,6 +227,9 @@ class PcfFontFile(FontFile.FontFile): nencoding = (last_col - first_col + 1) * (last_row - first_row + 1) + # map character code to bitmap index + encoding = [None] * min(256, nencoding) + encoding_offsets = [i16(fp.read(2)) for _ in range(nencoding)] for i in range(first_col, len(encoding)): diff --git a/src/PIL/PcxImagePlugin.py b/src/PIL/PcxImagePlugin.py index d2e166bdd..841c18a22 100644 --- a/src/PIL/PcxImagePlugin.py +++ b/src/PIL/PcxImagePlugin.py @@ -198,7 +198,9 @@ def _save(im, fp, filename): if im.mode == "P": # colour palette fp.write(o8(12)) - fp.write(im.im.getpalette("RGB", "RGB")) # 768 bytes + palette = im.im.getpalette("RGB", "RGB") + palette += b"\x00" * (768 - len(palette)) + fp.write(palette) # 768 bytes elif im.mode == "L": # greyscale palette fp.write(o8(12)) diff --git a/src/PIL/PdfImagePlugin.py b/src/PIL/PdfImagePlugin.py index 2109a6f52..181a05b8d 100644 --- a/src/PIL/PdfImagePlugin.py +++ b/src/PIL/PdfImagePlugin.py @@ -21,6 +21,7 @@ ## import io +import math import os import time @@ -123,8 +124,26 @@ def _save(im, fp, filename, save_all=False): params = None decode = None + # + # Get image characteristics + + width, height = im.size + if im.mode == "1": - filter = "DCTDecode" + filter = "CCITTFaxDecode" + bits = 1 + params = PdfParser.PdfArray( + [ + PdfParser.PdfDict( + { + "K": -1, + "BlackIs1": True, + "Columns": width, + "Rows": height, + } + ) + ] + ) colorspace = PdfParser.PdfName("DeviceGray") procset = "ImageB" # grayscale elif im.mode == "L": @@ -161,6 +180,14 @@ def _save(im, fp, filename, save_all=False): if filter == "ASCIIHexDecode": ImageFile._save(im, op, [("hex", (0, 0) + im.size, 0, im.mode)]) + elif filter == "CCITTFaxDecode": + im.save( + op, + "TIFF", + compression="group4", + # use a single strip + strip_size=math.ceil(im.width / 8) * im.height, + ) elif filter == "DCTDecode": Image.SAVE["JPEG"](im, op, filename) elif filter == "FlateDecode": @@ -170,22 +197,24 @@ def _save(im, fp, filename, save_all=False): else: raise ValueError(f"unsupported PDF filter ({filter})") - # - # Get image characteristics - - width, height = im.size + stream = op.getvalue() + if filter == "CCITTFaxDecode": + stream = stream[8:] + filter = PdfParser.PdfArray([PdfParser.PdfName(filter)]) + else: + filter = PdfParser.PdfName(filter) existing_pdf.write_obj( image_refs[page_number], - stream=op.getvalue(), + stream=stream, Type=PdfParser.PdfName("XObject"), Subtype=PdfParser.PdfName("Image"), Width=width, # * 72.0 / resolution, Height=height, # * 72.0 / resolution, - Filter=PdfParser.PdfName(filter), + Filter=filter, BitsPerComponent=bits, Decode=decode, - DecodeParams=params, + DecodeParms=params, ColorSpace=colorspace, ) diff --git a/src/PIL/PngImagePlugin.py b/src/PIL/PngImagePlugin.py index 01b4fd9ce..442c65e6f 100644 --- a/src/PIL/PngImagePlugin.py +++ b/src/PIL/PngImagePlugin.py @@ -509,6 +509,10 @@ class PngStream(ChunkStream): # 3 absolute colorimetric s = ImageFile._safe_read(self.fp, length) + if length < 1: + if ImageFile.LOAD_TRUNCATED_IMAGES: + return s + raise ValueError("Truncated sRGB chunk") self.im_info["srgb"] = s[0] return s @@ -710,7 +714,7 @@ class PngImageFile(ImageFile.ImageFile): if not _accept(self.fp.read(8)): raise SyntaxError("not a PNG file") - self.__fp = self.fp + self._fp = self.fp self.__frame = 0 # @@ -767,7 +771,7 @@ class PngImageFile(ImageFile.ImageFile): self._close_exclusive_fp_after_loading = False self.png.save_rewind() self.__rewind_idat = self.__prepare_idat - self.__rewind = self.__fp.tell() + self.__rewind = self._fp.tell() if self.default_image: # IDAT chunk contains default image and not first animation frame self.n_frames += 1 @@ -822,7 +826,7 @@ class PngImageFile(ImageFile.ImageFile): def _seek(self, frame, rewind=False): if frame == 0: if rewind: - self.__fp.seek(self.__rewind) + self._fp.seek(self.__rewind) self.png.rewind() self.__prepare_idat = self.__rewind_idat self.im = None @@ -830,7 +834,7 @@ class PngImageFile(ImageFile.ImageFile): self.pyaccess = None self.info = self.png.im_info self.tile = self.png.im_tile - self.fp = self.__fp + self.fp = self._fp self._prev_im = None self.dispose = None self.default_image = self.info.get("default_image", False) @@ -849,7 +853,7 @@ class PngImageFile(ImageFile.ImageFile): self.im.paste(self.dispose, self.dispose_extent) self._prev_im = self.im.copy() - self.fp = self.__fp + self.fp = self._fp # advance to the next frame if self.__prepare_idat: @@ -1027,15 +1031,6 @@ class PngImageFile(ImageFile.ImageFile): else {} ) - def _close__fp(self): - try: - if self.__fp != self.fp: - self.__fp.close() - except AttributeError: - pass - finally: - self.__fp = None - # -------------------------------------------------------------------- # PNG writer diff --git a/src/PIL/PpmImagePlugin.py b/src/PIL/PpmImagePlugin.py index 1312a80d0..392771d3e 100644 --- a/src/PIL/PpmImagePlugin.py +++ b/src/PIL/PpmImagePlugin.py @@ -27,6 +27,9 @@ b_whitespace = b"\x20\x09\x0a\x0b\x0c\x0d" MODES = { # standard + b"P1": "1", + b"P2": "L", + b"P3": "RGB", b"P4": "1", b"P5": "L", b"P6": "RGB", @@ -40,7 +43,7 @@ MODES = { def _accept(prefix): - return prefix[0:1] == b"P" and prefix[1] in b"0456y" + return prefix[0:1] == b"P" and prefix[1] in b"0123456y" ## @@ -93,19 +96,17 @@ class PpmImageFile(ImageFile.ImageFile): except KeyError: raise SyntaxError("not a PPM file") - self.custom_mimetype = { - b"P4": "image/x-portable-bitmap", - b"P5": "image/x-portable-graymap", - b"P6": "image/x-portable-pixmap", - }.get(magic_number) - - if mode == "1": - self.mode = "1" - rawmode = "1;I" - else: - self.mode = rawmode = mode + if magic_number in (b"P1", b"P4"): + self.custom_mimetype = "image/x-portable-bitmap" + elif magic_number in (b"P2", b"P5"): + self.custom_mimetype = "image/x-portable-graymap" + elif magic_number in (b"P3", b"P6"): + self.custom_mimetype = "image/x-portable-pixmap" + maxval = None decoder_name = "raw" + if magic_number in (b"P1", b"P2", b"P3"): + decoder_name = "ppm_plain" for ix in range(3): token = int(self._read_token()) if ix == 0: # token is the x size @@ -113,7 +114,11 @@ class PpmImageFile(ImageFile.ImageFile): elif ix == 1: # token is the y size ysize = token if mode == "1": + self.mode = "1" + rawmode = "1;I" break + else: + self.mode = rawmode = mode elif ix == 2: # token is maxval maxval = token if not 0 < maxval < 65536: @@ -123,23 +128,156 @@ class PpmImageFile(ImageFile.ImageFile): if maxval > 255 and mode == "L": self.mode = "I" - # If maxval matches a bit depth, use the raw decoder directly - if maxval == 65535 and mode == "L": - rawmode = "I;16B" - elif maxval != 255: - decoder_name = "ppm" - args = (rawmode, 0, 1) if decoder_name == "raw" else (rawmode, maxval) + if decoder_name != "ppm_plain": + # If maxval matches a bit depth, use the raw decoder directly + if maxval == 65535 and mode == "L": + rawmode = "I;16B" + elif maxval != 255: + decoder_name = "ppm" + args = (rawmode, 0, 1) if decoder_name == "raw" else (rawmode, maxval) self._size = xsize, ysize self.tile = [(decoder_name, (0, 0, xsize, ysize), self.fp.tell(), args)] +# +# -------------------------------------------------------------------- + + +class PpmPlainDecoder(ImageFile.PyDecoder): + _pulls_fd = True + + def _read_block(self): + return self.fd.read(ImageFile.SAFEBLOCK) + + def _find_comment_end(self, block, start=0): + a = block.find(b"\n", start) + b = block.find(b"\r", start) + return min(a, b) if a * b > 0 else max(a, b) # lowest nonnegative index (or -1) + + def _ignore_comments(self, block): + if self._comment_spans: + # Finish current comment + while block: + comment_end = self._find_comment_end(block) + if comment_end != -1: + # Comment ends in this block + # Delete tail of comment + block = block[comment_end + 1 :] + break + else: + # Comment spans whole block + # So read the next block, looking for the end + block = self._read_block() + + # Search for any further comments + self._comment_spans = False + while True: + comment_start = block.find(b"#") + if comment_start == -1: + # No comment found + break + comment_end = self._find_comment_end(block, comment_start) + if comment_end != -1: + # Comment ends in this block + # Delete comment + block = block[:comment_start] + block[comment_end + 1 :] + else: + # Comment continues to next block(s) + block = block[:comment_start] + self._comment_spans = True + break + return block + + def _decode_bitonal(self): + """ + This is a separate method because in the plain PBM format, all data tokens are + exactly one byte, so the inter-token whitespace is optional. + """ + data = bytearray() + total_bytes = self.state.xsize * self.state.ysize + + while len(data) != total_bytes: + block = self._read_block() # read next block + if not block: + # eof + break + + block = self._ignore_comments(block) + + tokens = b"".join(block.split()) + for token in tokens: + if token not in (48, 49): + raise ValueError(f"Invalid token for this mode: {bytes([token])}") + data = (data + tokens)[:total_bytes] + invert = bytes.maketrans(b"01", b"\xFF\x00") + return data.translate(invert) + + def _decode_blocks(self, maxval): + data = bytearray() + max_len = 10 + out_byte_count = 4 if self.mode == "I" else 1 + out_max = 65535 if self.mode == "I" else 255 + bands = Image.getmodebands(self.mode) + total_bytes = self.state.xsize * self.state.ysize * bands * out_byte_count + + half_token = False + while len(data) != total_bytes: + block = self._read_block() # read next block + if not block: + if half_token: + block = bytearray(b" ") # flush half_token + else: + # eof + break + + block = self._ignore_comments(block) + + if half_token: + block = half_token + block # stitch half_token to new block + + tokens = block.split() + + if block and not block[-1:].isspace(): # block might split token + half_token = tokens.pop() # save half token for later + if len(half_token) > max_len: # prevent buildup of half_token + raise ValueError( + f"Token too long found in data: {half_token[:max_len + 1]}" + ) + + for token in tokens: + if len(token) > max_len: + raise ValueError( + f"Token too long found in data: {token[:max_len + 1]}" + ) + value = int(token) + if value > maxval: + raise ValueError(f"Channel value too large for this mode: {value}") + value = round(value / maxval * out_max) + data += o32(value) if self.mode == "I" else o8(value) + if len(data) == total_bytes: # finished! + break + return data + + def decode(self, buffer): + self._comment_spans = False + if self.mode == "1": + data = self._decode_bitonal() + rawmode = "1;8" + else: + maxval = self.args[-1] + data = self._decode_blocks(maxval) + rawmode = "I;32" if self.mode == "I" else self.mode + self.set_as_raw(bytes(data), rawmode) + return -1, 0 + + class PpmDecoder(ImageFile.PyDecoder): _pulls_fd = True def decode(self, buffer): data = bytearray() - maxval = min(self.args[-1], 65535) + maxval = self.args[-1] in_byte_count = 1 if maxval < 256 else 2 out_byte_count = 4 if self.mode == "I" else 1 out_max = 65535 if self.mode == "I" else 255 @@ -156,7 +294,7 @@ class PpmDecoder(ImageFile.PyDecoder): value = min(out_max, round(value / maxval * out_max)) data += o32(value) if self.mode == "I" else o8(value) rawmode = "I;32" if self.mode == "I" else self.mode - self.set_as_raw(bytes(data), (rawmode, 0, 1)) + self.set_as_raw(bytes(data), rawmode) return -1, 0 @@ -197,6 +335,7 @@ Image.register_open(PpmImageFile.format, PpmImageFile, _accept) Image.register_save(PpmImageFile.format, _save) Image.register_decoder("ppm", PpmDecoder) +Image.register_decoder("ppm_plain", PpmPlainDecoder) Image.register_extensions(PpmImageFile.format, [".pbm", ".pgm", ".ppm", ".pnm"]) diff --git a/src/PIL/PsdImagePlugin.py b/src/PIL/PsdImagePlugin.py index dd755ed15..bd10e3b95 100644 --- a/src/PIL/PsdImagePlugin.py +++ b/src/PIL/PsdImagePlugin.py @@ -75,6 +75,9 @@ class PsdImageFile(ImageFile.ImageFile): if channels > psd_channels: raise OSError("not enough channels") + if mode == "RGB" and psd_channels == 4: + mode = "RGBA" + channels = 4 self.mode = mode self._size = i32(s, 18), i32(s, 14) @@ -132,7 +135,7 @@ class PsdImageFile(ImageFile.ImageFile): self.tile = _maketile(self.fp, mode, (0, 0) + self.size, channels) # keep the file open - self.__fp = self.fp + self._fp = self.fp self.frame = 1 self._min_frame = 1 @@ -146,7 +149,7 @@ class PsdImageFile(ImageFile.ImageFile): self.mode = mode self.tile = tile self.frame = layer - self.fp = self.__fp + self.fp = self._fp return name, bbox except IndexError as e: raise EOFError("no such layer") from e @@ -155,15 +158,6 @@ class PsdImageFile(ImageFile.ImageFile): # return layer number (0=image, 1..max=layers) return self.frame - def _close__fp(self): - try: - if self.__fp != self.fp: - self.__fp.close() - except AttributeError: - pass - finally: - self.__fp = None - def _layerinfo(fp, ct_bytes): # read layerinfo block diff --git a/src/PIL/SpiderImagePlugin.py b/src/PIL/SpiderImagePlugin.py index 1a72f5c04..acafc320e 100644 --- a/src/PIL/SpiderImagePlugin.py +++ b/src/PIL/SpiderImagePlugin.py @@ -15,7 +15,7 @@ # ## -# Image plugin for the Spider image format. This format is is used +# Image plugin for the Spider image format. This format is used # by the SPIDER software, in processing image data from electron # microscopy and tomography. ## @@ -149,7 +149,7 @@ class SpiderImageFile(ImageFile.ImageFile): self.mode = "F" self.tile = [("raw", (0, 0) + self.size, offset, (self.rawmode, 0, 1))] - self.__fp = self.fp # FIXME: hack + self._fp = self.fp # FIXME: hack @property def n_frames(self): @@ -172,7 +172,7 @@ class SpiderImageFile(ImageFile.ImageFile): if not self._seek_check(frame): return self.stkoffset = self.hdrlen + frame * (self.hdrlen + self.imgbytes) - self.fp = self.__fp + self.fp = self._fp self.fp.seek(self.stkoffset) self._open() @@ -191,15 +191,6 @@ class SpiderImageFile(ImageFile.ImageFile): return ImageTk.PhotoImage(self.convert2byte(), palette=256) - def _close__fp(self): - try: - if self.__fp != self.fp: - self.__fp.close() - except AttributeError: - pass - finally: - self.__fp = None - # -------------------------------------------------------------------- # Image series diff --git a/src/PIL/TiffImagePlugin.py b/src/PIL/TiffImagePlugin.py index 99d15e649..da33cc5a5 100644 --- a/src/PIL/TiffImagePlugin.py +++ b/src/PIL/TiffImagePlugin.py @@ -1073,7 +1073,7 @@ class TiffImageFile(ImageFile.ImageFile): # setup frame pointers self.__first = self.__next = self.tag_v2.next self.__frame = -1 - self.__fp = self.fp + self._fp = self.fp self._frame_pos = [] self._n_frames = None @@ -1106,7 +1106,7 @@ class TiffImageFile(ImageFile.ImageFile): self.im = Image.core.new(self.mode, self.size) def _seek(self, frame): - self.fp = self.__fp + self.fp = self._fp # reset buffered io handle in case fp # was passed to libtiff, invalidating the buffer @@ -1136,6 +1136,7 @@ class TiffImageFile(ImageFile.ImageFile): self.__frame += 1 self.fp.seek(self._frame_pos[frame]) self.tag_v2.load(self.fp) + self._reload_exif() # fill the legacy tag/ifd entries self.tag = self.ifd = ImageFileDirectory_v1.from_v2(self.tag_v2) self.__frame = frame @@ -1515,15 +1516,6 @@ class TiffImageFile(ImageFile.ImageFile): self._tile_orientation = self.tag_v2.get(0x0112) - def _close__fp(self): - try: - if self.__fp != self.fp: - self.__fp.close() - except AttributeError: - pass - finally: - self.__fp = None - # # -------------------------------------------------------------------- @@ -1568,7 +1560,13 @@ def _save(im, fp, filename): encoderinfo = im.encoderinfo encoderconfig = im.encoderconfig - compression = encoderinfo.get("compression", im.info.get("compression")) + try: + compression = encoderinfo["compression"] + except KeyError: + compression = im.info.get("compression") + if isinstance(compression, int): + # compression value may be from BMP. Ignore it + compression = None if compression is None: compression = "raw" elif compression == "tiff_jpeg": @@ -1676,12 +1674,18 @@ def _save(im, fp, filename): if im.mode in ["P", "PA"]: lut = im.im.getpalette("RGB", "RGB;L") - ifd[COLORMAP] = tuple(v * 256 for v in lut) + colormap = [] + colors = len(lut) // 3 + for i in range(3): + colormap += [v * 256 for v in lut[colors * i : colors * (i + 1)]] + colormap += [0] * (256 - colors) + ifd[COLORMAP] = colormap # data orientation stride = len(bits) * ((im.size[0] * bits[0] + 7) // 8) # aim for given strip size (64 KB by default) when using libtiff writer if libtiff: - rows_per_strip = 1 if stride == 0 else min(STRIP_SIZE // stride, im.size[1]) + im_strip_size = encoderinfo.get("strip_size", STRIP_SIZE) + rows_per_strip = 1 if stride == 0 else min(im_strip_size // stride, im.size[1]) # JPEG encoder expects multiple of 8 rows if compression == "jpeg": rows_per_strip = min(((rows_per_strip + 7) // 8) * 8, im.size[1]) diff --git a/src/PIL/_version.py b/src/PIL/_version.py index 66cb16064..8e736a432 100644 --- a/src/PIL/_version.py +++ b/src/PIL/_version.py @@ -1,2 +1,2 @@ # Master version for Pillow -__version__ = "9.2.0.dev0" +__version__ = "9.3.0.dev0" diff --git a/src/libImaging/Convert.c b/src/libImaging/Convert.c index ba57deca1..f0d42f7ff 100644 --- a/src/libImaging/Convert.c +++ b/src/libImaging/Convert.c @@ -1026,12 +1026,20 @@ pa2l(UINT8 *out, const UINT8 *in, int xsize, ImagingPalette palette) { } } +static void +pa2p(UINT8 *out, const UINT8 *in, int xsize, ImagingPalette palette) { + int x; + for (x = 0; x < xsize; x++, in += 4) { + *out++ = in[0]; + } +} + static void p2pa(UINT8 *out, const UINT8 *in, int xsize, ImagingPalette palette) { int x; int rgb = strcmp(palette->mode, "RGB"); for (x = 0; x < xsize; x++, in++) { - const UINT8 *rgba = &palette->palette[in[0]]; + const UINT8 *rgba = &palette->palette[in[0] * 4]; *out++ = in[0]; *out++ = in[0]; *out++ = in[0]; @@ -1209,6 +1217,8 @@ frompalette(Imaging imOut, Imaging imIn, const char *mode) { convert = alpha ? pa2l : p2l; } else if (strcmp(mode, "LA") == 0) { convert = alpha ? pa2la : p2la; + } else if (strcmp(mode, "P") == 0) { + convert = pa2p; } else if (strcmp(mode, "PA") == 0) { convert = p2pa; } else if (strcmp(mode, "I") == 0) { @@ -1233,6 +1243,10 @@ frompalette(Imaging imOut, Imaging imIn, const char *mode) { if (!imOut) { return NULL; } + if (strcmp(mode, "P") == 0) { + ImagingPaletteDelete(imOut->palette); + imOut->palette = ImagingPaletteDuplicate(imIn->palette); + } ImagingSectionEnter(&cookie); for (y = 0; y < imIn->ysize; y++) { diff --git a/src/libImaging/Draw.c b/src/libImaging/Draw.c index 86cd6c3a0..77343e583 100644 --- a/src/libImaging/Draw.c +++ b/src/libImaging/Draw.c @@ -419,7 +419,7 @@ draw_horizontal_lines( if (e[i].ymin == y && e[i].ymin == e[i].ymax) { int xmax; int xmin = e[i].xmin; - if (*x_pos < xmin) { + if (*x_pos != -1 && *x_pos < xmin) { // Line would be after the current position continue; } @@ -513,7 +513,9 @@ polygon_generic(Imaging im, int n, Edge *e, int ink, int eofill, hline_handler h continue; } // Check if the two edges join to make a corner - if (xx[j-1] == (ymin - other_edge->y0) * other_edge->dx + other_edge->x0) { + if (((ymin == current->ymin && ymin == other_edge->ymin) || + (ymin == current->ymax && ymin == other_edge->ymax)) && + xx[j-1] == (ymin - other_edge->y0) * other_edge->dx + other_edge->x0) { // Determine points from the edges on the next row // Or if this is the last row, check the previous row int offset = ymin == ymax ? -1 : 1; @@ -540,7 +542,7 @@ polygon_generic(Imaging im, int n, Edge *e, int ink, int eofill, hline_handler h } qsort(xx, j, sizeof(float), x_cmp); if (hasAlpha == 1) { - int x_pos = 0; + int x_pos = j == 0 ? -1 : 0; for (i = 1; i < j; i += 2) { int x_end = ROUND_DOWN(xx[i]); if (x_end < x_pos) { diff --git a/src/libImaging/GifDecode.c b/src/libImaging/GifDecode.c index 0be4771cd..92b2607b4 100644 --- a/src/libImaging/GifDecode.c +++ b/src/libImaging/GifDecode.c @@ -125,7 +125,7 @@ ImagingGifDecode(Imaging im, ImagingCodecState state, UINT8 *buffer, Py_ssize_t context->blocksize--; - /* New bits are shifted in from from the left. */ + /* New bits are shifted in from the left. */ context->bitbuffer |= (INT32)c << context->bitcount; context->bitcount += 8; diff --git a/src/libImaging/Jpeg2KDecode.c b/src/libImaging/Jpeg2KDecode.c index 8f27d87d8..cff30e2d0 100644 --- a/src/libImaging/Jpeg2KDecode.c +++ b/src/libImaging/Jpeg2KDecode.c @@ -180,11 +180,13 @@ j2ku_gray_i( case 2: for (y = 0; y < h; ++y) { const UINT16 *data = (const UINT16 *)&tiledata[2 * y * w]; - UINT8 *row = (UINT8 *)im->image[y0 + y] + x0; + UINT16 *row = (UINT16 *)im->image[y0 + y] + x0; for (x = 0; x < w; ++x) { UINT16 pixel = j2ku_shift(offset + *data++, shift); + #ifdef WORDS_BIGENDIAN + pixel = (pixel >> 8) | (pixel << 8); + #endif *row++ = pixel; - *row++ = pixel >> 8; } } break; diff --git a/src/libImaging/Palette.c b/src/libImaging/Palette.c index 20c6bc84b..71a095c2c 100644 --- a/src/libImaging/Palette.c +++ b/src/libImaging/Palette.c @@ -200,15 +200,15 @@ ImagingPaletteCacheUpdate(ImagingPalette palette, int r, int g, int b) { /* Find min and max distances to any point in the box */ r = palette->palette[i * 4 + 0]; - tmin = (r < r0) ? RDIST(r, r1) : (r > r1) ? RDIST(r, r0) : 0; + tmin = (r < r0) ? RDIST(r, r0) : (r > r1) ? RDIST(r, r1) : 0; tmax = (r <= rc) ? RDIST(r, r1) : RDIST(r, r0); g = palette->palette[i * 4 + 1]; - tmin += (g < g0) ? GDIST(g, g1) : (g > g1) ? GDIST(g, g0) : 0; + tmin += (g < g0) ? GDIST(g, g0) : (g > g1) ? GDIST(g, g1) : 0; tmax += (g <= gc) ? GDIST(g, g1) : GDIST(g, g0); b = palette->palette[i * 4 + 2]; - tmin += (b < b0) ? BDIST(b, b1) : (b > b1) ? BDIST(b, b0) : 0; + tmin += (b < b0) ? BDIST(b, b0) : (b > b1) ? BDIST(b, b1) : 0; tmax += (b <= bc) ? BDIST(b, b1) : BDIST(b, b0); dmin[i] = tmin; diff --git a/src/libImaging/Quant.c b/src/libImaging/Quant.c index 1c6b9d6a2..dfa6d842d 100644 --- a/src/libImaging/Quant.c +++ b/src/libImaging/Quant.c @@ -1519,7 +1519,7 @@ error_0: typedef struct { Pixel new; - Pixel furthest; + uint32_t furthestV; uint32_t furthestDistance; int secondPixel; } DistanceData; @@ -1536,7 +1536,7 @@ compute_distances(const HashTable *h, const Pixel pixel, uint32_t *dist, void *u } if (oldDist > data->furthestDistance) { data->furthestDistance = oldDist; - data->furthest.v = pixel.v; + data->furthestV = pixel.v; } } @@ -1577,10 +1577,11 @@ quantize2( data.new.c.b = (int)(.5 + (double)mean[2] / (double)nPixels); for (i = 0; i < nQuantPixels; i++) { data.furthestDistance = 0; + data.furthestV = pixelData[0].v; data.secondPixel = (i == 1) ? 1 : 0; hashtable_foreach_update(h, compute_distances, &data); - p[i].v = data.furthest.v; - data.new.v = data.furthest.v; + p[i].v = data.furthestV; + data.new.v = data.furthestV; } hashtable_free(h); diff --git a/src/libImaging/TgaRleDecode.c b/src/libImaging/TgaRleDecode.c index df430c940..95ae9b622 100644 --- a/src/libImaging/TgaRleDecode.c +++ b/src/libImaging/TgaRleDecode.c @@ -120,6 +120,7 @@ ImagingTgaRleDecode(Imaging im, ImagingCodecState state, UINT8 *buf, Py_ssize_t } memcpy(state->buffer + state->x, ptr, n); ptr += n; + bytes -= n; extra_bytes -= n; } } diff --git a/src/libImaging/TiffDecode.c b/src/libImaging/TiffDecode.c index f818f19d5..3bb444c80 100644 --- a/src/libImaging/TiffDecode.c +++ b/src/libImaging/TiffDecode.c @@ -815,11 +815,11 @@ ImagingLibTiffMergeFieldInfo( // custom fields added with ImagingLibTiffMergeFieldInfo are only used for // decoding, ignore readcount; - int readcount = 1; + int readcount = is_var_length ? TIFF_VARIABLE : 1; // we support writing a single value, or a variable number of values - int writecount = 1; + int writecount = is_var_length ? TIFF_VARIABLE : 1; // whether the first value should encode the number of values. - int passcount = 0; + int passcount = (is_var_length && field_type != TIFF_ASCII) ? 1 : 0; TIFFFieldInfo info[] = { {key, @@ -831,14 +831,6 @@ ImagingLibTiffMergeFieldInfo( passcount, "CustomField"}}; - if (is_var_length) { - info[0].field_writecount = -1; - } - - if (is_var_length && field_type != TIFF_ASCII) { - info[0].field_passcount = 1; - } - n = sizeof(info) / sizeof(info[0]); // Test for libtiff 4.0 or later, excluding libtiff 3.9.6 and 3.9.7 diff --git a/src/thirdparty/fribidi-shim/fribidi.c b/src/thirdparty/fribidi-shim/fribidi.c index 04491e17f..5663da86b 100644 --- a/src/thirdparty/fribidi-shim/fribidi.c +++ b/src/thirdparty/fribidi-shim/fribidi.c @@ -33,6 +33,7 @@ static void fribidi_get_bracket_types_compat( int load_fribidi(void) { int error = 0; + const char **p_fribidi_version_info = 0; p_fribidi = 0; @@ -87,20 +88,21 @@ int load_fribidi(void) { LOAD_FUNCTION(fribidi_get_par_embedding_levels); #ifndef _WIN32 - fribidi_version_info = *(const char**)dlsym(p_fribidi, "fribidi_version_info"); - if (error || (fribidi_version_info == 0)) { + p_fribidi_version_info = (const char**)dlsym(p_fribidi, "fribidi_version_info"); + if (error || (p_fribidi_version_info == 0) || (*p_fribidi_version_info == 0)) { dlclose(p_fribidi); p_fribidi = 0; return 2; } #else - fribidi_version_info = *(const char**)GetProcAddress(p_fribidi, "fribidi_version_info"); - if (error || (fribidi_version_info == 0)) { + p_fribidi_version_info = (const char**)GetProcAddress(p_fribidi, "fribidi_version_info"); + if (error || (p_fribidi_version_info == 0) || (*p_fribidi_version_info == 0)) { FreeLibrary(p_fribidi); p_fribidi = 0; return 2; } #endif + fribidi_version_info = *p_fribidi_version_info; return 0; } diff --git a/tox.ini b/tox.ini index 09db05884..21b5d4b50 100644 --- a/tox.ini +++ b/tox.ini @@ -6,7 +6,7 @@ [tox] envlist = lint - py{37,38,39,310,py3} + py{37,38,39,310,311,py3} minversion = 1.9 [testenv] diff --git a/winbuild/build.rst b/winbuild/build.rst index 661c5a5ec..716669771 100644 --- a/winbuild/build.rst +++ b/winbuild/build.rst @@ -42,9 +42,8 @@ behaviour of ``build_prepare.py``: If ``PYTHON`` is unset, the version of Python used to run ``build_prepare.py`` will be used. If only ``PYTHON`` is set, ``EXECUTABLE`` defaults to ``python.exe``. -* ``ARCHITECTURE`` is used to select a ``x86``, ``x64`` or ``ARM64``build. +* ``ARCHITECTURE`` is used to select a ``x86``, ``x64`` or ``ARM64`` build. By default, uses same architecture as the version of Python used to run ``build_prepare.py``. - is used. * ``PILLOW_BUILD`` can be used to override the ``winbuild\build`` directory path, used to store generated build scripts and compiled libraries. **Warning:** This directory is wiped when ``build_prepare.py`` is run. @@ -91,8 +90,8 @@ Some binary dependencies (e.g. ``fribidi.dll``) will be stored in the ``winbuild\build\bin`` directory; this directory should be added to ``PATH`` before running tests. -Build and install Pillow, then run ``python -m pytest Tests`` -from the root Pillow directory. +Build and install Pillow, then run ``python3 -m pytest`` from the root Pillow +directory. Example ------- diff --git a/winbuild/build_prepare.py b/winbuild/build_prepare.py index c5fcd62ff..94e5dd871 100644 --- a/winbuild/build_prepare.py +++ b/winbuild/build_prepare.py @@ -89,7 +89,7 @@ def cmd_msbuild( ) -SF_MIRROR = "https://iweb.dl.sourceforge.net" +SF_PROJECTS = "https://sourceforge.net/projects" architectures = { "x86": {"vcvars_arch": "x86", "msbuild_arch": "Win32"}, @@ -107,9 +107,10 @@ header = [ # dependencies, listed in order of compilation deps = { "libjpeg": { - "url": SF_MIRROR + "/project/libjpeg-turbo/2.1.3/libjpeg-turbo-2.1.3.tar.gz", - "filename": "libjpeg-turbo-2.1.3.tar.gz", - "dir": "libjpeg-turbo-2.1.3", + "url": SF_PROJECTS + + "/libjpeg-turbo/files/2.1.4/libjpeg-turbo-2.1.4.tar.gz/download", + "filename": "libjpeg-turbo-2.1.4.tar.gz", + "dir": "libjpeg-turbo-2.1.4", "build": [ cmd_cmake( [ @@ -143,9 +144,9 @@ deps = { "libs": [r"*.lib"], }, "libtiff": { - "url": "https://download.osgeo.org/libtiff/tiff-4.3.0.tar.gz", - "filename": "tiff-4.3.0.tar.gz", - "dir": "tiff-4.3.0", + "url": "https://download.osgeo.org/libtiff/tiff-4.4.0.tar.gz", + "filename": "tiff-4.4.0.tar.gz", + "dir": "tiff-4.4.0", "build": [ cmd_cmake("-DBUILD_SHARED_LIBS:BOOL=OFF"), cmd_nmake(target="clean"), @@ -156,9 +157,9 @@ deps = { # "bins": [r"libtiff\*.dll"], }, "libwebp": { - "url": "http://downloads.webmproject.org/releases/webp/libwebp-1.2.2.tar.gz", - "filename": "libwebp-1.2.2.tar.gz", - "dir": "libwebp-1.2.2", + "url": "http://downloads.webmproject.org/releases/webp/libwebp-1.2.4.tar.gz", + "filename": "libwebp-1.2.4.tar.gz", + "dir": "libwebp-1.2.4", "build": [ cmd_rmdir(r"output\release-static"), # clean cmd_nmake( @@ -172,7 +173,7 @@ deps = { "libs": [r"output\release-static\{architecture}\lib\*.lib"], }, "libpng": { - "url": SF_MIRROR + "/project/libpng/libpng16/1.6.37/lpng1637.zip", + "url": SF_PROJECTS + "/libpng/files/libpng16/1.6.37/lpng1637.zip/download", "filename": "lpng1637.zip", "dir": "lpng1637", "build": [ @@ -221,40 +222,40 @@ deps = { # "bins": [r"objs\{msbuild_arch}\Release\freetype.dll"], }, "lcms2": { - "url": SF_MIRROR + "/project/lcms/lcms/2.13/lcms2-2.13.1.tar.gz", + "url": SF_PROJECTS + "/lcms/files/lcms/2.13/lcms2-2.13.1.tar.gz/download", "filename": "lcms2-2.13.1.tar.gz", "dir": "lcms2-2.13.1", "patch": { - r"Projects\VC2019\lcms2_static\lcms2_static.vcxproj": { + r"Projects\VC2022\lcms2_static\lcms2_static.vcxproj": { # default is /MD for x86 and /MT for x64, we need /MD always "MultiThreaded": "MultiThreadedDLL", # noqa: E501 # retarget to default toolset (selected by vcvarsall.bat) - "v142": "$(DefaultPlatformToolset)", # noqa: E501 + "v143": "$(DefaultPlatformToolset)", # noqa: E501 # retarget to latest (selected by vcvarsall.bat) "10.0": "$(WindowsSDKVersion)", # noqa: E501 } }, "build": [ cmd_rmdir("Lib"), - cmd_rmdir(r"Projects\VC2019\Release"), - cmd_msbuild(r"Projects\VC2019\lcms2.sln", "Release", "Clean"), + cmd_rmdir(r"Projects\VC2022\Release"), + cmd_msbuild(r"Projects\VC2022\lcms2.sln", "Release", "Clean"), cmd_msbuild( - r"Projects\VC2019\lcms2.sln", "Release", "lcms2_static:Rebuild" + r"Projects\VC2022\lcms2.sln", "Release", "lcms2_static:Rebuild" ), cmd_xcopy("include", "{inc_dir}"), ], "libs": [r"Lib\MS\*.lib"], }, "openjpeg": { - "url": "https://github.com/uclouvain/openjpeg/archive/v2.4.0.tar.gz", - "filename": "openjpeg-2.4.0.tar.gz", - "dir": "openjpeg-2.4.0", + "url": "https://github.com/uclouvain/openjpeg/archive/v2.5.0.tar.gz", + "filename": "openjpeg-2.5.0.tar.gz", + "dir": "openjpeg-2.5.0", "build": [ cmd_cmake(("-DBUILD_THIRDPARTY:BOOL=OFF", "-DBUILD_SHARED_LIBS:BOOL=OFF")), cmd_nmake(target="clean"), cmd_nmake(target="openjp2"), - cmd_mkdir(r"{inc_dir}\openjpeg-2.4.0"), - cmd_copy(r"src\lib\openjp2\*.h", r"{inc_dir}\openjpeg-2.4.0"), + cmd_mkdir(r"{inc_dir}\openjpeg-2.5.0"), + cmd_copy(r"src\lib\openjp2\*.h", r"{inc_dir}\openjpeg-2.5.0"), ], "libs": [r"bin\*.lib"], }, @@ -280,9 +281,9 @@ deps = { "libs": [r"imagequant.lib"], }, "harfbuzz": { - "url": "https://github.com/harfbuzz/harfbuzz/archive/4.2.1.zip", - "filename": "harfbuzz-4.2.1.zip", - "dir": "harfbuzz-4.2.1", + "url": "https://github.com/harfbuzz/harfbuzz/archive/5.1.0.zip", + "filename": "harfbuzz-5.1.0.zip", + "dir": "harfbuzz-5.1.0", "build": [ cmd_cmake("-DHB_HAVE_FREETYPE:BOOL=TRUE"), cmd_nmake(target="clean"),