diff --git a/.appveyor.yml b/.appveyor.yml index d525e4cfc07..b817cd9d804 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -10,9 +10,9 @@ environment: TEST_OPTIONS: DEPLOY: YES matrix: - - PYTHON: C:/Python310 + - PYTHON: C:/Python311 ARCHITECTURE: x86 - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 + APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2022 - PYTHON: C:/Python37-x64 ARCHITECTURE: x64 APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 @@ -25,8 +25,8 @@ install: - mv c:\pillow-depends-main c:\pillow-depends - xcopy /S /Y c:\pillow-depends\test_images\* c:\pillow\tests\images - 7z x ..\pillow-depends\nasm-2.15.05-win64.zip -oc:\ -- ..\pillow-depends\gs9550w32.exe /S -- path c:\nasm-2.15.05;C:\Program Files (x86)\gs\gs9.55.0\bin;%PATH% +- ..\pillow-depends\gs1000w32.exe /S +- path c:\nasm-2.15.05;C:\Program Files (x86)\gs\gs10.0.0\bin;%PATH% - cd c:\pillow\winbuild\ - ps: | c:\python37\python.exe c:\pillow\winbuild\build_prepare.py -v --depends=C:\pillow-depends\ @@ -43,7 +43,7 @@ build_script: test_script: - cd c:\pillow -- '%PYTHON%\%EXECUTABLE% -m pip install pytest pytest-cov' +- '%PYTHON%\%EXECUTABLE% -m pip install pytest pytest-cov pytest-timeout' - c:\"Program Files (x86)"\"Windows Kits"\10\Debuggers\x86\gflags.exe /p /enable %PYTHON%\%EXECUTABLE% - '%PYTHON%\%EXECUTABLE% -c "from PIL import Image"' - '%PYTHON%\%EXECUTABLE% -m pytest -vx --cov PIL --cov Tests --cov-report term --cov-report xml Tests' diff --git a/.ci/after_success.sh b/.ci/after_success.sh index ff91b481eca..23a6fcd4d45 100755 --- a/.ci/after_success.sh +++ b/.ci/after_success.sh @@ -1,9 +1,9 @@ #!/bin/bash # gather the coverage data -pip3 install codecov +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 a2e3041bd27..e678f68ec85 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 c48acf9eece..518b66acc23 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 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,25 +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 -python3 -m pip install numpy - -# PyQt5 doesn't support PyPy3 -if [[ $GHA_PYTHON_VERSION == 3.* ]]; then - # arm64, ppc64le, s390x CPUs: - # "ERROR: Could not find a version that satisfies the requirement pyqt5" - sudo apt-get -qq install libxcb-xinerama0 pyqt5-dev-tools - python3 -m pip install pyqt5 -fi -# webp -pushd depends && ./install_webp.sh && popd +if [[ $(uname) != CYGWIN* ]]; then + python3 -m pip install numpy -# libimagequant -pushd depends && ./install_imagequant.sh && popd + # 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 -# raqm -pushd depends && ./install_raqm.sh && popd + # webp + pushd depends && ./install_webp.sh && popd -# extra test images -pushd depends && ./install_extra_test_images.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 diff --git a/.editorconfig b/.editorconfig index 798ab753c77..449530717f9 100644 --- a/.editorconfig +++ b/.editorconfig @@ -13,10 +13,13 @@ indent_style = space trim_trailing_whitespace = true +[*.rst] +# Four-space indentation +indent_size = 4 + [*.yml] # Two-space indentation indent_size = 2 -indent_style = space # Tab indentation (no size specified) [Makefile] diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index bc958774497..ba2b7d8ed26 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 8b289bda671..8dfa07f4ec5 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/renovate.json b/.github/renovate.json new file mode 100644 index 00000000000..d1d82433553 --- /dev/null +++ b/.github/renovate.json @@ -0,0 +1,17 @@ +{ + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "extends": [ + "config:base" + ], + "labels": [ + "Dependency" + ], + "packageRules": [ + { + "groupName": "github-actions", + "matchManagers": ["github-actions"], + "separateMajorMinor": "false" + } + ], + "schedule": ["on the 3rd day of the month"] +} diff --git a/.github/workflows/cifuzz.yml b/.github/workflows/cifuzz.yml new file mode 100644 index 00000000000..db030704607 --- /dev/null +++ b/.github/workflows/cifuzz.yml @@ -0,0 +1,56 @@ +name: CIFuzz + +on: + push: + paths: + - "**.c" + - "**.h" + pull_request: + paths: + - "**.c" + - "**.h" + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + Fuzzing: + runs-on: ubuntu-latest + steps: + - name: Build Fuzzers + id: build + uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master + with: + oss-fuzz-project-name: 'pillow' + language: python + dry-run: false + - name: Run Fuzzers + id: run + uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master + with: + oss-fuzz-project-name: 'pillow' + fuzz-seconds: 600 + language: python + dry-run: false + - name: Upload New Crash + uses: actions/upload-artifact@v3 + if: failure() && steps.build.outcome == 'success' + with: + name: artifacts + path: ./out/artifacts + - name: Upload Legacy Crash + uses: actions/upload-artifact@v3 + if: steps.run.outcome == 'success' + with: + name: crash + path: ./out/crash* + - name: Fail on legacy crash + if: success() + run: | + [ ! -e out/crash-* ] + echo No legacy crash detected diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 533ce8cbd53..49611e2879e 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -2,6 +2,13 @@ name: Lint on: [push, pull_request, workflow_dispatch] +permissions: + contents: read + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: build: @@ -10,10 +17,10 @@ jobs: name: Lint steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: pre-commit cache - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: ~/.cache/pre-commit key: lint-pre-commit-${{ hashFiles('**/.pre-commit-config.yaml') }} @@ -21,9 +28,9 @@ jobs: lint-pre-commit- - name: Set up Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: - python-version: "3.10" + python-version: "3.x" cache: pip cache-dependency-path: "setup.py" diff --git a/.github/workflows/macos-install.sh b/.github/workflows/macos-install.sh index 8260cf8d8d3..dfd7d055302 100755 --- a/.github/workflows/macos-install.sh +++ b/.github/workflows/macos-install.sh @@ -2,7 +2,7 @@ set -e -brew install libtiff libjpeg openjpeg libimagequant webp little-cms2 freetype openblas libraqm +brew install libtiff libjpeg openjpeg libimagequant webp little-cms2 freetype libraqm PYTHONOPTIMIZE=0 python3 -m pip install cffi python3 -m pip install coverage @@ -12,9 +12,7 @@ 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 python3 -m pip install numpy # extra test images diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml index ad66117b187..9e2fdc09604 100644 --- a/.github/workflows/release-drafter.yml +++ b/.github/workflows/release-drafter.yml @@ -7,8 +7,18 @@ on: - main workflow_dispatch: +permissions: + contents: read + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + 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/stale.yml b/.github/workflows/stale.yml new file mode 100644 index 00000000000..8c210bc9096 --- /dev/null +++ b/.github/workflows/stale.yml @@ -0,0 +1,31 @@ +name: Close stale issues + +on: + schedule: + - cron: "10 0 * * *" + workflow_dispatch: + +permissions: + issues: write + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + stale: + if: github.repository_owner == 'python-pillow' + + runs-on: ubuntu-latest + + steps: + - name: "Check issues" + uses: actions/stale@v7 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + only-labels: "Awaiting OP Action" + close-issue-message: "Closing this issue as no feedback has been received." + days-before-stale: 7 + days-before-issue-close: 0 + days-before-pr-close: -1 + labels-to-remove-when-unstale: "Awaiting OP Action" diff --git a/.github/workflows/test-cygwin.yml b/.github/workflows/test-cygwin.yml new file mode 100644 index 00000000000..7b8070d3477 --- /dev/null +++ b/.github/workflows/test-cygwin.yml @@ -0,0 +1,116 @@ +name: Test Cygwin + +on: [push, pull_request, workflow_dispatch] + +permissions: + contents: read + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + build: + runs-on: windows-latest + strategy: + fail-fast: false + matrix: + python-minor-version: [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@v3 + 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@v3 + 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: | + SETUPTOOLS_USE_DISTUTILS=stdlib .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 6a4f980161a..7331cf8ee0d 100644 --- a/.github/workflows/test-docker.yml +++ b/.github/workflows/test-docker.yml @@ -2,6 +2,13 @@ name: Test Docker on: [push, pull_request, workflow_dispatch] +permissions: + contents: read + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: build: @@ -10,25 +17,39 @@ jobs: fail-fast: false matrix: docker: [ + # Run slower jobs first to give them a headstart and reduce waiting time + ubuntu-22.04-jammy-arm64v8, + ubuntu-22.04-jammy-ppc64le, + ubuntu-22.04-jammy-s390x, # Then run the remainder alpine, amazon-2-amd64, arch, centos-7-amd64, - centos-8-amd64, centos-stream-8-amd64, + centos-stream-9-amd64, debian-10-buster-x86, - fedora-34-amd64, - fedora-35-amd64, + debian-11-bullseye-x86, + fedora-36-amd64, + fedora-37-amd64, + gentoo, ubuntu-18.04-bionic-amd64, ubuntu-20.04-focal-amd64, + ubuntu-22.04-jammy-amd64, ] dockerTag: [main] + include: + - docker: "ubuntu-22.04-jammy-arm64v8" + qemu-arch: "aarch64" + - docker: "ubuntu-22.04-jammy-ppc64le" + qemu-arch: "ppc64le" + - docker: "ubuntu-22.04-jammy-s390x" + qemu-arch: "s390x" name: ${{ matrix.docker }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Build system information run: python3 .github/workflows/system-info.py @@ -62,12 +83,14 @@ jobs: MATRIX_DOCKER: ${{ matrix.docker }} - name: Upload coverage - uses: codecov/codecov-action@v1 + uses: codecov/codecov-action@v3 with: flags: GHA_Docker 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 d94c7d53751..ccf6e193a6d 100644 --- a/.github/workflows/test-mingw.yml +++ b/.github/workflows/test-mingw.yml @@ -2,9 +2,16 @@ name: Test MinGW on: [push, pull_request, workflow_dispatch] +permissions: + contents: read + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: build: - runs-on: windows-2019 + runs-on: windows-latest strategy: fail-fast: false matrix: @@ -29,7 +36,7 @@ jobs: steps: - name: Checkout Pillow - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Set up shell run: echo "C:\msys64\usr\bin\" >> $env:GITHUB_PATH @@ -45,6 +52,7 @@ jobs: ${{ matrix.package }}-python-pyqt6 \ ${{ matrix.package }}-python3-setuptools \ ${{ matrix.package }}-freetype \ + ${{ matrix.package }}-gcc \ ${{ matrix.package }}-ghostscript \ ${{ matrix.package }}-lcms2 \ ${{ matrix.package }}-libimagequant \ @@ -69,13 +77,15 @@ jobs: python3 -m pytest -vx --cov PIL --cov Tests --cov-report term --cov-report xml Tests - name: Upload coverage - run: | - python3 -m pip install codecov - bash <(curl -s https://codecov.io/bash) -F GHA_Windows - env: - CODECOV_NAME: ${{ matrix.name }} + uses: codecov/codecov-action@v3 + with: + file: ./coverage.xml + flags: GHA_Windows + 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 4a8966ca8b3..f8b050f7625 100644 --- a/.github/workflows/test-valgrind.yml +++ b/.github/workflows/test-valgrind.yml @@ -13,6 +13,13 @@ on: - "**.h" workflow_dispatch: +permissions: + contents: read + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: build: @@ -21,14 +28,14 @@ jobs: fail-fast: false matrix: docker: [ - ubuntu-20.04-focal-amd64-valgrind, + ubuntu-22.04-jammy-amd64-valgrind, ] dockerTag: [main] name: ${{ matrix.docker }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Build system information run: python3 .github/workflows/system-info.py @@ -41,5 +48,5 @@ jobs: run: | # The Pillow user in the docker container is UID 1000 sudo chown -R 1000 $GITHUB_WORKSPACE - docker run --name pillow_container -v $GITHUB_WORKSPACE:/Pillow pythonpillow/${{ matrix.docker }}:${{ matrix.dockerTag }} + docker run --name pillow_container -e "PILLOW_VALGRIND_TEST=true" -v $GITHUB_WORKSPACE:/Pillow pythonpillow/${{ matrix.docker }}:${{ matrix.dockerTag }} sudo chown -R runner $GITHUB_WORKSPACE diff --git a/.github/workflows/test-windows.yml b/.github/workflows/test-windows.yml index c768838eb06..487c3586f02 100644 --- a/.github/workflows/test-windows.yml +++ b/.github/workflows/test-windows.yml @@ -2,19 +2,26 @@ name: Test Windows on: [push, pull_request, workflow_dispatch] +permissions: + contents: read + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: build: - runs-on: windows-2019 + runs-on: windows-latest strategy: fail-fast: false matrix: - python-version: ["3.7", "3.8", "3.9", "3.10"] + python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"] architecture: ["x86", "x64"] include: # PyPy 7.3.4+ only ships 64-bit binaries for Windows - - python-version: "pypy-3.7" + - python-version: "pypy3.8" architecture: "x64" - - python-version: "pypy-3.8" + - python-version: "pypy3.9" architecture: "x64" timeout-minutes: 30 @@ -23,17 +30,17 @@ jobs: steps: - name: Checkout Pillow - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Checkout cached dependencies - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: repository: python-pillow/pillow-depends path: winbuild\depends # sets env: pythonLocation - name: Set up Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} architecture: ${{ matrix.architecture }} @@ -41,10 +48,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 @@ -52,18 +59,20 @@ jobs: 7z x winbuild\depends\nasm-2.15.05-win64.zip "-o$env:RUNNER_WORKSPACE\" echo "$env:RUNNER_WORKSPACE\nasm-2.15.05" >> $env:GITHUB_PATH - winbuild\depends\gs9550w32.exe /S - echo "C:\Program Files (x86)\gs\gs9.55.0\bin" >> $env:GITHUB_PATH + winbuild\depends\gs1000w32.exe /S + echo "C:\Program Files (x86)\gs\gs10.0.0\bin" >> $env:GITHUB_PATH xcopy /S /Y winbuild\depends\test_images\* Tests\images\ # make cache key depend on VS version - & "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" | find """catalog_buildVersion""" | ForEach-Object { $a = $_.split(" ")[1]; echo "::set-output name=vs::$a" } + & "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" ` + | find """catalog_buildVersion""" ` + | ForEach-Object { $a = $_.split(" ")[1]; echo "vs=$a" >> $env:GITHUB_OUTPUT } shell: pwsh - name: Cache build id: build-cache - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: winbuild\build key: @@ -83,19 +92,28 @@ jobs: if: steps.build-cache.outputs.cache-hit != 'true' run: "& winbuild\\build\\build_dep_zlib.cmd" - - name: Build dependencies / LibTiff + - name: Build dependencies / xz if: steps.build-cache.outputs.cache-hit != 'true' - run: "& winbuild\\build\\build_dep_libtiff.cmd" + run: "& winbuild\\build\\build_dep_xz.cmd" - name: Build dependencies / WebP if: steps.build-cache.outputs.cache-hit != 'true' run: "& winbuild\\build\\build_dep_libwebp.cmd" + - name: Build dependencies / LibTiff + if: steps.build-cache.outputs.cache-hit != 'true' + run: "& winbuild\\build\\build_dep_libtiff.cmd" + # for FreeType CBDT/SBIX font support - name: Build dependencies / libpng if: steps.build-cache.outputs.cache-hit != 'true' run: "& winbuild\\build\\build_dep_libpng.cmd" + # for FreeType WOFF2 font support + - name: Build dependencies / brotli + if: steps.build-cache.outputs.cache-hit != 'true' + run: "& winbuild\\build\\build_dep_brotli.cmd" + - name: Build dependencies / FreeType if: steps.build-cache.outputs.cache-hit != 'true' run: "& winbuild\\build\\build_dep_freetype.cmd" @@ -123,7 +141,7 @@ jobs: if: steps.build-cache.outputs.cache-hit != 'true' run: "& winbuild\\build\\build_dep_fribidi.cmd" - # trim ~150MB x 9 + # trim ~150MB for each job - name: Optimize build cache if: steps.build-cache.outputs.cache-hit != 'true' run: rmdir /S /Q winbuild\build\src @@ -137,10 +155,11 @@ jobs: & $env:pythonLocation\python.exe selftest.py --installed shell: pwsh - # failing with PyPy3 + # skip PyPy for speed - name: Enable heap verification if: "!contains(matrix.python-version, 'pypy')" - run: "& 'C:\\Program Files (x86)\\Windows Kits\\10\\Debuggers\\x86\\gflags.exe' /p /enable $env:pythonLocation\\python.exe" + run: | + & reg.exe add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\python.exe" /v "GlobalFlag" /t REG_SZ /d "0x02000000" /f - name: Test Pillow run: | @@ -155,7 +174,7 @@ jobs: shell: bash - name: Upload errors - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 if: failure() with: name: errors @@ -167,7 +186,7 @@ jobs: shell: pwsh - name: Upload coverage - uses: codecov/codecov-action@v1 + uses: codecov/codecov-action@v3 with: file: ./coverage.xml flags: GHA_Windows @@ -177,17 +196,45 @@ jobs: id: wheel if: "github.event_name != 'pull_request'" run: | - for /f "tokens=3 delims=/" %%a in ("${{ github.ref }}") do echo ::set-output name=dist::dist-%%a + mkdir fribidi\${{ matrix.architecture }} + copy winbuild\build\bin\fribidi* fribidi\${{ matrix.architecture }} + setlocal EnableDelayedExpansion + for %%f in (winbuild\build\license\*) do ( + set x=%%~nf + rem Skip FriBiDi license, it is not included in the wheel. + set fribidi=!x:~0,7! + if NOT !fribidi!==fribidi ( + rem Skip imagequant license, it is not included in the wheel. + set libimagequant=!x:~0,13! + if NOT !libimagequant!==libimagequant ( + echo. >> LICENSE + echo ===== %%~nf ===== >> LICENSE + echo. >> LICENSE + type %%f >> LICENSE + ) + ) + ) + for /f "tokens=3 delims=/" %%a in ("${{ github.ref }}") do echo dist=dist-%%a >> %GITHUB_OUTPUT% winbuild\\build\\build_pillow.cmd --disable-imagequant bdist_wheel shell: cmd - - uses: actions/upload-artifact@v2 + - name: Upload wheel + uses: actions/upload-artifact@v3 if: "github.event_name != 'pull_request'" with: name: ${{ steps.wheel.outputs.dist }} path: dist\*.whl + - name: Upload fribidi.dll + if: "github.event_name != 'pull_request' && matrix.python-version == 3.11" + uses: actions/upload-artifact@v3 + with: + name: fribidi + path: fribidi\* + 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 414c7e94edd..11c7b77be03 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -2,6 +2,13 @@ name: Test on: [push, pull_request, workflow_dispatch] +permissions: + contents: read + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: build: @@ -13,8 +20,9 @@ jobs: "ubuntu-latest", ] python-version: [ - "pypy-3.8", - "pypy-3.7", + "pypy3.9", + "pypy3.8", + "3.11", "3.10", "3.9", "3.8", @@ -26,20 +34,15 @@ jobs: REVERSE: "--reverse" - python-version: "3.8" PYTHONOPTIMIZE: 2 - # Include new variables for Codecov - - os: ubuntu-latest - codecov-flag: GHA_Ubuntu - - os: macos-latest - codecov-flag: GHA_macOS runs-on: ${{ matrix.os }} name: ${{ matrix.os }} Python ${{ matrix.python-version }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} cache: pip @@ -59,6 +62,8 @@ jobs: if: startsWith(matrix.os, 'macOS') run: | .github/workflows/macos-install.sh + env: + GHA_PYTHON_VERSION: ${{ matrix.python-version }} - name: Build run: | @@ -84,16 +89,15 @@ jobs: mkdir -p Tests/errors - name: Upload errors - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 if: failure() with: name: errors path: Tests/errors - name: Docs - if: startsWith(matrix.os, 'ubuntu') && matrix.python-version == 3.9 + if: startsWith(matrix.os, 'ubuntu') && matrix.python-version == 3.11 run: | - python3 -m pip install sphinx-copybutton sphinx-issues sphinx-removed-in sphinx-rtd-theme sphinxext-opengraph make doccheck - name: After success @@ -101,11 +105,15 @@ jobs: .ci/after_success.sh - name: Upload coverage - run: bash <(curl -s https://codecov.io/bash) -F ${{ matrix.codecov-flag }} - env: - CODECOV_NAME: ${{ matrix.os }} Python ${{ matrix.python-version }} + uses: codecov/codecov-action@v3 + with: + file: ./coverage.xml + flags: ${{ matrix.os == 'macos-latest' && 'GHA_macOS' || 'GHA_Ubuntu' }} + 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 deleted file mode 100644 index c2b8b3bdaa9..00000000000 --- a/.github/workflows/tidelift.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: Tidelift Align -on: - schedule: - - cron: "30 2 * * *" # daily at 02:30 UTC - push: - paths: - - ".github/workflows/tidelift.yml" - pull_request: - paths: - - ".github/workflows/tidelift.yml" - workflow_dispatch: - -jobs: - build: - if: github.repository_owner == 'python-pillow' - name: Run Tidelift to ensure approved open source packages are in use - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Scan - uses: tidelift/alignment-action@main - env: - TIDELIFT_API_KEY: ${{ secrets.TIDELIFT_API_KEY }} - TIDELIFT_ORGANIZATION: team/aclark4life - TIDELIFT_PROJECT: pillow diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5f1d16709c1..d019d3e7fce 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,46 +1,65 @@ repos: - repo: https://github.com/psf/black - rev: 911470a610e47d9da5ea938b0887c3df62819b85 # frozen: 21.9b0 + rev: 22.12.0 hooks: - id: black - args: ["--target-version", "py37"] + args: [--target-version=py37] # Only .py files, until https://github.com/psf/black/issues/402 resolved files: \.py$ types: [] - repo: https://github.com/PyCQA/isort - rev: fd5ba70665a37ec301a1f714ed09336048b3be63 # frozen: 5.9.3 + rev: 5.11.1 hooks: - id: isort + - repo: https://github.com/PyCQA/bandit + rev: 1.7.4 + hooks: + - id: bandit + args: [--severity-level=high] + files: ^src/ + - repo: https://github.com/asottile/yesqa - rev: 644ede78511c02fc6f8e03e014cc1ddcfbf1e1f5 # frozen: v1.2.3 + rev: v1.4.0 hooks: - id: yesqa - repo: https://github.com/Lucas-C/pre-commit-hooks - rev: 3592548bbd98528887eeed63486cf6c9bae00b98 # frozen: v1.1.10 + rev: v1.3.1 hooks: - id: remove-tabs exclude: (Makefile$|\.bat$|\.cmake$|\.eps$|\.fits$|\.opt$) - repo: https://github.com/PyCQA/flake8 - rev: dcd740bc0ebaf2b3d43e59a0060d157c97de13f3 # frozen: 3.9.2 + rev: 6.0.0 hooks: - id: flake8 - additional_dependencies: [flake8-2020, flake8-implicit-str-concat] + additional_dependencies: + [flake8-2020, flake8-errmsg, flake8-implicit-str-concat] - repo: https://github.com/pre-commit/pygrep-hooks - rev: 6f51a66bba59954917140ec2eeeaa4d5e630e6ce # frozen: v1.9.0 + rev: v1.9.0 hooks: - id: python-check-blanket-noqa - id: rst-backticks - repo: https://github.com/pre-commit/pre-commit-hooks - rev: 38b88246ccc552bffaaf54259d064beeee434539 # frozen: v4.0.1 + rev: v4.4.0 hooks: - id: check-merge-conflict + - id: check-json - id: check-yaml + - repo: https://github.com/sphinx-contrib/sphinx-lint + rev: v0.6.7 + hooks: + - id: sphinx-lint + + - repo: https://github.com/tox-dev/tox-ini-fmt + rev: 0.5.2 + hooks: + - id: tox-ini-fmt + ci: - autoupdate_schedule: quarterly + autoupdate_schedule: monthly diff --git a/.readthedocs.yml b/.readthedocs.yml index 73e1f821366..0f581ebba90 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -1,2 +1,8 @@ +version: 2 + python: - pip_install: true + install: + - method: pip + path: . + extra_requirements: + - docs diff --git a/CHANGES.rst b/CHANGES.rst index c2d4892cb2f..7ec7b936da8 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -2,16 +2,604 @@ Changelog (Pillow) ================== +9.4.0 (2023-01-02) +------------------ + +- Fixed null pointer dereference crash with malformed font #6846 + [wiredfool, radarhere] + +- Return from ImagingFill early if image has a zero dimension #6842 + [radarhere] + +- Reversed deprecations for Image constants, except for duplicate Resampling attributes #6830 + [radarhere] + +- Improve exception traceback readability #6836 + [hugovk, radarhere] + +- Do not attempt to read IFD1 if absent #6840 + [radarhere] + +- Fixed writing int as ASCII tag #6800 + [radarhere] + +- If available, use wl-paste or xclip for grabclipboard() on Linux #6783 + [radarhere] + +- Added signed option when saving JPEG2000 images #6709 + [radarhere] + +- Patch OpenJPEG to include ARM64 fix #6718 + [radarhere] + +- Added support for I;16 modes in putdata() #6825 + [radarhere] + +- Added conversion from RGBa to RGB #6708 + [radarhere] + +- Added DDS support for uncompressed L and LA images #6820 + [radarhere, REDxEYE] + +- Added LightSource tag values to ExifTags #6749 + [radarhere] + +- Fixed PyAccess after changing ICO size #6821 + [radarhere] + +- Do not use EXIF from info when saving PNG images #6819 + [radarhere] + +- Fixed saving EXIF data to MPO #6817 + [radarhere] + +- Added Exif hide_offsets() #6762 + [radarhere] + +- Only compare to previous frame when checking for duplicate GIF frames while saving #6787 + [radarhere] + +- Always initialize all plugins in registered_extensions() #6811 + [radarhere] + +- Ignore non-opaque WebP background when saving as GIF #6792 + [radarhere] + +- Only set tile in ImageFile __setstate__ #6793 + [radarhere] + +- When reading BLP, do not trust JPEG decoder to determine image is CMYK #6767 + [radarhere] + +- Added IFD enum to ExifTags #6748 + [radarhere] + +- Fixed bug combining GIF frame durations #6779 + [radarhere] + +- Support saving JPEG comments #6774 + [smason, radarhere] + +- Added getxmp() to WebPImagePlugin #6758 + [radarhere] + +- Added "exact" option when saving WebP #6747 + [ashafaei, radarhere] + +- Use fractional coordinates when drawing text #6722 + [radarhere] + +- Fixed writing int as BYTE tag #6740 + [radarhere] + +- Added MP Format Version when saving MPO #6735 + [radarhere] + +- Added Interop to ExifTags #6724 + [radarhere] + +- CVE-2007-4559 patch when building on Windows #6704 + [TrellixVulnTeam, nulano, radarhere] + +- Fix compiler warning: accessing 64 bytes in a region of size 48 #6714 + [wiredfool] + +- Use verbose flag for pip install #6713 + [wiredfool, radarhere] + +9.3.0 (2022-10-29) +------------------ + +- Limit SAMPLESPERPIXEL to avoid runtime DOS #6700 + [wiredfool] + +- Initialize libtiff buffer when saving #6699 + [radarhere] + +- Inline fname2char to fix memory leak #6329 + [nulano] + +- Fix memory leaks related to text features #6330 + [nulano] + +- Use double quotes for version check on old CPython on Windows #6695 + [hugovk] + +- Remove backup implementation of Round for Windows platforms #6693 + [cgohlke] + +- Fixed set_variation_by_name offset #6445 + [radarhere] + +- Fix malloc in _imagingft.c:font_setvaraxes #6690 + [cgohlke] + +- Release Python GIL when converting images using matrix operations #6418 + [hmaarrfk] + +- Added ExifTags enums #6630 + [radarhere] + +- Do not modify previous frame when calculating delta in PNG #6683 + [radarhere] + +- Added support for reading BMP images with RLE4 compression #6674 + [npjg, radarhere] + +- Decode JPEG compressed BLP1 data in original mode #6678 + [radarhere] + +- Added GPS TIFF tag info #6661 + [radarhere] + +- Added conversion between RGB/RGBA/RGBX and LAB #6647 + [radarhere] + +- Do not attempt normalization if mode is already normal #6644 + [radarhere] + +- Fixed seeking to an L frame in a GIF #6576 + [radarhere] + +- Consider all frames when selecting mode for PNG save_all #6610 + [radarhere] + +- Don't reassign crc on ChunkStream close #6627 + [wiredfool, radarhere] + +- Raise a warning if NumPy failed to raise an error during conversion #6594 + [radarhere] + +- Show all frames in ImageShow #6611 + [radarhere] + +- Allow FLI palette chunk to not be first #6626 + [radarhere] + +- If first GIF frame has transparency for RGB_ALWAYS loading strategy, use RGBA mode #6592 + [radarhere] + +- Round box position to integer when pasting embedded color #6517 + [radarhere, nulano] + +- Removed EXIF prefix when saving WebP #6582 + [radarhere] + +- Pad IM palette to 768 bytes when saving #6579 + [radarhere] + +- Added DDS BC6H reading #6449 + [ShadelessFox, REDxEYE, radarhere] + +- Added support for opening WhiteIsZero 16-bit integer TIFF images #6642 + [JayWiz, radarhere] + +- Raise an error when allocating translucent color to RGB palette #6654 + [jsbueno, radarhere] + +- Added reading of TIFF child images #6569 + [radarhere] + +- Improved ImageOps palette handling #6596 + [PososikTeam, radarhere] + +- Defer parsing of palette into colors #6567 + [radarhere] + +- Apply transparency to P images in ImageTk.PhotoImage #6559 + [radarhere] + +- Use rounding in ImageOps contain() and pad() #6522 + [bibinhashley, radarhere] + +- Fixed GIF remapping to palette with duplicate entries #6548 + [radarhere] + +- Allow remap_palette() to return an image with less than 256 palette entries #6543 + [radarhere] + +- Corrected BMP and TGA palette size when saving #6500 + [radarhere] + +- Do not call load() before draft() in Image.thumbnail #6539 + [radarhere] + +- Copy palette when converting from P to PA #6497 + [radarhere] + +- Allow RGB and RGBA values for PA image putpixel #6504 + [radarhere] + +- Removed support for tkinter in PyPy before Python 3.6 #6551 + [nulano] + +- Do not use CCITTFaxDecode filter if libtiff is not available #6518 + [radarhere] + +- Fallback to not using mmap if buffer is not large enough #6510 + [radarhere] + +- Fixed writing bytes as ASCII tag #6493 + [radarhere] + +- Open 1 bit EPS in mode 1 #6499 + [radarhere] + +- Removed support for tkinter before Python 1.5.2 #6549 + [radarhere] + +- 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] + +- Use durations from each frame by default when saving GIFs #6265 + [radarhere] + +- Adjust BITSPERSAMPLE to match SAMPLESPERPIXEL when opening TIFFs #6270 + [radarhere] + +- Search pkgconf system libs/cflags #6138 + [jameshilliard, radarhere] + +- Raise ValueError for invalid PPM maxval #6242 + [radarhere] + +- Corrected screencapture argument in ImageGrab.grab() #6244 + [axt-one] + +- Deprecate support for Qt 5 (PyQt5 and PySide2) #6237 + [hugovk, radarhere] + +- Increase wait time of temporary file deletion on Windows #6224 + [AlexTedeschi] + +- Deprecate FreeTypeFont.getmask2 fill parameter #6220 + [nulano, radarhere, hugovk] + +- Round lut values where necessary #6188 + [radarhere] + +- Load before getting size in resize() #6190 + [radarhere] + +- Load image before performing size calculations in thumbnail() #6186 + [radarhere] + +- 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) +------------------ + +- Add support for multiple component transformation to JPEG2000 #5500 + [scaramallion, radarhere, hugovk] + +- Fix loading FriBiDi on Alpine #6165 + [nulano] + +- Added setting for converting GIF P frames to RGB #6150 + [radarhere] + +- Allow 1 mode images to be inverted #6034 + [radarhere] + +- Raise ValueError when trying to save empty JPEG #6159 + [radarhere] + +- Always save TIFF with contiguous planar configuration #5973 + [radarhere] + +- Connected discontiguous polygon corners #5980 + [radarhere] + +- Ensure Tkinter hook is activated for getimage() #6032 + [radarhere] + +- Use screencapture arguments to crop on macOS #6152 + [radarhere] + +- Do not mark L mode JPEG as 1 bit in PDF #6151 + [radarhere] + +- Added support for reading I;16R TIFF images #6132 + [radarhere] + +- If an error occurs after creating a file, remove the file #6134 + [radarhere] + +- Fixed calling DisplayViewer or XVViewer without a title #6136 + [radarhere] + +- Retain RGBA transparency when saving multiple GIF frames #6128 + [radarhere] + +- Save additional ICO frames with other bit depths if supplied #6122 + [radarhere] + +- Handle EXIF data truncated to just the header #6124 + [radarhere] + +- Added support for reading BMP images with RLE8 compression #6102 + [radarhere] + +- Support Python distributions where _tkinter is compiled in #6006 + [lukegb] + +- Added support for PPM arbitrary maxval #6119 + [radarhere] + +- Added BigTIFF reading #6097 + [radarhere] + +- When converting, clip I;16 to be unsigned, not signed #6112 + [radarhere] + +- Fixed loading L mode GIF with transparency #6086 + [radarhere] + +- Improved handling of PPM header #5121 + [Piolie, radarhere] + +- Reset size when seeking away from "Large Thumbnail" MPO frame #6101 + [radarhere] + +- Replace requirements.txt with extras #6072 + [hugovk, radarhere] + +- Added PyEncoder and support BLP saving #6069 + [radarhere] + +- Handle TGA images with packets that cross scan lines #6087 + [radarhere] + +- Added FITS reading #6056 + [radarhere, hugovk] + +- Added rawmode argument to Image.getpalette() #6061 + [radarhere] + +- Fixed BUFR, GRIB and HDF5 stub saving #6071 + [radarhere] + +- Do not automatically remove temporary ImageShow files on Unix #6045 + [radarhere] + +- Correctly read JPEG compressed BLP images #4685 + [Meithal, radarhere] + +- Merged _MODE_CONV typ into ImageMode as typestr #6057 + [radarhere] + +- Consider palette size when converting and in getpalette() #6060 + [radarhere] + +- Added enums #5954 + [radarhere] + +- Ensure image is opaque after converting P to PA with RGB palette #6052 + [radarhere] + +- Attach RGBA palettes from putpalette() when suitable #6054 + [radarhere] + +- Added get_photoshop_blocks() to parse Photoshop TIFF tag #6030 + [radarhere] + +- Drop excess values in BITSPERSAMPLE #6041 + [mikhail-iurkov] + +- Added unpacker from RGBA;15 to RGB #6031 + [radarhere] + +- Enable arm64 for MSVC on Windows #5811 + [gaborkertesz-linaro, gaborkertesz] + +- Keep IPython/Jupyter text/plain output stable #5891 + [shamrin, radarhere] + +- Raise an error when performing a negative crop #5972 + [radarhere, hugovk] + +- Deprecated show_file "file" argument in favour of "path" #5959 + [radarhere] + +- Fixed SPIDER images for use with Bio-formats library #5956 + [radarhere] + +- Ensure duplicated file pointer is closed #5946 + [radarhere] + +- Added specific error if path coordinate type is incorrect #5942 + [radarhere] + +- Return an empty bytestring from tobytes() for an empty image #5938 + [radarhere] + +- Remove readonly from Image.__eq__ #5930 + [hugovk] + +9.0.1 (2022-02-03) +------------------ + +- In show_file, use os.remove to remove temporary images. CVE-2022-24303 #6010 + [radarhere, hugovk] + +- Restrict builtins within lambdas for ImageMath.eval. CVE-2022-22817 #6009 + [radarhere] + 9.0.0 (2022-01-02) ------------------ -- Restrict builtins for ImageMath.eval(). CVE TBD #5923 +- Restrict builtins for ImageMath.eval(). CVE-2022-22817 #5923 [radarhere] - Ensure JpegImagePlugin stops at the end of a truncated file #5921 [radarhere] -- Fixed ImagePath.Path array handling. CVEs TBD #5920 +- Fixed ImagePath.Path array handling. CVE-2022-22815, CVE-2022-22816 #5920 [radarhere] - Remove consecutive duplicate tiles that only differ by their offset #5919 @@ -2975,7 +3563,7 @@ Changelog (Pillow) - Change function declaration to match Tcl_CmdProc type #1966 [homm] -- Integer overflow checks on all calls to *alloc #1781 +- Integer overflow checks on all calls to \*alloc #1781 [wiredfool] - Change equals method on Image so it short circuits #1967 @@ -4611,10 +5199,10 @@ Changelog (Pillow) [aclark4life] Pre-fork --------- +======== 0.2b5-1.1.7 -+++++++++++ +----------- :: @@ -4648,1740 +5236,1787 @@ Pre-fork Ka-Ping Yee, and many others (if your name should be on this list, let me know.) - *** Changes from release 1.1.6 to 1.1.7 *** - - This section may not be fully complete. For changes since this file - was last updated, see the repository revision history: - - http://svn.effbot.org/public/pil/ - - (1.1.7 final) - - + Set GIF loop info property to the number of iterations if a NETSCAPE - loop extension is present, instead of always setting it to 1 (from - Valentino Volonghi). - - (1.1.7c1 released) +1.1.6 to 1.1.7 +-------------- - + Improved PNG compression (from Alexey Borzenkov). +This section may not be fully complete. For changes since this file +was last updated, see the repository revision history: +http://svn.effbot.org/public/pil/ - + Read interlaced PNG files (from Conrado Porto Lopes Gouvêa) +1.1.7 final +----------- - + Added various TGA improvements from Alexey Borzenkov, including - support for specifying image orientation. +- Set GIF loop info property to the number of iterations if a NETSCAPE + loop extension is present, instead of always setting it to 1 (from + Valentino Volonghi). - + Bumped block threshold to 16 megabytes, made size estimation a bit - more accurate. This speeds up allocation of large images. +1.1.7c1 +------- - + Fixed rounding error in ImagingDrawWideLine. +- Improved PNG compression (from Alexey Borzenkov). - "gormish" writes: ImagingDrawWideLine() in Draw.c has a bug in every - version I've seen, which leads to different width lines depending on - the order of the points in the line. This is especially bad at some - angles where a 'width=2' line can completely disappear. +- Read interlaced PNG files (from Conrado Porto Lopes Gouvêa) - + Added support for RGBA mode to the SGI module (based on code by - Karsten Hiddemann). +- Added various TGA improvements from Alexey Borzenkov, including + support for specifying image orientation. - + Handle repeated IPTC tags (adapted from a patch by Eric Bruning). +- Bumped block threshold to 16 megabytes, made size estimation a bit + more accurate. This speeds up allocation of large images. - Eric writes: According to the specification, some IPTC tags can be - repeated, e.g., tag 2:25 (keywords). PIL 1.1.6 only retained the last - instance of that tag. Below is a patch to store all tags. If there are - multiple tag instances, they are stored in a (python) list. Single tag - instances remain as strings. +- Fixed rounding error in ImagingDrawWideLine. - + Fixed potential crash in ImageFilter for small target images - (reported by Zac Burns and Daniel Fetchinson). + "gormish" writes: ImagingDrawWideLine() in Draw.c has a bug in every + version I've seen, which leads to different width lines depending on + the order of the points in the line. This is especially bad at some + angles where a 'width=2' line can completely disappear. - + Use BMP instead of JPEG as temporary show format on Mac OS X. +- Added support for RGBA mode to the SGI module (based on code by + Karsten Hiddemann). - + Fixed putpixel/new for I;16 with colors > 255. +- Handle repeated IPTC tags (adapted from a patch by Eric Bruning). - + Added integer power support to ImagingMath. + Eric writes: According to the specification, some IPTC tags can be + repeated, e.g., tag 2:25 (keywords). PIL 1.1.6 only retained the last + instance of that tag. Below is a patch to store all tags. If there are + multiple tag instances, they are stored in a (python) list. Single tag + instances remain as strings. - + Added limited support for I;16L mode (explicit little endian). +- Fixed potential crash in ImageFilter for small target images + (reported by Zac Burns and Daniel Fetchinson). - + Moved WMF support into Image.core; enable WMF rendering by default - if renderer is available. +- Use BMP instead of JPEG as temporary show format on Mac OS X. - + Mark the ARG plugin as obsolete. +- Fixed putpixel/new for I;16 with colors > 255. - + Added version query mechanism to ImageCms and ImageFont, for - debugging. +- Added integer power support to ImagingMath. - + Added (experimental) ImageCms function for fetching the ICC profile - for the current display (currently Windows only). +- Added limited support for I;16L mode (explicit little endian). - Added HWND/HDC support to ImageCms.get_display_profile(). +- Moved WMF support into Image.core; enable WMF rendering by default + if renderer is available. - + Added WMF renderer (Windows only). +- Mark the ARG plugin as obsolete. - + Added ImagePointHandler and ImageTransformHandler mixins; made - ImageCmsTransform work with im.point. +- Added version query mechanism to ImageCms and ImageFont, for + debugging. - + Fixed potential endless loop in the XVThumbnail reader (from Nikolai - Ugelvik). +- Added (experimental) ImageCms function for fetching the ICC profile + for the current display (currently Windows only). - + Added Kevin Cazabon's pyCMS package. + Added HWND/HDC support to ImageCms.get_display_profile(). - The C code has been moved to _imagingcms.c, the Python interface - module is installed as PIL.ImageCMS. +- Added WMF renderer (Windows only). - Added support for in-memory ICC profiles. +- Added ImagePointHandler and ImageTransformHandler mixins; made + ImageCmsTransform work with im.point. - Unified buildTransform and buildTransformFromOpenProfiles. +- Fixed potential endless loop in the XVThumbnail reader (from Nikolai + Ugelvik). - The profile can now be either a filename, a profile object, or a - file-like object containing an in-memory profile. +- Added Kevin Cazabon's pyCMS package. - Additional fixes from Florian Böch: + The C code has been moved to _imagingcms.c, the Python interface + module is installed as PIL.ImageCMS. - Very nice - it just needs LCMS flags support so we can use black - point compensation and softproofing :) See attached patches. They - also fix a naming issue which could cause confusion - display - profile (ImageCms wording) actually means proof profile (lcms - wording), so I changed variable names and docstrings where - applicable. Patches are tested under Python 2.6. + Added support for in-memory ICC profiles. - + Improved support for layer names in PSD files (from Sylvain Baubeau) + Unified buildTransform and buildTransformFromOpenProfiles. - Sylvain writes: I needed to be able to retrieve the names of the - layers in a PSD files. But PsdImagePlugin.py didn't do the job so I - wrote this very small patch. + The profile can now be either a filename, a profile object, or a + file-like object containing an in-memory profile. - + Improved RGBA support for ImageTk for 8.4 and newer (from Con - Radchenko). + Additional fixes from Florian Böch: - This replaces the slow run-length based encoding model with true - compositing at the Tk level. + Very nice - it just needs LCMS flags support so we can use black + point compensation and softproofing :) See attached patches. They + also fix a naming issue which could cause confusion - display + profile (ImageCms wording) actually means proof profile (lcms + wording), so I changed variable names and docstrings where + applicable. Patches are tested under Python 2.6. - + Added support for 16- and 32-bit images to McIdas loader. +- Improved support for layer names in PSD files (from Sylvain Baubeau) - Based on file samples and stand-alone reader code provided by Craig - Swank. + Sylvain writes: I needed to be able to retrieve the names of the + layers in a PSD files. But PsdImagePlugin.py didn't do the job so I + wrote this very small patch. - + Added ImagePalette support to putpalette. +- Improved RGBA support for ImageTk for 8.4 and newer (from Con + Radchenko). - + Fixed problem with incremental parsing of PNG files. + This replaces the slow run-length based encoding model with true + compositing at the Tk level. - + Make selftest.py report non-zero status on failure (from Mark - Sienkiewicz) +- Added support for 16- and 32-bit images to McIdas loader. - + Add big endian save support and multipage infrastructure to the TIFF - writer (from Sebastian Haase). + Based on file samples and stand-alone reader code provided by Craig + Swank. - + Handle files with GPS IFD but no basic EXIF IFD (reported by Kurt - Schwehr). +- Added ImagePalette support to putpalette. - + Added zTXT support (from Andrew Kuchling via Lowell Alleman). +- Fixed problem with incremental parsing of PNG files. - + Fixed potential infinite loop bug in ImageFont (from Guilherme Polo). +- Make selftest.py report non-zero status on failure (from Mark + Sienkiewicz) - + Added sample ICC profiles (from Kevin Cazabon) +- Add big endian save support and multipage infrastructure to the TIFF + writer (from Sebastian Haase). - + Fixed array interface for I, F, and RGBA/RGBX images. +- Handle files with GPS IFD but no basic EXIF IFD (reported by Kurt + Schwehr). - + Added Chroma subsampling support for JPEG (from Justin Huff). +- Added zTXT support (from Andrew Kuchling via Lowell Alleman). - Justin writes: Attached is a patch (against PIL 1.1.6) to provide - control over the chroma subsampling done by the JPEG encoder. This - is often useful for reducing compression artifacts around edges of - clipart and text. +- Fixed potential infinite loop bug in ImageFont (from Guilherme Polo). - + Added USM/Gaussian Blur code from Kevin Cazabon. +- Added sample ICC profiles (from Kevin Cazabon) - + Fixed bug w. uninitialized image data when cropping outside the - source image. +- Fixed array interface for I, F, and RGBA/RGBX images. - + Use ImageShow to implement the Image.show method. +- Added Chroma subsampling support for JPEG (from Justin Huff). - Most notably, this picks the 'display' utility when available. It - also allows application code to register new display utilities via - the ImageShow registry. + Justin writes: Attached is a patch (against PIL 1.1.6) to provide + control over the chroma subsampling done by the JPEG encoder. This + is often useful for reducing compression artifacts around edges of + clipart and text. - + Release the GIL in the PNG compressor (from Michael van Tellingen). +- Added USM/Gaussian Blur code from Kevin Cazabon. - + Revised JPEG CMYK handling. +- Fixed bug w. uninitialized image data when cropping outside the + source image. - Always assume Adobe behaviour, both when reading and writing (based on - a patch by Kevin Cazabon, and test data by Tim V. and Charlie Clark, and - additional debugging by Michael van Tellingen). +- Use ImageShow to implement the Image.show method. - + Support for preserving ICC profiles (by Florian Böch via Tim Hatch). + Most notably, this picks the 'display' utility when available. It + also allows application code to register new display utilities via + the ImageShow registry. - Florian writes: +- Release the GIL in the PNG compressor (from Michael van Tellingen). - It's a beta, so still needs some testing, but should allow you to: - - retain embedded ICC profiles when saving from/to JPEG, PNG, TIFF. - Existing code doesn't need to be changed. - - access embedded profiles in JPEG, PNG, PSD, TIFF. +- Revised JPEG CMYK handling. - It also includes patches for TIFF to retain IPTC, Photoshop and XMP - metadata when saving as TIFF again, read/write TIFF resolution - information correctly, and to correct inverted CMYK JPEG files. + Always assume Adobe behaviour, both when reading and writing (based on + a patch by Kevin Cazabon, and test data by Tim V. and Charlie Clark, and + additional debugging by Michael van Tellingen). - + Fixed potential memory leak in median cut quantizer (from Evgeny Salmin). +- Support for preserving ICC profiles (by Florian Böch via Tim Hatch). - + Fixed OverflowError when reading upside-down BMP images. + Florian writes: - + Added resolution save option for PDF files. + It's a beta, so still needs some testing, but should allow you to: - Andreas Kostyrka writes: I've included a patched PdfImagePlugin.py - based on 1.1.6 as included in Ubuntu, that supports a "resolution" - save option. Not great, but it makes the PDF saving more useful by - allowing PDFs that are not exactly 72dpi. + - retain embedded ICC profiles when saving from/to JPEG, PNG, TIFF. + Existing code doesn't need to be changed. + - access embedded profiles in JPEG, PNG, PSD, TIFF. - + Look for Tcl/Tk include files in version-specific include directory - (from Encolpe Degoute). + It also includes patches for TIFF to retain IPTC, Photoshop and XMP + metadata when saving as TIFF again, read/write TIFF resolution + information correctly, and to correct inverted CMYK JPEG files. - + Fixed grayscale rounding error in ImageColor.getcolor (from Tim - Hatch). +- Fixed potential memory leak in median cut quantizer (from Evgeny Salmin). - + Fixed calculation of mean value in ImageEnhance.Contrast (reported - by "roop" and Scott David Daniels). +- Fixed OverflowError when reading upside-down BMP images. - + Fixed truetype positioning when first character has a negative left - bearing (from Ned Batchelder): +- Added resolution save option for PDF files. - Ned writes: In PIL 1.1.6, ImageDraw.text will position the string - incorrectly if the first character has a negative left bearing. To - see the problem, show a string like "///" in an italic font. The - first slash will be clipped at the left, and the string will be - mis-positioned. + Andreas Kostyrka writes: I've included a patched PdfImagePlugin.py + based on 1.1.6 as included in Ubuntu, that supports a "resolution" + save option. Not great, but it makes the PDF saving more useful by + allowing PDFs that are not exactly 72dpi. - + Fixed resolution unit bug in tiff reader/writer (based on code by - Florian Höch, Gary Bloom, and others). +- Look for Tcl/Tk include files in version-specific include directory + (from Encolpe Degoute). - + Added simple transparency support for RGB images (reported by - Sebastian Spaeth). +- Fixed grayscale rounding error in ImageColor.getcolor (from Tim + Hatch). - + Added support for Unicode filenames in ImageFont.truetype (from Donn - Ingle). +- Fixed calculation of mean value in ImageEnhance.Contrast (reported + by "roop" and Scott David Daniels). - + Fixed potential crash in ImageFont.getname method (from Donn Ingle). +- Fixed truetype positioning when first character has a negative left + bearing (from Ned Batchelder): - + Fixed encoding issue in PIL/WalImageFile (from Santiago M. Mola). + Ned writes: In PIL 1.1.6, ImageDraw.text will position the string + incorrectly if the first character has a negative left bearing. To + see the problem, show a string like "///" in an italic font. The + first slash will be clipped at the left, and the string will be + mis-positioned. - *** Changes from release 1.1.5 to 1.1.6 *** +- Fixed resolution unit bug in tiff reader/writer (based on code by + Florian Höch, Gary Bloom, and others). - (1.1.6 released) +- Added simple transparency support for RGB images (reported by + Sebastian Spaeth). - + Fixed some 64-bit compatibility warnings for Python 2.5. +- Added support for Unicode filenames in ImageFont.truetype (from Donn + Ingle). - + Added threading support for the Sane driver (from Abel Deuring). +- Fixed potential crash in ImageFont.getname method (from Donn Ingle). - (1.1.6b2 released) +- Fixed encoding issue in PIL/WalImageFile (from Santiago M. Mola). - + Added experimental "floodfill" function to the ImageDraw module - (based on code by Eric Raymond). +1.1.6 +----- - + The default arguments for "frombuffer" doesn't match "fromstring" - and the documentation; this is a bug, and will most likely be fixed - in a future version. In this release, PIL prints a warning message - instead. To silence the warning, change any calls of the form - "frombuffer(mode, size, data)" to +- Fixed some 64-bit compatibility warnings for Python 2.5. - frombuffer(mode, size, data, "raw", mode, 0, 1) +- Added threading support for the Sane driver (from Abel Deuring). - + Added "fromarray" function, which takes an object implementing the - NumPy array interface and creates a PIL Image from it. (from Travis - Oliphant). +1.1.6b2 +------- - + Added NumPy array interface support (__array_interface__) to the - Image class (based on code by Travis Oliphant). +- Added experimental "floodfill" function to the ImageDraw module + (based on code by Eric Raymond). - This allows you to easily convert between PIL image memories and - NumPy arrays: +- The default arguments for "frombuffer" doesn't match "fromstring" + and the documentation; this is a bug, and will most likely be fixed + in a future version. In this release, PIL prints a warning message + instead. To silence the warning, change any calls of the form + "frombuffer(mode, size, data)" to:: - import numpy, Image + frombuffer(mode, size, data, "raw", mode, 0, 1) - im = Image.open('hopper.jpg') +- Added "fromarray" function, which takes an object implementing the + NumPy array interface and creates a PIL Image from it. (from Travis + Oliphant). - a = numpy.asarray(im) # a is readonly +- Added NumPy array interface support (__array_interface__) to the + Image class (based on code by Travis Oliphant). - im = Image.fromarray(a) + This allows you to easily convert between PIL image memories and + NumPy arrays:: - + Fixed CMYK polarity for JPEG images, by treating all images as - "Adobe CMYK" images. (thanks to Cesare Leonardi and Kevin Cazabon - for samples, debugging, and patches). + import numpy, Image + im = Image.open('hopper.jpg') + a = numpy.asarray(im) # a is readonly + im = Image.fromarray(a) - (1.1.6b1 released) +- Fixed CMYK polarity for JPEG images, by treating all images as + "Adobe CMYK" images. (thanks to Cesare Leonardi and Kevin Cazabon + for samples, debugging, and patches). - + Added 'expand' option to the Image 'rotate' method. If true, the - output image is made large enough to hold the entire rotated image. +1.1.6b1 +------- - + Changed the ImageDraw 'line' method to always draw the last pixel in - a polyline, independent of line angle. +- Added 'expand' option to the Image 'rotate' method. If true, the + output image is made large enough to hold the entire rotated image. - + Fixed bearing calculation and clipping in the ImageFont truetype - renderer; this could lead to clipped text, or crashes in the low- - level _imagingft module. (based on input from Adam Twardoch and - others). +- Changed the ImageDraw 'line' method to always draw the last pixel in + a polyline, independent of line angle. - + Added ImageQt wrapper module, for converting PIL Image objects to - QImage objects in an efficient way. +- Fixed bearing calculation and clipping in the ImageFont truetype + renderer; this could lead to clipped text, or crashes in the low- + level _imagingft module. (based on input from Adam Twardoch and + others). - + Fixed 'getmodebands' to return the number of bands also for "PA" - and "LA" modes. Added 'getmodebandnames' helper that return the - band names. +- Added ImageQt wrapper module, for converting PIL Image objects to + QImage objects in an efficient way. - (1.1.6a2 released) +- Fixed 'getmodebands' to return the number of bands also for "PA" + and "LA" modes. Added 'getmodebandnames' helper that return the + band names. - + Added float/double support to the TIFF loader (from Russell - Nelson). +1.1.6a2 +------- - + Fixed broken use of realloc() in path.c (from Jan Matejek) +- Added float/double support to the TIFF loader (from Russell + Nelson). - + Added save support for Spider images (from William Baxter). +- Fixed broken use of realloc() in path.c (from Jan Matejek) - + Fixed broken 'paste' and 'resize' operations in pildriver - (from Bill Janssen). +- Added save support for Spider images (from William Baxter). - + Added support for duplex scanning to the Sane interface (Abel - Deuring). +- Fixed broken 'paste' and 'resize' operations in pildriver + (from Bill Janssen). - (1.1.6a1 released) +- Added support for duplex scanning to the Sane interface (Abel + Deuring). - + Fixed a memory leak in "convert(mode)", when converting from - L to P. +1.1.6a1 +------- - + Added pixel access object. The "load" method now returns a - access object that can be used to directly get and set pixel - values, using ordinary [x, y] notation: +- Fixed a memory leak in "convert(mode)", when converting from + L to P. - pixel = im.load() - v = pixel[x, y] - pixel[x, y] = v +- Added pixel access object. The "load" method now returns a + access object that can be used to directly get and set pixel + values, using ordinary [x, y] notation:: - If you're accessing more than a few pixels, this is a lot - faster than using getpixel/putpixel. + pixel = im.load() + v = pixel[x, y] + pixel[x, y] = v - + Fixed building on Cygwin (from Miki Tebeka). + If you're accessing more than a few pixels, this is a lot + faster than using getpixel/putpixel. - + Fixed "point(callable)" on unloaded images (reported by Håkan - Karlsson). +- Fixed building on Cygwin (from Miki Tebeka). - + Fixed size bug in ImageWin.ImageWindow constructor (from Victor - Reijs) +- Fixed "point(callable)" on unloaded images (reported by Håkan + Karlsson). - + Fixed ImageMath float() and int() operations for Python 2.4 - (reported by Don Rozenberg). +- Fixed size bug in ImageWin.ImageWindow constructor (from Victor + Reijs) - + Fixed "RuntimeError: encoder error -8 in tostring" problem for - wide "RGB", "I", and "F" images. +- Fixed ImageMath float() and int() operations for Python 2.4 + (reported by Don Rozenberg). - + Fixed line width calculation. +- Fixed "RuntimeError: encoder error -8 in tostring" problem for + wide "RGB", "I", and "F" images. - (1.1.6a0 released) +- Fixed line width calculation. - + Fixed byte order issue in Image.paste(ink) (from Ka-Ping Yee). +1.1.6a0 +------- - + Fixed off-by-0.5 errors in the ANTIALIAS code (based on input - from Douglas Bagnall). +- Fixed byte order issue in Image.paste(ink) (from Ka-Ping Yee). - + Added buffer interface support to the Path constructor. If - a buffer is provided, it is assumed to contain a flat array - of float coordinates (e.g. array.array('f', seq)). +- Fixed off-by-0.5 errors in the ANTIALIAS code (based on input + from Douglas Bagnall). - + Added new ImageMath module. +- Added buffer interface support to the Path constructor. If + a buffer is provided, it is assumed to contain a flat array + of float coordinates (e.g. array.array('f', seq)). - + Fixed ImageOps.equalize when used with a small number of distinct - values (reported by David Kirtley). +- Added new ImageMath module. - + Fixed potential integer division in PSDraw.image (from Eric Etheridge). +- Fixed ImageOps.equalize when used with a small number of distinct + values (reported by David Kirtley). - *** Changes from release 1.1 to 1.1.5 *** +- Fixed potential integer division in PSDraw.image (from Eric Etheridge). - (1.1.5c2 and 1.1.5 final released) +1.1.5c2 and 1.1.5 final +----------------------- - + Added experimental PERSPECTIVE transform method (from Jeff Breiden- - bach). +- Added experimental PERSPECTIVE transform method (from Jeff Breiden- + bach). - (1.1.5c1 released) +1.1.5c1 +------- - + Make sure "thumbnail" never generates zero-wide or zero-high images - (reported by Gene Skonicki) +- Make sure "thumbnail" never generates zero-wide or zero-high images + (reported by Gene Skonicki) - + Fixed a "getcolors" bug that could result in a zero count for some - colors (reported by Richard Oudkerk). +- Fixed a "getcolors" bug that could result in a zero count for some + colors (reported by Richard Oudkerk). - + Changed default "convert" palette to avoid "rounding errors" when - round-tripping white source pixels (reported by Henryk Gerlach and - Jeff Epler). +- Changed default "convert" palette to avoid "rounding errors" when + round-tripping white source pixels (reported by Henryk Gerlach and + Jeff Epler). - (1.1.5b3 released) +1.1.5b3 +------- - + Don't crash in "quantize" method if the number of colors requested - is larger than 256. This release raises a ValueError exception; - future versions may return a mode "RGB" image instead (reported - by Richard Oudkerk). +- Don't crash in "quantize" method if the number of colors requested + is larger than 256. This release raises a ValueError exception; + future versions may return a mode "RGB" image instead (reported + by Richard Oudkerk). - + Added WBMP read/write support (based on code by Duncan Booth). +- Added WBMP read/write support (based on code by Duncan Booth). - (1.1.5b2 released) +1.1.5b2 +------- - + Added DPI read/write support to the PNG codec. The decoder sets - the info["dpi"] attribute for PNG files with appropriate resolution - settings. The encoder uses the "dpi" option (based on code by Niki - Spahiev). +- Added DPI read/write support to the PNG codec. The decoder sets + the info["dpi"] attribute for PNG files with appropriate resolution + settings. The encoder uses the "dpi" option (based on code by Niki + Spahiev). - + Added limited support for "point" mappings from mode "I" to mode "L". - Only 16-bit values are supported (other values are clipped), the lookup - table must contain exactly 65536 entries, and the mode argument must be - set to "L". +- Added limited support for "point" mappings from mode "I" to mode "L". + Only 16-bit values are supported (other values are clipped), the lookup + table must contain exactly 65536 entries, and the mode argument must be + set to "L". - + Added support for Mac OS X icns files (based on code by Bob Ippolito). +- Added support for Mac OS X icns files (based on code by Bob Ippolito). - + Added "ModeFilter" support to the ImageFilter module. +- Added "ModeFilter" support to the ImageFilter module. - + Added support for Spider images (from William Baxter). See the - comments in PIL/SpiderImagePlugin.py for more information on this - format. +- Added support for Spider images (from William Baxter). See the + comments in PIL/SpiderImagePlugin.py for more information on this + format. - (1.1.5b1 released) +1.1.5b1 +------- - + Added new Sane release (from Ralph Heinkel). See the Sane/README - and Sane/CHANGES files for more information. +- Added new Sane release (from Ralph Heinkel). See the Sane/README + and Sane/CHANGES files for more information. - + Added experimental PngInfo chunk container to the PngImageFile - module. This can be used to add arbitrary chunks to a PNG file. - Create a PngInfo instance, use "add" or "add_text" to add chunks, - and pass the instance as the "pnginfo" option when saving the - file. +- Added experimental PngInfo chunk container to the PngImageFile + module. This can be used to add arbitrary chunks to a PNG file. + Create a PngInfo instance, use "add" or "add_text" to add chunks, + and pass the instance as the "pnginfo" option when saving the + file. - + Added "getpalette" method. This returns the palette as a list, - or None if the image has no palette. To modify the palette, use - "getpalette" to fetch the current palette, modify the list, and - put it back using "putpalette". +- Added "getpalette" method. This returns the palette as a list, + or None if the image has no palette. To modify the palette, use + "getpalette" to fetch the current palette, modify the list, and + put it back using "putpalette". - + Added optional flattening to the ImagePath "tolist" method. - tolist() or tolist(0) returns a list of 2-tuples, as before. - tolist(1) returns a flattened list instead. +- Added optional flattening to the ImagePath "tolist" method. + tolist() or tolist(0) returns a list of 2-tuples, as before. + tolist(1) returns a flattened list instead. - (1.1.5a5 released) +1.1.5a5 +------- - + Fixed BILINEAR/BICUBIC/ANTIALIAS filtering for mode "LA". +- Fixed BILINEAR/BICUBIC/ANTIALIAS filtering for mode "LA". - + Added "getcolors()" method. This is similar to the existing histo- - gram method, but looks at color values instead of individual layers, - and returns an unsorted list of (count, color) tuples. +- Added "getcolors()" method. This is similar to the existing histo- + gram method, but looks at color values instead of individual layers, + and returns an unsorted list of (count, color) tuples. - By default, the method returns None if finds more than 256 colors. - If you need to look for more colors, you can pass in a limit (this - is used to allocate internal tables, so you probably don't want to - pass in too large values). + By default, the method returns None if finds more than 256 colors. + If you need to look for more colors, you can pass in a limit (this + is used to allocate internal tables, so you probably don't want to + pass in too large values). - + Build improvements: Fixed building under AIX, improved detection of - FreeType2 and Mac OS X framework libraries, and more. Many thanks - to everyone who helped test the new "setup.py" script! +- Build improvements: Fixed building under AIX, improved detection of + FreeType2 and Mac OS X framework libraries, and more. Many thanks + to everyone who helped test the new "setup.py" script! - (1.1.5a4 released) +1.1.5a4 +------- - + The "save" method now looks for a file format driver before - creating the file. +- The "save" method now looks for a file format driver before + creating the file. - + Don't use antialiased truetype fonts when drawing in mode "P", "I", - and "F" images. +- Don't use antialiased truetype fonts when drawing in mode "P", "I", + and "F" images. - + Rewrote the "setup.py" file. The new version scans for available - support libraries, and configures both the libImaging core library - and the bindings in one step. +- Rewrote the "setup.py" file. The new version scans for available + support libraries, and configures both the libImaging core library + and the bindings in one step. - To use specific versions of the libraries, edit the ROOT variables - in the setup.py file. + To use specific versions of the libraries, edit the ROOT variables + in the setup.py file. - + Removed threaded "show" viewer; use the old "show" implementation - instead (Windows). +- Removed threaded "show" viewer; use the old "show" implementation + instead (Windows). - + Added deprecation warnings to Image.offset, ImageDraw.setink, and - ImageDraw.setfill. +- Added deprecation warnings to Image.offset, ImageDraw.setink, and + ImageDraw.setfill. - + Added width option to ImageDraw.line(). The current implementation - works best for straight lines; it does not support line joins, so - polylines won't look good. +- Added width option to ImageDraw.line(). The current implementation + works best for straight lines; it does not support line joins, so + polylines won't look good. - + ImageDraw.Draw is now a factory function instead of a class. If - you need to create custom draw classes, inherit from the ImageDraw - class. All other code should use the factory function. +- ImageDraw.Draw is now a factory function instead of a class. If + you need to create custom draw classes, inherit from the ImageDraw + class. All other code should use the factory function. - + Fixed loading of certain PCX files (problem reported by Greg - Hamilton, who also provided samples). +- Fixed loading of certain PCX files (problem reported by Greg + Hamilton, who also provided samples). - + Changed _imagingft.c to require FreeType 2.1 or newer. The - module can still be built with earlier versions; see comments - in _imagingft.c for details. +- Changed _imagingft.c to require FreeType 2.1 or newer. The + module can still be built with earlier versions; see comments + in _imagingft.c for details. - (1.1.5a3 released) +1.1.5a3 +------- - + Added 'getim' method, which returns a PyCObject wrapping an - Imaging pointer. The description string is set to IMAGING_MAGIC. - See Imaging.h for pointer and string declarations. +- Added 'getim' method, which returns a PyCObject wrapping an + Imaging pointer. The description string is set to IMAGING_MAGIC. + See Imaging.h for pointer and string declarations. - + Fixed reading of TIFF JPEG images (problem reported by Ulrik - Svensson). +- Fixed reading of TIFF JPEG images (problem reported by Ulrik + Svensson). - + Made ImageColor work under Python 1.5.2 +- Made ImageColor work under Python 1.5.2 - + Fixed division by zero "equalize" on very small images (from - Douglas Bagnall). +- Fixed division by zero "equalize" on very small images (from + Douglas Bagnall). - (1.1.5a2 released) +1.1.5a2 +------- - + The "paste" method now supports the alternative "paste(im, mask)" - syntax (in this case, the box defaults to im's bounding box). +- The "paste" method now supports the alternative "paste(im, mask)" + syntax (in this case, the box defaults to im's bounding box). - + The "ImageFile.Parser" class now works also for PNG files with - more than one IDAT block. +- The "ImageFile.Parser" class now works also for PNG files with + more than one IDAT block. - + Added DPI read/write to the TIFF codec, and fixed writing of - rational values. The decoder sets the info["dpi"] attribute - for TIFF files with appropriate resolution settings. The - encoder uses the "dpi" option. +- Added DPI read/write to the TIFF codec, and fixed writing of + rational values. The decoder sets the info["dpi"] attribute + for TIFF files with appropriate resolution settings. The + encoder uses the "dpi" option. - + Disable interlacing for small (or narrow) GIF images, to - work around what appears to be a hard-to-find bug in PIL's - GIF encoder. +- Disable interlacing for small (or narrow) GIF images, to + work around what appears to be a hard-to-find bug in PIL's + GIF encoder. - + Fixed writing of mode "P" PDF images. Made mode "1" PDF - images smaller. +- Fixed writing of mode "P" PDF images. Made mode "1" PDF + images smaller. - + Made the XBM reader a bit more robust; the file may now start - with a few whitespace characters. +- Made the XBM reader a bit more robust; the file may now start + with a few whitespace characters. - + Added support for enhanced metafiles to the WMF driver. The - separate PILWMF kit lets you render both placeable WMF files - and EMF files as raster images. See +- Added support for enhanced metafiles to the WMF driver. The + separate PILWMF kit lets you render both placeable WMF files + and EMF files as raster images. See + http://effbot.org/downloads#pilwmf - http://effbot.org/downloads#pilwmf +1.1.5a1 +------- - (1.1.5a1 released) +- Replaced broken WMF driver with a WMF stub plugin (see below). - + Replaced broken WMF driver with a WMF stub plugin (see below). +- Fixed writing of mode "1", "L", and "CMYK" PDF images (based on + input from Nicholas Riley and others). - + Fixed writing of mode "1", "L", and "CMYK" PDF images (based on - input from Nicholas Riley and others). +- Fixed adaptive palette conversion for zero-width or zero-height + images (from Chris Cogdon) - + Fixed adaptive palette conversion for zero-width or zero-height - images (from Chris Cogdon) +- Fixed reading of PNG images from QuickTime 6 (from Paul Pharr) - + Fixed reading of PNG images from QuickTime 6 (from Paul Pharr) +- Added support for StubImageFile plugins, including stub plugins + for BUFR, FITS, GRIB, and HDF5 files. A stub plugin can identify + a given file format, but relies on application code to open and + save files in that format. - + Added support for StubImageFile plugins, including stub plugins - for BUFR, FITS, GRIB, and HDF5 files. A stub plugin can identify - a given file format, but relies on application code to open and - save files in that format. +- Added optional "encoding" argument to the ImageFont.truetype + factory. This argument can be used to specify non-Unicode character + maps for fonts that support that. For example, to draw text using + the Microsoft Symbol font, use:: - + Added optional "encoding" argument to the ImageFont.truetype - factory. This argument can be used to specify non-Unicode character - maps for fonts that support that. For example, to draw text using - the Microsoft Symbol font, use: + font = ImageFont.truetype("symbol.ttf", 16, encoding="symb") + draw.text((0, 0), unichr(0xF000 + 0xAA)) - font = ImageFont.truetype("symbol.ttf", 16, encoding="symb") - draw.text((0, 0), unichr(0xF000 + 0xAA)) + (note that the symbol font uses characters in the 0xF000-0xF0FF + range) - (note that the symbol font uses characters in the 0xF000-0xF0FF - range) + Common encodings are "unic" (Unicode), "symb" (Microsoft Symbol), + "ADOB" (Adobe Standard), "ADBE" (Adobe Expert), and "armn" (Apple + Roman). See the FreeType documentation for more information. - Common encodings are "unic" (Unicode), "symb" (Microsoft Symbol), - "ADOB" (Adobe Standard), "ADBE" (Adobe Expert), and "armn" (Apple - Roman). See the FreeType documentation for more information. +- Made "putalpha" a bit more robust; you can now attach an alpha + layer to a plain "L" or "RGB" image, and you can also specify + constant alphas instead of alpha layers (using integers or colour + names). - + Made "putalpha" a bit more robust; you can now attach an alpha - layer to a plain "L" or "RGB" image, and you can also specify - constant alphas instead of alpha layers (using integers or colour - names). +- Added experimental "LA" mode support. - + Added experimental "LA" mode support. + An "LA" image is an "L" image with an attached transparency layer. + Note that support for "LA" is not complete; some operations may + fail or produce unexpected results. - An "LA" image is an "L" image with an attached transparency layer. - Note that support for "LA" is not complete; some operations may - fail or produce unexpected results. +- Added "RankFilter", "MinFilter", "MedianFilter", and "MaxFilter" + classes to the ImageFilter module. - + Added "RankFilter", "MinFilter", "MedianFilter", and "MaxFilter" - classes to the ImageFilter module. +- Improved support for applications using multiple threads; PIL + now releases the global interpreter lock for many CPU-intensive + operations (based on work by Kevin Cazabon). - + Improved support for applications using multiple threads; PIL - now releases the global interpreter lock for many CPU-intensive - operations (based on work by Kevin Cazabon). +- Ignore Unicode characters in the PCF loader (from Andres Polit) - + Ignore Unicode characters in the PCF loader (from Andres Polit) +- Fixed typo in OleFileIO.loadfat, which could affect loading of + FlashPix and Image Composer images (Daniel Haertle) - + Fixed typo in OleFileIO.loadfat, which could affect loading of - FlashPix and Image Composer images (Daniel Haertle) +- Fixed building on platforms that have Freetype but don't have + Tcl/Tk (Jack Jansen, Luciano Nocera, Piet van Oostrum and others) - + Fixed building on platforms that have Freetype but don't have - Tcl/Tk (Jack Jansen, Luciano Nocera, Piet van Oostrum and others) +- Added EXIF GPSInfo read support for JPEG files. To extract + GPSInfo information, open the file, extract the exif dictionary, + and check for the key 0x8825 (GPSInfo). If present, it contains + a dictionary mapping GPS keys to GPS values. For a list of keys, + see the EXIF specification. - + Added EXIF GPSInfo read support for JPEG files. To extract - GPSInfo information, open the file, extract the exif dictionary, - and check for the key 0x8825 (GPSInfo). If present, it contains - a dictionary mapping GPS keys to GPS values. For a list of keys, - see the EXIF specification. + The "ExifTags" module contains a GPSTAGS dictionary mapping GPS + tags to tag names. - The "ExifTags" module contains a GPSTAGS dictionary mapping GPS - tags to tag names. +- Added DPI read support to the PCX and DCX codecs (info["dpi"]). - + Added DPI read support to the PCX and DCX codecs (info["dpi"]). +- The "show" methods now uses a built-in image viewer on Windows. + This viewer creates an instance of the ImageWindow class (see + below) and keeps it running in a separate thread. NOTE: This + was disabled in 1.1.5a4. - + The "show" methods now uses a built-in image viewer on Windows. - This viewer creates an instance of the ImageWindow class (see - below) and keeps it running in a separate thread. NOTE: This - was disabled in 1.1.5a4. +- Added experimental "Window" and "ImageWindow" classes to the + ImageWin module. These classes allow you to create a WCK-style + toplevel window, and use it to display raster data. - + Added experimental "Window" and "ImageWindow" classes to the - ImageWin module. These classes allow you to create a WCK-style - toplevel window, and use it to display raster data. +- Fixed some Python 1.5.2 issues (to build under 1.5.2, use the + Makefile.pre.in/Setup.in approach) - + Fixed some Python 1.5.2 issues (to build under 1.5.2, use the - Makefile.pre.in/Setup.in approach) +- Added support for the TIFF FillOrder tag. PIL can read mode "1", + "L", "P" and "RGB" images with non-standard FillOrder (based on + input from Jeff Breidenbach). - + Added support for the TIFF FillOrder tag. PIL can read mode "1", - "L", "P" and "RGB" images with non-standard FillOrder (based on - input from Jeff Breidenbach). +1.1.4 final +----------- - (1.1.4 final released) +- Fixed ImageTk build problem on Unix. - + Fixed ImageTk build problem on Unix. +1.1.4b2 +------- - (1.1.4b2 released) +- Improved building on Mac OS X (from Jack Jansen). - + Improved building on Mac OS X (from Jack Jansen). +- Improved building on Windows with MinGW (from Klamer Shutte). - + Improved building on Windows with MinGW (from Klamer Shutte). +- If no font is specified, ImageDraw now uses the embedded default + font. Use the "load" or "truetype" methods to load a real font. - + If no font is specified, ImageDraw now uses the embedded default - font. Use the "load" or "truetype" methods to load a real font. +- Added embedded default font to the ImageFont module (currently + an 8-pixel Courier font, taken from the X window distribution). - + Added embedded default font to the ImageFont module (currently - an 8-pixel Courier font, taken from the X window distribution). +1.1.4b1 +------- - (1.1.4b1 released) +- Added experimental EXIF support for JPEG files. To extract EXIF + information from a JPEG file, open the file as usual, and call the + "_getexif" method. If successful, this method returns a dictionary + mapping EXIF TIFF tags to values. If the file does not contain EXIF + data, the "_getexif" method returns None. - + Added experimental EXIF support for JPEG files. To extract EXIF - information from a JPEG file, open the file as usual, and call the - "_getexif" method. If successful, this method returns a dictionary - mapping EXIF TIFF tags to values. If the file does not contain EXIF - data, the "_getexif" method returns None. + The "ExifTags" module contains a dictionary mapping tags to tag + names. - The "ExifTags" module contains a dictionary mapping tags to tag - names. + This interface will most likely change in future versions. - This interface will most likely change in future versions. +- Fixed a bug when using the "transparency" option with the GIF + writer. - + Fixed a bug when using the "transparency" option with the GIF - writer. +- Added limited support for "bitfield compression" in BMP files + and DIB buffers, for 15-bit, 16-bit, and 32-bit images. This + also fixes a problem with ImageGrab module when copying screen- + dumps from the clipboard on 15/16/32-bit displays. - + Added limited support for "bitfield compression" in BMP files - and DIB buffers, for 15-bit, 16-bit, and 32-bit images. This - also fixes a problem with ImageGrab module when copying screen- - dumps from the clipboard on 15/16/32-bit displays. +- Added experimental WAL (Quake 2 textures) loader. To use this + loader, import WalImageFile and call the "open" method in that + module. - + Added experimental WAL (Quake 2 textures) loader. To use this - loader, import WalImageFile and call the "open" method in that - module. +1.1.4a4 +------- - (1.1.4a4 released) +- Added updated SANE driver (Andrew Kuchling, Abel Deuring) - + Added updated SANE driver (Andrew Kuchling, Abel Deuring) +- Use Python's "mmap" module on non-Windows platforms to read some + uncompressed formats using memory mapping. Also added a "frombuffer" + function that allows you to access the contents of an existing string + or buffer object as if it were an image object. - + Use Python's "mmap" module on non-Windows platforms to read some - uncompressed formats using memory mapping. Also added a "frombuffer" - function that allows you to access the contents of an existing string - or buffer object as if it were an image object. +- Fixed a memory leak that could appear when processing mode "P" + images (from Pier Paolo Glave) - + Fixed a memory leak that could appear when processing mode "P" - images (from Pier Paolo Glave) +- Ignore Unicode characters in the BDF loader (from Graham Dumpleton) - + Ignore Unicode characters in the BDF loader (from Graham Dumpleton) +1.1.4a3 released; Windows only +------------------------------ - (1.1.4a3 released; windows only) +- Added experimental RGBA-on-RGB drawing support. To use RGBA + colours on an RGB image, pass "RGBA" as the second string to + the ImageDraw.Draw constructor. - + Added experimental RGBA-on-RGB drawing support. To use RGBA - colours on an RGB image, pass "RGBA" as the second string to - the ImageDraw.Draw constructor. +- Added support for non-ASCII strings (Latin-1) and Unicode + to the truetype font renderer. - + Added support for non-ASCII strings (Latin-1) and Unicode - to the truetype font renderer. +- The ImageWin "Dib" object can now be constructed directly from + an image object. - + The ImageWin "Dib" object can now be constructed directly from - an image object. +- The ImageWin module now allows you use window handles as well + as device contexts. To use a window handle, wrap the handle in + an ImageWin.HWND object, and pass in this object instead of the + device context. - + The ImageWin module now allows you use window handles as well - as device contexts. To use a window handle, wrap the handle in - an ImageWin.HWND object, and pass in this object instead of the - device context. +1.1.4a2 +------- - (1.1.4a2 released) +- Improved support for 16-bit unsigned integer images (mode "I;16"). + This includes TIFF reader support, and support for "getextrema" + and "point" (from Klamer Shutte). - + Improved support for 16-bit unsigned integer images (mode "I;16"). - This includes TIFF reader support, and support for "getextrema" - and "point" (from Klamer Shutte). +- Made the BdfFontFile reader a bit more robust (from Kevin Cazabon + and Dmitry Vasiliev) - + Made the BdfFontFile reader a bit more robust (from Kevin Cazabon - and Dmitry Vasiliev) +- Changed TIFF writer to always write Compression tag, even when + using the default compression (from Greg Couch). - + Changed TIFF writer to always write Compression tag, even when - using the default compression (from Greg Couch). +- Added "show" support for Mac OS X (from Dan Wolfe). - + Added "show" support for Mac OS X (from Dan Wolfe). +- Added clipboard support to the "ImageGrab" module (Windows only). + The "grabclipboard" function returns an Image object, a list of + filenames (not in 1.1.4), or None if neither was found. - + Added clipboard support to the "ImageGrab" module (Windows only). - The "grabclipboard" function returns an Image object, a list of - filenames (not in 1.1.4), or None if neither was found. +1.1.4a1 +------- - (1.1.4a1 released) +- Improved support for drawing RGB data in palette images. You can + now use RGB tuples or colour names (see below) when drawing in a + mode "P" image. The drawing layer automatically assigns color + indexes, as long as you don't use more than 256 unique colours. - + Improved support for drawing RGB data in palette images. You can - now use RGB tuples or colour names (see below) when drawing in a - mode "P" image. The drawing layer automatically assigns color - indexes, as long as you don't use more than 256 unique colours. +- Moved self test from MiniTest/test.py to ./selftest.py. - + Moved self test from MiniTest/test.py to ./selftest.py. +- Added support for CSS3-style color strings to most places that + accept colour codes/tuples. This includes the "ImageDraw" module, + the Image "new" function, and the Image "paste" method. - + Added support for CSS3-style color strings to most places that - accept colour codes/tuples. This includes the "ImageDraw" module, - the Image "new" function, and the Image "paste" method. + Colour strings can use one of the following formats: "#f00", + "#ff0000", "rgb(255,0,0)", "rgb(100%,0%,0%)", "hsl(0, 100%, 50%)", + or "red" (most X11-style colour names are supported). See the + documentation for the "ImageColor" module for more information. - Colour strings can use one of the following formats: "#f00", - "#ff0000", "rgb(255,0,0)", "rgb(100%,0%,0%)", "hsl(0, 100%, 50%)", - or "red" (most X11-style colour names are supported). See the - documentation for the "ImageColor" module for more information. +- Fixed DCX decoder (based on input from Larry Bates) - + Fixed DCX decoder (based on input from Larry Bates) +- Added "IptcImagePlugin.getiptcinfo" helper to extract IPTC/NAA + newsphoto properties from JPEG, TIFF, or IPTC files. - + Added "IptcImagePlugin.getiptcinfo" helper to extract IPTC/NAA - newsphoto properties from JPEG, TIFF, or IPTC files. +- Support for TrueType/OpenType fonts has been added to + the standard distribution. You need the freetype 2.0 + library. - + Support for TrueType/OpenType fonts has been added to - the standard distribution. You need the freetype 2.0 - library. +- Made the PCX reader a bit more robust when reading 2-bit + and 4-bit PCX images with odd image sizes. - + Made the PCX reader a bit more robust when reading 2-bit - and 4-bit PCX images with odd image sizes. +- Added "Kernel" class to the ImageFilter module. This class + allows you to filter images with user-defined 3x3 and 5x5 + convolution kernels. - + Added "Kernel" class to the ImageFilter module. This class - allows you to filter images with user-defined 3x3 and 5x5 - convolution kernels. +- Added "putdata" support for mode "I", "F" and "RGB". - + Added "putdata" support for mode "I", "F" and "RGB". +- The GIF writer now supports the transparency option (from + Denis Benoit). - + The GIF writer now supports the transparency option (from - Denis Benoit). +- A HTML version of the module documentation is now shipped + with the source code distribution. You'll find the files in + the Doc subdirectory. - + A HTML version of the module documentation is now shipped - with the source code distribution. You'll find the files in - the Doc subdirectory. +- Added support for Palm pixmaps (from Bill Janssen). This + change was listed for 1.1.3, but the "PalmImagePlugin" driver + didn't make it into the distribution. - + Added support for Palm pixmaps (from Bill Janssen). This - change was listed for 1.1.3, but the "PalmImagePlugin" driver - didn't make it into the distribution. +- Improved decoder error messages. - + Improved decoder error messages. +1.1.3 final +----------- - (1.1.3 final released) +- Made setup.py look for old versions of zlib. For some back- + ground, see: https://zlib.net/advisory-2002-03-11.txt - + Made setup.py look for old versions of zlib. For some back- - ground, see: https://zlib.net/advisory-2002-03-11.txt +1.1.3c2 +------- - (1.1.3c2 released) +- Added setup.py file (tested on Unix and Windows). You still + need to build libImaging/imaging.lib in the traditional way, + but the setup.py script takes care of the rest. - + Added setup.py file (tested on Unix and Windows). You still - need to build libImaging/imaging.lib in the traditional way, - but the setup.py script takes care of the rest. + The old Setup.in/Makefile.pre.in build method is still + supported. - The old Setup.in/Makefile.pre.in build method is still - supported. +- Fixed segmentation violation in ANTIALIAS filter (an internal + buffer wasn't properly allocated). - + Fixed segmentation violation in ANTIALIAS filter (an internal - buffer wasn't properly allocated). +1.1.3c1 +------- - (1.1.3c1 released) +- Added ANTIALIAS downsampling filter for high-quality "resize" + and "thumbnail" operations. Also added filter option to the + "thumbnail" operation; the default value is NEAREST, but this + will most likely change in future versions. - + Added ANTIALIAS downsampling filter for high-quality "resize" - and "thumbnail" operations. Also added filter option to the - "thumbnail" operation; the default value is NEAREST, but this - will most likely change in future versions. +- Fixed plugin loader to be more robust if the __file__ + variable isn't set. - + Fixed plugin loader to be more robust if the __file__ - variable isn't set. +- Added seek/tell support (for layers) to the PhotoShop + loader. Layer 0 is the main image. - + Added seek/tell support (for layers) to the PhotoShop - loader. Layer 0 is the main image. +- Added new (but experimental) "ImageOps" module, which provides + shortcuts for commonly used operations on entire images. - + Added new (but experimental) "ImageOps" module, which provides - shortcuts for commonly used operations on entire images. +- Don't mess up when loading PNG images if the decoder leaves + data in the output buffer. This could cause internal errors + on some PNG images, with some versions of ZLIB. (Bug report + and patch provided by Bernhard Herzog.) - + Don't mess up when loading PNG images if the decoder leaves - data in the output buffer. This could cause internal errors - on some PNG images, with some versions of ZLIB. (Bug report - and patch provided by Bernhard Herzog.) +- Don't mess up on Unicode filenames. - + Don't mess up on Unicode filenames. +- Don't mess up when drawing on big endian platforms. - + Don't mess up when drawing on big endian platforms. +- Made the TIFF loader a bit more robust; it can now read some + more slightly broken TIFF files (based on input from Ted Wright, + Bob Klimek, and D. Alan Stewart) - + Made the TIFF loader a bit more robust; it can now read some - more slightly broken TIFF files (based on input from Ted Wright, - Bob Klimek, and D. Alan Stewart) +- Added OS/2 EMX build files (from Andrew MacIntyre) - + Added OS/2 EMX build files (from Andrew MacIntyre) +- Change "ImageFont" to reject image files if they don't have the + right mode. Older versions could leak memory for "P" images. + (Bug reported by Markus Gritsch). - + Change "ImageFont" to reject image files if they don't have the - right mode. Older versions could leak memory for "P" images. - (Bug reported by Markus Gritsch). +- Renamed some internal functions to avoid potential build + problem on Mac OS X. - + Renamed some internal functions to avoid potential build - problem on Mac OS X. +- Added DL_EXPORT where relevant (for Cygwin, based on input + from Robert Yodlowski) - + Added DL_EXPORT where relevant (for Cygwin, based on input - from Robert Yodlowski) +- (re)moved bogus __init__ call in BdfFontFile (bug spotted + by Fred Clare) - + (re)moved bogus __init__ call in BdfFontFile (bug spotted - by Fred Clare) +- Added "ImageGrab" support (Windows only) - + Added "ImageGrab" support (Windows only) +- Added support for XBM hotspots (based on code contributed by + Bernhard Herzog). - + Added support for XBM hotspots (based on code contributed by - Bernhard Herzog). +- Added write support for more TIFF tags, namely the Artist, + Copyright, DateTime, ResolutionUnit, Software, XResolution and + YResolution tags (from Greg Couch) - + Added write support for more TIFF tags, namely the Artist, - Copyright, DateTime, ResolutionUnit, Software, XResolution and - YResolution tags (from Greg Couch) +- Added TransposedFont wrapper to ImageFont module - + Added TransposedFont wrapper to ImageFont module +- Added "optimize" flag to GIF encoder. If optimize is present + and non-zero, PIL will work harder to create a small file. - + Added "optimize" flag to GIF encoder. If optimize is present - and non-zero, PIL will work harder to create a small file. +- Raise "EOFError" (not IndexError) when reading beyond the + end of a TIFF sequence. - + Raise "EOFError" (not IndexError) when reading beyond the - end of a TIFF sequence. +- Support rewind ("seek(0)") for GIF and TIFF sequences. - + Support rewind ("seek(0)") for GIF and TIFF sequences. +- Load grayscale GIF images as mode "L" - + Load grayscale GIF images as mode "L" +- Added DPI read/write support to the JPEG codec. The decoder + sets the info["dpi"] attribute for JPEG files with JFIF dpi + settings. The encoder uses the "dpi" option:: - + Added DPI read/write support to the JPEG codec. The decoder - sets the info["dpi"] attribute for JPEG files with JFIF dpi - settings. The encoder uses the "dpi" option: + im = Image.open("file.jpg") + dpi = im.info["dpi"] # raises KeyError if DPI not known + im.save("out.jpg", dpi=dpi) - im = Image.open("file.jpg") - dpi = im.info["dpi"] # raises KeyError if DPI not known - im.save("out.jpg", dpi=dpi) + Note that PIL doesn't always preserve the "info" attribute + for normal image operations. - Note that PIL doesn't always preserve the "info" attribute - for normal image operations. +1.1.2c1 and 1.1.2 final +----------------------- - (1.1.2c1 and 1.1.2 final released) +- Adapted to Python 2.1. Among other things, all uses of the + "regex" module have been replaced with "re". - + Adapted to Python 2.1. Among other things, all uses of the - "regex" module have been replaced with "re". +- Fixed attribute error when reading large PNG files (this bug + was introduced in maintenance code released after the 1.1.1 + release) - + Fixed attribute error when reading large PNG files (this bug - was introduced in maintenance code released after the 1.1.1 - release) +- Ignore non-string objects in sys.path - + Ignore non-string objects in sys.path +- Fixed Image.transform(EXTENT) for negative xoffsets - + Fixed Image.transform(EXTENT) for negative xoffsets +- Fixed loading of image plugins if PIL is installed as a package. + (The plugin loader now always looks in the directory where the + Image.py module itself is found, even if that directory isn't on + the standard search path) - + Fixed loading of image plugins if PIL is installed as a package. - (The plugin loader now always looks in the directory where the - Image.py module itself is found, even if that directory isn't on - the standard search path) +- The Png plugin has been added to the list of preloaded standard + formats - + The Png plugin has been added to the list of preloaded standard - formats +- Fixed bitmap/text drawing in fill mode. - + Fixed bitmap/text drawing in fill mode. +- Fixed "getextrema" to work also for multiband images. - + Fixed "getextrema" to work also for multiband images. +- Added transparency support for L and P images to the PNG codec. - + Added transparency support for L and P images to the PNG codec. +- Improved support for read-only images. The "load" method now + sets the "readonly" attribute for memory-mapped images. Operations + that modifies an image in place (such as "paste" and drawing operations) + creates an in-memory copy of the image, if necessary. (before this + change, any attempt to modify a memory-mapped image resulted in a + core dump...) - + Improved support for read-only images. The "load" method now - sets the "readonly" attribute for memory-mapped images. Operations - that modifies an image in place (such as "paste" and drawing operations) - creates an in-memory copy of the image, if necessary. (before this - change, any attempt to modify a memory-mapped image resulted in a - core dump...) +- Added special cases for lists everywhere PIL expects a sequence. + This should speed up things like "putdata" and drawing operations. - + Added special cases for lists everywhere PIL expects a sequence. - This should speed up things like "putdata" and drawing operations. +- The Image.offset method is deprecated. Use the ImageChops.offset + function instead. - + The Image.offset method is deprecated. Use the ImageChops.offset - function instead. +- Changed ImageChops operators to copy palette and info dictionary + from the first image argument. - + Changed ImageChops operators to copy palette and info dictionary - from the first image argument. +1.1.1 +----- - (1.1.1 released) +- Additional fixes for Python 1.6/2.0, including TIFF "save" bug. - + Additional fixes for Python 1.6/2.0, including TIFF "save" bug. +- Changed "init" to properly load plugins when PIL is used as a + package. - + Changed "init" to properly load plugins when PIL is used as a - package. +- Fixed broken "show" method (on Unix) - + Fixed broken "show" method (on Unix) +1.0 to 1.1 +---------- - *** Changes from release 1.0 to 1.1 *** +- Adapted to Python 1.6 ("append" and other method changes) - + Adapted to Python 1.6 ("append" and other method changes) +- Fixed Image.paste when pasting with solid colour and matte + layers ("L" or "RGBA" masks) (bug reported by Robert Kern) - + Fixed Image.paste when pasting with solid colour and matte - layers ("L" or "RGBA" masks) (bug reported by Robert Kern) +- To make it easier to distribute prebuilt versions of PIL, + the tkinit binding stuff has been moved to a separate + extension module, named "_imagingtk". - + To make it easier to distribute prebuilt versions of PIL, - the tkinit binding stuff has been moved to a separate - extension module, named "_imagingtk". - - *** Changes from release 0.3b2 to 1.0 final *** - - + If there's no 16-bit integer (like on a Cray T3E), set - INT16 to the smallest integer available. Most of the - library works just fine anyway (from Bill Crutchfield) - - + Tweaks to make drawing work on big-endian platforms. - - (1.0c2 released) - - + If PIL is built with the WITH_TKINTER flag, ImageTk can - automatically hook into a standard Tkinter build. You - no longer need to build your own Tkinter to use the - ImageTk module. - - The old way still works, though. For more information, - see Tk/install.txt. - - + Some tweaks to ImageTk to support multiple Tk interpreters - (from Greg Couch). - - + ImageFont "load_path" now scans directory mentioned in .pth - files (from Richard Jones). - - (1.0c1 released) - - + The TIFF plugin has been rewritten. The new plugin fully - supports all major PIL image modes (including F and I). - - + The ImageFile module now includes a Parser class, which can - be used to incrementally decode an image file (while down- - loading it from the net, for example). See the handbook for - details. - - + "show" now converts non-standard modes to "L" or "RGB" (as - appropriate), rather than writing weird things to disk for - "xv" to choke upon. (bug reported by Les Schaffer). - - (1.0b2 released) - - + Major speedups for rotate, transform(EXTENT), and transform(AFFINE) - when using nearest neighbour resampling. - - + Modified ImageDraw to be compatible with the Arrow graphics - interface. See the handbook for details. - - + PIL now automatically loads file codecs when used as a package - (from The Dragon De Monsyne). Also included an __init__.py file - in the standard distribution. - - + The GIF encoder has been modified to produce much smaller files. - - PIL now uses a run-length encoding method to encode GIF files. - On a random selection of GIF images grabbed from the web, this - version makes the images about twice as large as the original - LZW files, where the earlier version made them over 5 times - larger. YMMV, of course. - - + Added PCX write support (works with "1", "P", "L", and "RGB") - - + Added "bitmap" and "textsize" methods to ImageDraw. - - + Improved font rendering code. Fixed a bug or two, and moved - most of the time critical stuff to C. - - + Removed "bdf2pil.py". Use "pilfont.py" instead! - - + Improved 16-bit support (still experimental, though). +0.3b2 to 1.0 final +------------------ - The following methods now support "I;16" and "I;16B" images: - "getpixel", "copy", "convert" (to and from mode "I"), "resize", - "rotate", and "transform" with nearest neighbour filters, and - "save" using the IM format. The "new" and "open" functions - also work as expected. On Windows, 16-bit files are memory - mapped. +- If there's no 16-bit integer (like on a Cray T3E), set + INT16 to the smallest integer available. Most of the + library works just fine anyway (from Bill Crutchfield) - NOTE: ALL other operations are still UNDEFINED on 16-bit images. +- Tweaks to make drawing work on big-endian platforms. - + The "paste" method now supports constant sources. +1.0c2 +----- - Just pass a colour value (a number or a tuple, depending on - the target image mode) instead of the source image. +- If PIL is built with the WITH_TKINTER flag, ImageTk can + automatically hook into a standard Tkinter build. You + no longer need to build your own Tkinter to use the + ImageTk module. - This was in fact implemented in an inefficient way in - earlier versions (the "paste" method generated a temporary - source image if you passed it a colour instead of an image). - In this version, this is handled on the C level instead. + The old way still works, though. For more information, + see Tk/install.txt. - + Added experimental "RGBa" mode support. +- Some tweaks to ImageTk to support multiple Tk interpreters + (from Greg Couch). - An "RGBa" image is an RGBA image where the colour components - have have been premultiplied with the alpha value. PIL allows - you to convert an RGBA image to an RGBa image, and to paste - RGBa images on top of RGB images. Since this saves a bunch - of multiplications and shifts, it is typically about twice - as fast an ordinary RGBA paste. +- ImageFont "load_path" now scans directory mentioned in .pth + files (from Richard Jones). - + Eliminated extra conversion step when pasting "RGBA" or "RGBa" - images on top of "RGB" images. +1.0c1 +----- - + Fixed Image.BICUBIC resampling for "RGB" images. +- The TIFF plugin has been rewritten. The new plugin fully + supports all major PIL image modes (including F and I). - + Fixed PCX image file handler to properly read 8-bit PCX - files (bug introduced in 1.0b1, reported by Bernhard - Herzog) +- The ImageFile module now includes a Parser class, which can + be used to incrementally decode an image file (while down- + loading it from the net, for example). See the handbook for + details. - + Fixed PSDraw "image" method to restore the coordinate - system. +- "show" now converts non-standard modes to "L" or "RGB" (as + appropriate), rather than writing weird things to disk for + "xv" to choke upon. (bug reported by Les Schaffer). - + Fixed "blend" problem when applied to images that was - not already loaded (reported by Edward C. Jones) +1.0b2 +----- - + Fixed -f option to "pilconvert.py" (from Anthony Baxter) +- Major speedups for rotate, transform(EXTENT), and transform(AFFINE) + when using nearest neighbour resampling. - (1.0b1 released) +- Modified ImageDraw to be compatible with the Arrow graphics + interface. See the handbook for details. - + Added Toby J. Sargeant's quantization package. To enable - quantization, use the "palette" option to "convert": +- PIL now automatically loads file codecs when used as a package + (from The Dragon De Monsyne). Also included an __init__.py file + in the standard distribution. - imOut = im.convert("P", palette=Image.ADAPTIVE) +- The GIF encoder has been modified to produce much smaller files. - This can be used with "L", "P", and "RGB" images. In this - version, dithering cannot be used with adaptive palettes. + PIL now uses a run-length encoding method to encode GIF files. + On a random selection of GIF images grabbed from the web, this + version makes the images about twice as large as the original + LZW files, where the earlier version made them over 5 times + larger. YMMV, of course. - Note: ADAPTIVE currently maps to median cut quantization - with 256 colours. The quantization package also contains - a maximum coverage quantizer, which will be supported by - future versions of PIL. +- Added PCX write support (works with "1", "P", "L", and "RGB") - + Added Eric S. Raymond's "pildriver" image calculator to the - distribution. See the docstring for more information. +- Added "bitmap" and "textsize" methods to ImageDraw. - + The "offset" method no longer dumps core if given positive - offsets (from Charles Waldman). +- Improved font rendering code. Fixed a bug or two, and moved + most of the time critical stuff to C. - + Fixed a resource leak that could cause ImageWin to run out of - GDI resources (from Roger Burnham). +- Removed "bdf2pil.py". Use "pilfont.py" instead! - + Added "arc", "chord", and "pieslice" methods to ImageDraw (inspired - by code contributed by Richard Jones). +- Improved 16-bit support (still experimental, though). - + Added experimental 16-bit support, via modes "I;16" (little endian - data) and "I;16B" (big endian). Only a few methods properly support - such images (see above). + The following methods now support "I;16" and "I;16B" images: + "getpixel", "copy", "convert" (to and from mode "I"), "resize", + "rotate", and "transform" with nearest neighbour filters, and + "save" using the IM format. The "new" and "open" functions + also work as expected. On Windows, 16-bit files are memory + mapped. - + Added XV thumbnail file handler (from Gene Cash). + NOTE: ALL other operations are still UNDEFINED on 16-bit images. - + Fixed BMP image file handler to handle palette images with small - palettes (from Rob Hooft). +- The "paste" method now supports constant sources. - + Fixed Sun raster file handler for palette images (from Charles - Waldman). + Just pass a colour value (a number or a tuple, depending on + the target image mode) instead of the source image. - + Improved various internal error messages. + This was in fact implemented in an inefficient way in + earlier versions (the "paste" method generated a temporary + source image if you passed it a colour instead of an image). + In this version, this is handled on the C level instead. - + Fixed Path constructor to handle arbitrary sequence objects. This - also affects the ImageDraw class (from Richard Jones). +- Added experimental "RGBa" mode support. - + Fixed a bug in JpegDecode that caused PIL to report "decoder error - -2" for some progressive JPEG files (reported by Magnus Källström, - who also provided samples). + An "RGBa" image is an RGBA image where the colour components + have have been premultiplied with the alpha value. PIL allows + you to convert an RGBA image to an RGBa image, and to paste + RGBa images on top of RGB images. Since this saves a bunch + of multiplications and shifts, it is typically about twice + as fast an ordinary RGBA paste. - + Fixed a bug in JpegImagePlugin that caused PIL to hang when loading - JPEG files using 16-bit quantization tables. +- Eliminated extra conversion step when pasting "RGBA" or "RGBa" + images on top of "RGB" images. - + The Image "transform" method now supports Image.QUAD transforms. - The data argument is an 8-tuple giving the upper left, lower - left, lower right, and upper right corner of the source quadri- - lateral. Also added Image.MESH transform which takes a list - of quadrilaterals. +- Fixed Image.BICUBIC resampling for "RGB" images. - + The Image "resize", "rotate", and "transform" methods now support - Image.BILINEAR (2x2) and Image.BICUBIC (4x4) resampling filters. - Filters can be used with all transform methods. +- Fixed PCX image file handler to properly read 8-bit PCX + files (bug introduced in 1.0b1, reported by Bernhard + Herzog) - + The ImageDraw "rectangle" method now includes both the right - and the bottom edges when drawing filled rectangles. +- Fixed PSDraw "image" method to restore the coordinate + system. - + The TGA decoder now works properly for runlength encoded images - which have more than one byte per pixel. +- Fixed "blend" problem when applied to images that was + not already loaded (reported by Edward C. Jones) - + "getbands" on an YCbCr image now returns ("Y", "Cb", "Cr") +- Fixed -f option to "pilconvert.py" (from Anthony Baxter) - + Some file drivers didn't handle the optional "modify" argument - to the load method. This resulted in exceptions when you used - "paste" (and other methods that modify an image in place) on a - newly opened file. +1.0b1 +----- - *** Changes from release 0.2 (b5) to 0.3 (b2) *** +- Added Toby J. Sargeant's quantization package. To enable + quantization, use the "palette" option to "convert":: - (0.3b2 released) + imOut = im.convert("P", palette=Image.ADAPTIVE) - The test suite includes 825 individual tests. + This can be used with "L", "P", and "RGB" images. In this + version, dithering cannot be used with adaptive palettes. - + An Image "getbands" method has been added. It returns a tuple - containing the individual band names for this image. To figure - out how many bands an image has, use "len(im.getbands())". + Note: ADAPTIVE currently maps to median cut quantization + with 256 colours. The quantization package also contains + a maximum coverage quantizer, which will be supported by + future versions of PIL. - + An Image "putpixel" method has been added. +- Added Eric S. Raymond's "pildriver" image calculator to the + distribution. See the docstring for more information. - + The Image "point" method can now be used to convert "L" images - to any other format, via a lookup table. That table should - contain 256 values for each band in the output image. +- The "offset" method no longer dumps core if given positive + offsets (from Charles Waldman). - + Some file drivers (including FLI/FLC, GIF, and IM) accidentally - overwrote the offset method with an internal attribute. All - drivers have been updated to use private attributes where - possible. +- Fixed a resource leak that could cause ImageWin to run out of + GDI resources (from Roger Burnham). - + The Image "histogram" method now works for "I" and "F" images. - For these modes, PIL divides the range between the min and - max values used in the image into 256 bins. You can also - pass in your own min and max values via the "extrema" option: +- Added "arc", "chord", and "pieslice" methods to ImageDraw (inspired + by code contributed by Richard Jones). - h = im.histogram(extrema=(0, 255)) +- Added experimental 16-bit support, via modes "I;16" (little endian + data) and "I;16B" (big endian). Only a few methods properly support + such images (see above). - + An Image "getextrema" method has been added. It returns the - min and max values used in the image. In this release, this - works for single band images only. +- Added XV thumbnail file handler (from Gene Cash). - + Changed the PNG driver to load and save mode "I" images as - 16-bit images. When saving, values outside the range 0..65535 - are clipped. +- Fixed BMP image file handler to handle palette images with small + palettes (from Rob Hooft). - + Fixed ImageFont.py to work with the new "pilfont" compiler. +- Fixed Sun raster file handler for palette images (from Charles + Waldman). - + Added JPEG "save" and "draft" support for mode "YCbCr" images. - Note that if you save an "YCbCr" image as a JPEG file and read - it back, it is read as an RGB file. To get around this, you - can use the "draft" method: +- Improved various internal error messages. - im = Image.open("color.jpg") - im.draft("YCbCr", im.size) +- Fixed Path constructor to handle arbitrary sequence objects. This + also affects the ImageDraw class (from Richard Jones). - + Read "RGBA" TGA images. Also fixed the orientation bug; all - images should now come out the right way. +- Fixed a bug in JpegDecode that caused PIL to report "decoder error + -2" for some progressive JPEG files (reported by Magnus Källström, + who also provided samples). - + Changed mode name (and internal representation) from "YCrCb" - to "YCbCr" (!) - *** WARNING: MAY BREAK EXISTING CODE *** +- Fixed a bug in JpegImagePlugin that caused PIL to hang when loading + JPEG files using 16-bit quantization tables. - (0.3b1 released) +- The Image "transform" method now supports Image.QUAD transforms. + The data argument is an 8-tuple giving the upper left, lower + left, lower right, and upper right corner of the source quadri- + lateral. Also added Image.MESH transform which takes a list + of quadrilaterals. - The test suite includes 750 individual tests. +- The Image "resize", "rotate", and "transform" methods now support + Image.BILINEAR (2x2) and Image.BICUBIC (4x4) resampling filters. + Filters can be used with all transform methods. - + The "pilfont" package is now included in the standard PIL - distribution. The pilfont utility can be used to convert - X BDF and PCF raster font files to a format understood by - the ImageFont module. +- The ImageDraw "rectangle" method now includes both the right + and the bottom edges when drawing filled rectangles. - + GIF files are now interlaced by default. To write a - non-interlaced file, pass interlace=0 to the "save" - method. +- The TGA decoder now works properly for runlength encoded images + which have more than one byte per pixel. - + The default string format has changed for the "fromstring" - and "tostring" methods. - *** WARNING: MAY BREAK EXISTING CODE *** +- "getbands" on an YCbCr image now returns ("Y", "Cb", "Cr") - NOTE: If no extra arguments are given, the first line in - the string buffer is the top line of the image, instead of - the bottom line. For RGB images, the string now contains - 3 bytes per pixel instead of 4. These changes were made - to make the methods compatible with the "fromstring" - factory function. +- Some file drivers didn't handle the optional "modify" argument + to the load method. This resulted in exceptions when you used + "paste" (and other methods that modify an image in place) on a + newly opened file. - To get the old behaviour, use the following syntax: +0.3b2 +----- - data = im.tostring("raw", "RGBX", 0, -1) - im.fromstring(data, "raw", "RGBX", 0, -1) +The test suite includes 825 individual tests. - + "new" no longer gives a MemoryError if the width or height - is zero (this only happened on platforms where malloc(0) - or calloc(0) returns NULL). +- An Image "getbands" method has been added. It returns a tuple + containing the individual band names for this image. To figure + out how many bands an image has, use "len(im.getbands())". - + "new" now adds a default palette object to "P" images. +- An Image "putpixel" method has been added. - + You can now convert directly between all modes supported by - PIL. When converting colour images to "P", PIL defaults to - a "web" palette and dithering. When converting greyscale - images to "1", PIL uses a thresholding and dithering. +- The Image "point" method can now be used to convert "L" images + to any other format, via a lookup table. That table should + contain 256 values for each band in the output image. - + Added a "dither" option to "convert". By default, "convert" - uses floyd-steinberg error diffusion for "P" and "1" targets, - so this option is only used to *disable* dithering. Allowed - values are NONE (no dithering) or FLOYDSTEINBERG (default). +- Some file drivers (including FLI/FLC, GIF, and IM) accidentally + overwrote the offset method with an internal attribute. All + drivers have been updated to use private attributes where + possible. - imOut = im.convert("P", dither=Image.NONE) +- The Image "histogram" method now works for "I" and "F" images. + For these modes, PIL divides the range between the min and + max values used in the image into 256 bins. You can also + pass in your own min and max values via the "extrema" option:: - + Added a full set of "I" decoders. You can use "fromstring" - (and file decoders) to read any standard integer type as an - "I" image. + h = im.histogram(extrema=(0, 255)) - + Added some support for "YCbCr" images (creation, conversion - from/to "L" and "RGB", IM YCC load/save) +- An Image "getextrema" method has been added. It returns the + min and max values used in the image. In this release, this + works for single band images only. - + "getpixel" now works properly with fractional coordinates. +- Changed the PNG driver to load and save mode "I" images as + 16-bit images. When saving, values outside the range 0..65535 + are clipped. - + ImageDraw "setink" now works with "I", "F", "RGB", "RGBA", - "RGBX", "CMYK", and "YCbCr" images. +- Fixed ImageFont.py to work with the new "pilfont" compiler. - + ImImagePlugin no longer attaches palettes to "RGB" images. +- Added JPEG "save" and "draft" support for mode "YCbCr" images. + Note that if you save an "YCbCr" image as a JPEG file and read + it back, it is read as an RGB file. To get around this, you + can use the "draft" method:: - + Various minor fixes. + im = Image.open("color.jpg") + im.draft("YCbCr", im.size) - (0.3a4 released) +- Read "RGBA" TGA images. Also fixed the orientation bug; all + images should now come out the right way. - + Added experimental IPTC/NAA support. +- Changed mode name (and internal representation) from "YCrCb" + to "YCbCr" (!) + **WARNING: MAY BREAK EXISTING CODE** - + Eliminated AttributeError exceptions after "crop" (from - Skip Montanaro) +0.3b1 +----- - + Reads some uncompressed formats via memory mapping (this - is currently supported on Win32 only) +The test suite includes 750 individual tests. - + Fixed some last minute glitches in the last alpha release - (Types instead of types in Image.py, version numbers, etc.) +- The "pilfont" package is now included in the standard PIL + distribution. The pilfont utility can be used to convert + X BDF and PCF raster font files to a format understood by + the ImageFont module. - + Eliminated some more bogus compiler warnings. +- GIF files are now interlaced by default. To write a + non-interlaced file, pass interlace=0 to the "save" + method. - + Various fixes to make PIL compile and run smoother on Macs - (from Jack Jansen). +- The default string format has changed for the "fromstring" + and "tostring" methods. + **WARNING: MAY BREAK EXISTING CODE** - + Fixed "fromstring" and "tostring" for mode "I" images. + NOTE: If no extra arguments are given, the first line in + the string buffer is the top line of the image, instead of + the bottom line. For RGB images, the string now contains + 3 bytes per pixel instead of 4. These changes were made + to make the methods compatible with the "fromstring" + factory function. - (0.3a3 released) + To get the old behaviour, use the following syntax:: - The test suite includes 530 individual tests. + data = im.tostring("raw", "RGBX", 0, -1) + im.fromstring(data, "raw", "RGBX", 0, -1) - + Eliminated unexpected side-effect in "paste" with matte. "paste" - now works properly also if compiled with "gcc". +- "new" no longer gives a MemoryError if the width or height + is zero (this only happened on platforms where malloc(0) + or calloc(0) returns NULL). - + Adapted to Python 1.5 (build issues only) +- "new" now adds a default palette object to "P" images. - + Fixed the ImageDraw "point" method to draw also the last - point (!). +- You can now convert directly between all modes supported by + PIL. When converting colour images to "P", PIL defaults to + a "web" palette and dithering. When converting greyscale + images to "1", PIL uses a thresholding and dithering. - + Added "I" and "RGBX" support to Image.new. +- Added a "dither" option to "convert". By default, "convert" + uses floyd-steinberg error diffusion for "P" and "1" targets, + so this option is only used to *disable* dithering. Allowed + values are NONE (no dithering) or FLOYDSTEINBERG (default). + :: - + The plugin path is now properly prepended to the module search - path when a plugin module is imported. + imOut = im.convert("P", dither=Image.NONE) - + Added "draw" method to the ImageWin.Dib class. This is used by - Topaz to print images on Windows printers. +- Added a full set of "I" decoders. You can use "fromstring" + (and file decoders) to read any standard integer type as an + "I" image. - + "convert" now supports conversions from "P" to "1" and "F". +- Added some support for "YCbCr" images (creation, conversion + from/to "L" and "RGB", IM YCC load/save) - + "paste" can now take a colour instead of an image as the first argument. - The colour must match the colour argument given to the new function, and - match the mode of the target image. +- "getpixel" now works properly with fractional coordinates. - + Fixed "paste" to allow a mask also for mode "F" images. +- ImageDraw "setink" now works with "I", "F", "RGB", "RGBA", + "RGBX", "CMYK", and "YCbCr" images. - + The BMP driver now saves mode "1" images. When loading images, the mode - is set to "L" for 8-bit files with greyscale palettes, and to "P" for - other 8-bit files. +- ImImagePlugin no longer attaches palettes to "RGB" images. - + The IM driver now reads and saves "1" images (file modes "0 1" or "L 1"). +- Various minor fixes. - + The JPEG and GIF drivers now saves "1" images. For JPEG, the image - is saved as 8-bit greyscale (it will load as mode "L"). For GIF, the - image will be loaded as a "P" image. +0.3a4 +----- - + Fixed a potential buffer overrun in the GIF encoder. +- Added experimental IPTC/NAA support. - (0.3a2 released) +- Eliminated AttributeError exceptions after "crop" (from + Skip Montanaro) - The test suite includes 400 individual tests. +- Reads some uncompressed formats via memory mapping (this + is currently supported on Win32 only) - + Improvements to the test suite revealed a number of minor bugs, which - are all fixed. Note that crop/paste, 32-bit ImageDraw, and ImageFont - are still weak spots in this release. +- Fixed some last minute glitches in the last alpha release + (Types instead of types in Image.py, version numbers, etc.) - + Added "putpalette" method to the Image class. You can use this - to add or modify the palette for "P" and "L" images. If a palette - is added to an "L" image, it is automatically converted to a "P" - image. +- Eliminated some more bogus compiler warnings. - + Fixed ImageDraw to properly handle 32-bit image memories - ("RGB", "RGBA", "CMYK", "F") +- Various fixes to make PIL compile and run smoother on Macs + (from Jack Jansen). - + Fixed "fromstring" and "tostring" not to mess up the mode attribute - in default mode. +- Fixed "fromstring" and "tostring" for mode "I" images. - + Changed ImPlatform.h to work on CRAY's (don't have one at home, so I - haven't tried it). The previous version assumed that either "short" - or "int" were 16-bit wide. PIL still won't compile on platforms where - neither "short", "int" nor "long" are 32-bit wide. +0.3a3 +----- - + Added file= and data= keyword arguments to PhotoImage and BitmapImage. - This allows you to use them as drop-in replacements for the corre- - sponding Tkinter classes. +The test suite includes 530 individual tests. - + Removed bogus references to the crack coder (ImagingCrack). +- Eliminated unexpected side-effect in "paste" with matte. "paste" + now works properly also if compiled with "gcc". - (0.3a1 released) +- Adapted to Python 1.5 (build issues only) - + Make sure image is loaded in "tostring". +- Fixed the ImageDraw "point" method to draw also the last + point (!). - + Added floating point packer (native 32-bit floats only). +- Added "I" and "RGBX" support to Image.new. - *** Changes from release 0.1b1 to 0.2 (b5) *** +- The plugin path is now properly prepended to the module search + path when a plugin module is imported. - + Modified "fromstring" and "tostring" methods to use file codecs. - Also added "fromstring" factory method to create an image directly - from data in a string. +- Added "draw" method to the ImageWin.Dib class. This is used by + Topaz to print images on Windows printers. - + Added support for 32-bit floating point images (mode "F"). You - can convert between "L" and "F" images, and apply a subset of the - available image processing methods on the "F" image. You can also - read virtually any data format into a floating point image memory; - see the section on "Decoding Floating Point Data" in the handbook - for more information. +- "convert" now supports conversions from "P" to "1" and "F". - (0.2b5 released; on windows only) +- "paste" can now take a colour instead of an image as the first argument. + The colour must match the colour argument given to the new function, and + match the mode of the target image. - + Fixed the tobitmap() method to work properly for small bitmaps. +- Fixed "paste" to allow a mask also for mode "F" images. - + Added RMS and standard deviation to the ImageStat.Stat class. Also - modified the constructor to take an optional feature mask, and also - to accept either an image or a list containing the histogram data. +- The BMP driver now saves mode "1" images. When loading images, the mode + is set to "L" for 8-bit files with greyscale palettes, and to "P" for + other 8-bit files. - + The BitmapImage code in ImageTk can now use a special bitmap - decoder, which has to be patched into Tk. See the "Tk/pilbitmap.txt" - file for details. If not installed, bitmaps are transferred to Tk as - XBM strings. +- The IM driver now reads and saves "1" images (file modes "0 1" or "L 1"). - + The PhotoImage code in ImageTk now uses a Tcl command ("PyImagingPaste") - instead of a special image type. This gives somewhat better performance, - and also allows PIL to support transparency. - *** WARNING: TKAPPINIT MUST BE MODIFIED *** +- The JPEG and GIF drivers now saves "1" images. For JPEG, the image + is saved as 8-bit greyscale (it will load as mode "L"). For GIF, the + image will be loaded as a "P" image. - + ImageTk now honours the alpha layer in RGBA images. Only fully - transparent pixels are made transparent (that is, the alpha layer - is treated as a mask). To treat the alpha laters as a matte, you - must paste the image on the background before handing it over to - ImageTk. +- Fixed a potential buffer overrun in the GIF encoder. - + Added McIdas reader (supports 8-bit images only). +0.3a2 +----- - + PIL now preloads drivers for BMP, GIF, JPEG, PPM, and TIFF. As - long as you only load and save these formats, you don't have to - wait for a full scan for drivers. To force scanning, call the - Image.init() function. +The test suite includes 400 individual tests. - + The "seek" and "tell" methods are now always available, also for - single-frame images. +- Improvements to the test suite revealed a number of minor bugs, which + are all fixed. Note that crop/paste, 32-bit ImageDraw, and ImageFont + are still weak spots in this release. - + Added optional mask argument to histogram method. The mask may - be an "1" or "L" image with the same size as the original image. - Only pixels where the mask is non-zero are included in the - histogram. +- Added "putpalette" method to the Image class. You can use this + to add or modify the palette for "P" and "L" images. If a palette + is added to an "L" image, it is automatically converted to a "P" + image. - + The "paste" method now allows you to specify only the lower left - corner (a 2-tuple), instead of the full region (a 4-tuple). +- Fixed ImageDraw to properly handle 32-bit image memories + ("RGB", "RGBA", "CMYK", "F") - + Reverted to old plugin scanning model; now scans all directory - names in the path when looking for plugins. +- Fixed "fromstring" and "tostring" not to mess up the mode attribute + in default mode. - + Added PIXAR raster support. Only uncompressed ("dumped") RGB - images can currently be read (based on information provided - by Greg Coats). +- Changed ImPlatform.h to work on CRAY's (don't have one at home, so I + haven't tried it). The previous version assumed that either "short" + or "int" were 16-bit wide. PIL still won't compile on platforms where + neither "short", "int" nor "long" are 32-bit wide. - + Added FlashPix (FPX) read support. Reads all pixel formats, but - only the highest resolution is read, and the viewing transform is - currently ignored. +- Added file= and data= keyword arguments to PhotoImage and BitmapImage. + This allows you to use them as drop-in replacements for the corre- + sponding Tkinter classes. - + Made PNG encoding somewhat more efficient in "optimize" mode; a - bug in 0.2b4 didn't enable all predictor filters when optimized - storage were requested. +- Removed bogus references to the crack coder (ImagingCrack). - + Added Microsoft Image Composer (MIC) read support. When opened, - the first sprite in the file is loaded. You can use the seek method - to load additional sprites from the file. +0.3a1 +----- - + Properly reads "P" and "CMYK" PSD images. +- Make sure image is loaded in "tostring". - + "pilconvert" no longer optimizes by default; use the -o option to - make the file as small as possible (at the expense of speed); use - the -q option to set the quality when compressing to JPEG. +- Added floating point packer (native 32-bit floats only). - + Fixed "crop" not to drop the palette for "P" images. +0.1b1 to 0.2 (b5) +----------------- - + Added and verified FLC support. +- Modified "fromstring" and "tostring" methods to use file codecs. + Also added "fromstring" factory method to create an image directly + from data in a string. - + Paste with "L" or "RGBA" alpha is now several times faster on most - platforms. +- Added support for 32-bit floating point images (mode "F"). You + can convert between "L" and "F" images, and apply a subset of the + available image processing methods on the "F" image. You can also + read virtually any data format into a floating point image memory; + see the section on "Decoding Floating Point Data" in the handbook + for more information. - + Changed Image.new() to initialize the image to black, as described - in the handbook. To get an uninitialized image, use None as the - colour. +0.2b5 released; on windows only +------------------------------- - + Fixed the PDF encoder to produce a valid header; Acrobat no longer - complains when you load PDF images created by PIL. +- Fixed the tobitmap() method to work properly for small bitmaps. - + PIL only scans fully-qualified directory names in the path when - looking for plugins. - *** WARNING: MAY BREAK EXISTING CODE *** +- Added RMS and standard deviation to the ImageStat.Stat class. Also + modified the constructor to take an optional feature mask, and also + to accept either an image or a list containing the histogram data. - + Faster implementation of "save" used when filename is given, - or when file object has "fileno" and "flush" methods. +- The BitmapImage code in ImageTk can now use a special bitmap + decoder, which has to be patched into Tk. See the "Tk/pilbitmap.txt" + file for details. If not installed, bitmaps are transferred to Tk as + XBM strings. - + Don't crash in "crop" if region extends outside the source image. +- The PhotoImage code in ImageTk now uses a Tcl command ("PyImagingPaste") + instead of a special image type. This gives somewhat better performance, + and also allows PIL to support transparency. + **WARNING: TKAPPINIT MUST BE MODIFIED** - + Eliminated a massive memory leak in the "save" function. +- ImageTk now honours the alpha layer in RGBA images. Only fully + transparent pixels are made transparent (that is, the alpha layer + is treated as a mask). To treat the alpha laters as a matte, you + must paste the image on the background before handing it over to + ImageTk. - + The GIF decoder doesn't crash if the code size is set to an illegal - value. This could happen since another bug didn't handle local - palettes properly if they didn't have the same size as the - global palette (not very common). +- Added McIdas reader (supports 8-bit images only). - + Added predictor support (TIFF 6.0 section 14) to the TIFF decoder. +- PIL now preloads drivers for BMP, GIF, JPEG, PPM, and TIFF. As + long as you only load and save these formats, you don't have to + wait for a full scan for drivers. To force scanning, call the + Image.init() function. - + Fixed palette and padding problems in BMP driver. Now properly - writes "1", "L", "P" and "RGB" images. +- The "seek" and "tell" methods are now always available, also for + single-frame images. - + Fixed getpixel()/getdata() to return correct pixel values. +- Added optional mask argument to histogram method. The mask may + be an "1" or "L" image with the same size as the original image. + Only pixels where the mask is non-zero are included in the + histogram. - + Added PSD (PhotoShop) read support. Reads both uncompressed - and compressed images of most types. +- The "paste" method now allows you to specify only the lower left + corner (a 2-tuple), instead of the full region (a 4-tuple). - + Added GIF write support (writes "uncompressed" GIF files only, - due to unresolvable licensing issues). The "gifmaker.py" script - can be used to create GIF animations. +- Reverted to old plugin scanning model; now scans all directory + names in the path when looking for plugins. - + Reads 8-bit "L" and "P" TGA images. Also reads 16-bit "RGB" - images. +- Added PIXAR raster support. Only uncompressed ("dumped") RGB + images can currently be read (based on information provided + by Greg Coats). - + Added FLI read support. This driver has only been tested - on a few FLI samples. +- Added FlashPix (FPX) read support. Reads all pixel formats, but + only the highest resolution is read, and the viewing transform is + currently ignored. - + Reads 2-bit and 4-bit PCX images. +- Made PNG encoding somewhat more efficient in "optimize" mode; a + bug in 0.2b4 didn't enable all predictor filters when optimized + storage were requested. - + Added MSP read and write support. Both version 1 and 2 can be - read, but only version 1 (uncompressed) files are written. +- Added Microsoft Image Composer (MIC) read support. When opened, + the first sprite in the file is loaded. You can use the seek method + to load additional sprites from the file. - + Fixed a bug in the FLI/FLC identification code that caused the - driver to raise an exception when parsing valid FLI/FLC files. +- Properly reads "P" and "CMYK" PSD images. - + Improved performance when loading file format plugins, and when - opening files. +- "pilconvert" no longer optimizes by default; use the -o option to + make the file as small as possible (at the expense of speed); use + the -q option to set the quality when compressing to JPEG. - + Added GIF animation support, via the "seek" and "tell" methods. - You can use "player.py" to play an animated GIF file. +- Fixed "crop" not to drop the palette for "P" images. - + Removed MNG support, since the spec is changing faster than I - can change the code. I've added support for the experimental - ARG format instead. Contact me for more information on this - format. +- Added and verified FLC support. - + Added keyword options to the "save" method. The following options - are currently supported: +- Paste with "L" or "RGBA" alpha is now several times faster on most + platforms. - Format Option Description - -------------------------------------------------------- - JPEG optimize Minimize output file at the - expense of compression speed. +- Changed Image.new() to initialize the image to black, as described + in the handbook. To get an uninitialized image, use None as the + colour. - JPEG progressive Enable progressive output. - The option value is ignored. +- Fixed the PDF encoder to produce a valid header; Acrobat no longer + complains when you load PDF images created by PIL. - JPEG quality Set compression quality (1-100). - The default value is 75. +- PIL only scans fully-qualified directory names in the path when + looking for plugins. + **WARNING: MAY BREAK EXISTING CODE** - JPEG smooth Smooth dithered images. - Value is strength (1-100). - Default is off (0). +- Faster implementation of "save" used when filename is given, + or when file object has "fileno" and "flush" methods. - PNG optimize Minimize output file at the - expense of compression speed. +- Don't crash in "crop" if region extends outside the source image. - Expect more options in future releases. Also note that - file writers silently ignore unknown options. +- Eliminated a massive memory leak in the "save" function. - + Plugged memory leaks in the PNG and TIFF decoders. +- The GIF decoder doesn't crash if the code size is set to an illegal + value. This could happen since another bug didn't handle local + palettes properly if they didn't have the same size as the + global palette (not very common). - + Added PNG write support. +- Added predictor support (TIFF 6.0 section 14) to the TIFF decoder. - + (internal) RGB unpackers and converters now set the pad byte - to 255 (full opacity). +- Fixed palette and padding problems in BMP driver. Now properly + writes "1", "L", "P" and "RGB" images. - + Properly handles the "transparency" property for GIF, PNG - and XPM files. +- Fixed getpixel()/getdata() to return correct pixel values. - + Added a "putalpha" method, allowing you to attach a "1" or "L" - image as the alpha layer to an "RGBA" image. +- Added PSD (PhotoShop) read support. Reads both uncompressed + and compressed images of most types. - + Various improvements to the sample scripts: +- Added GIF write support (writes "uncompressed" GIF files only, + due to unresolvable licensing issues). The "gifmaker.py" script + can be used to create GIF animations. - "pilconvert" Carries out some extra tricks in order to make - the resulting file as small as possible. +- Reads 8-bit "L" and "P" TGA images. Also reads 16-bit "RGB" + images. - "explode" (NEW) Split an image sequence into individual frames. +- Added FLI read support. This driver has only been tested + on a few FLI samples. - "gifmaker" (NEW) Convert a sequence file into a GIF animation. - Note that the GIF encoder create "uncompressed" GIF - files, so animations created by this script are - rather large (typically 2-5 times the compressed - sizes). +- Reads 2-bit and 4-bit PCX images. - "image2py" (NEW) Convert a single image to a python module. See - comments in this script for details. +- Added MSP read and write support. Both version 1 and 2 can be + read, but only version 1 (uncompressed) files are written. - "player" If multiple images are given on the command line, - they are interpreted as frames in a sequence. The - script assumes that they all have the same size. - Also note that this script now can play FLI/FLC - and GIF animations. +- Fixed a bug in the FLI/FLC identification code that caused the + driver to raise an exception when parsing valid FLI/FLC files. - This player can also execute embedded Python - animation applets (ARG format only). +- Improved performance when loading file format plugins, and when + opening files. - "viewer" Transparent images ("P" with transparency property, - and "RGBA") are superimposed on the standard Tk back- - ground. +- Added GIF animation support, via the "seek" and "tell" methods. + You can use "player.py" to play an animated GIF file. - + Fixed colour argument to "new". For multilayer images, pass a - tuple: (Red, Green, Blue), (Red, Green, Blue, Alpha), or (Cyan, - Magenta, Yellow, Black). +- Removed MNG support, since the spec is changing faster than I + can change the code. I've added support for the experimental + ARG format instead. Contact me for more information on this + format. - + Added XPM (X pixmap) read support. +- Added keyword options to the "save" method. The following options + are currently supported: - (0.2b3 released) + .. list-table:: + :widths: 25 25 50 + :header-rows: 1 - + Added MNG (multi-image network graphics) read support. "Ming" - is a proposed animation standard, based on the PNG file format. + * - Format + - Option + - Description + * - JPEG + - optimize + - Minimize output file at the expense of compression speed. + * - JPEG + - progressive + - Enable progressive output. The option value is ignored. + * - JPEG + - quality + - Set compression quality (1-100). The default value is 75. + * - JPEG + - smooth + - Smooth dithered images. Value is strength (1-100). Default is off (0). + * - PNG + - optimize + - Minimize output file at the expense of compression speed. - You can use the "player" sample script to display some flavours - of this format. The MNG standard is still under development, - as is this driver. More information, including sample files, - can be found at + Expect more options in future releases. Also note that + file writers silently ignore unknown options. - + Added a "verify" method to images loaded from file. This method - scans the file for errors, without actually decoding the image - data, and raises a suitable exception if it finds any problems. - Currently implemented for PNG and MNG files only. +- Plugged memory leaks in the PNG and TIFF decoders. - + Added support for interlaced GIF images. +- Added PNG write support. - + Added PNG read support -- if linked with the ZLIB compression library, - PIL reads all kinds of PNG images, except interlaced files. +- (internal) RGB unpackers and converters now set the pad byte + to 255 (full opacity). - + Improved PNG identification support -- doesn't mess up on unknown - chunks, identifies all possible PNG modes, and verifies checksum - on PNG header chunks. +- Properly handles the "transparency" property for GIF, PNG + and XPM files. - + Added an experimental reader for placable Windows Meta Files (WMF). - This reader is still very incomplete, but it illustrates how PIL's - drawing capabilities can be used to render vector and metafile - formats. +- Added a "putalpha" method, allowing you to attach a "1" or "L" + image as the alpha layer to an "RGBA" image. - + Added restricted drivers for images from Image Tools (greyscale - only) and LabEye/IFUNC (common interchange modes only). +- Various improvements to the sample scripts: - + Some minor improvements to the sample scripts provided in the - "Scripts" directory. + .. list-table:: + :widths: 25 75 - + The test images have been moved to the "Images" directory. + * - pilconvert + - Carries out some extra tricks in order to make + the resulting file as small as possible. + * - explode + - (NEW) Split an image sequence into individual frames. + * - gifmaker + - (NEW) Convert a sequence file into a GIF animation. + Note that the GIF encoder create "uncompressed" GIF + files, so animations created by this script are + rather large (typically 2-5 times the compressed + sizes). + * - image2py + - (NEW) Convert a single image to a python module. See + comments in this script for details. + * - player + - If multiple images are given on the command line, + they are interpreted as frames in a sequence. The + script assumes that they all have the same size. + Also note that this script now can play FLI/FLC + and GIF animations. + + This player can also execute embedded Python + animation applets (ARG format only). + * - viewer + - Transparent images ("P" with transparency property, + and "RGBA") are superimposed on the standard Tk background. + +- Fixed colour argument to "new". For multilayer images, pass a + tuple: (Red, Green, Blue), (Red, Green, Blue, Alpha), or (Cyan, + Magenta, Yellow, Black). + +- Added XPM (X pixmap) read support. + +0.2b3 +----- + +- Added MNG (multi-image network graphics) read support. "Ming" + is a proposed animation standard, based on the PNG file format. + + You can use the "player" sample script to display some flavours + of this format. The MNG standard is still under development, + as is this driver. More information, including sample files, + can be found at + +- Added a "verify" method to images loaded from file. This method + scans the file for errors, without actually decoding the image + data, and raises a suitable exception if it finds any problems. + Currently implemented for PNG and MNG files only. + +- Added support for interlaced GIF images. + +- Added PNG read support -- if linked with the ZLIB compression library, + PIL reads all kinds of PNG images, except interlaced files. + +- Improved PNG identification support -- doesn't mess up on unknown + chunks, identifies all possible PNG modes, and verifies checksum + on PNG header chunks. + +- Added an experimental reader for placable Windows Meta Files (WMF). + This reader is still very incomplete, but it illustrates how PIL's + drawing capabilities can be used to render vector and metafile + formats. + +- Added restricted drivers for images from Image Tools (greyscale + only) and LabEye/IFUNC (common interchange modes only). + +- Some minor improvements to the sample scripts provided in the + "Scripts" directory. + +- The test images have been moved to the "Images" directory. - (0.2b2 released) - (0.2b1 released; Windows only) +0.2b2 released. 0.2b1 released for Windows only +----------------------------------------------- - + Fixed filling of complex polygons. The ImageDraw "line" and - "polygon" methods also accept Path objects. +- Fixed filling of complex polygons. The ImageDraw "line" and + "polygon" methods also accept Path objects. - + The ImageTk "PhotoImage" object can now be constructed directly - from an image. You can also pass the object itself to Tkinter, - instead of using the "image" attribute. Finally, using "paste" - on a displayed image automatically updates the display. +- The ImageTk "PhotoImage" object can now be constructed directly + from an image. You can also pass the object itself to Tkinter, + instead of using the "image" attribute. Finally, using "paste" + on a displayed image automatically updates the display. - + The ImageTk "BitmapImage" object allows you to create transparent - overlays from 1-bit images. You can pass the object itself to - Tkinter. The constructor takes the same arguments as the Tkinter - BitmapImage class; use the "foreground" option to set the colour - of the overlay. +- The ImageTk "BitmapImage" object allows you to create transparent + overlays from 1-bit images. You can pass the object itself to + Tkinter. The constructor takes the same arguments as the Tkinter + BitmapImage class; use the "foreground" option to set the colour + of the overlay. - + Added a "putdata" method to the Image class. This can be used to - load a 1-layer image with data from a sequence object or a string. - An optional floating point scale and offset can be used to adjust - the data to fit into the 8-bit pixel range. Also see the "getdata" - method. +- Added a "putdata" method to the Image class. This can be used to + load a 1-layer image with data from a sequence object or a string. + An optional floating point scale and offset can be used to adjust + the data to fit into the 8-bit pixel range. Also see the "getdata" + method. - + Added the EXTENT method to the Image "transform" method. This can - be used to quickly crop, stretch, shrink, or mirror a subregion - from another image. +- Added the EXTENT method to the Image "transform" method. This can + be used to quickly crop, stretch, shrink, or mirror a subregion + from another image. - + Adapted to Python 1.4. +- Adapted to Python 1.4. - + Added a project makefile for Visual C++ 4.x. This allows you to - easily build a dynamically linked version of PIL for Windows 95 - and NT. +- Added a project makefile for Visual C++ 4.x. This allows you to + easily build a dynamically linked version of PIL for Windows 95 + and NT. - + A Tk "booster" patch for Windows is available. It gives dramatic - performance improvements for some displays. Has been tested with - Tk 4.2 only, but is likely to work with Tk 4.1 as well. See the Tk - subdirectory for details. +- A Tk "booster" patch for Windows is available. It gives dramatic + performance improvements for some displays. Has been tested with + Tk 4.2 only, but is likely to work with Tk 4.1 as well. See the Tk + subdirectory for details. - + You can now save 1-bit images in the XBM format. In addition, the - Image class now provides a "tobitmap" method which returns a string - containing an XBM representation of the image. Quite handy to use - with Tk. +- You can now save 1-bit images in the XBM format. In addition, the + Image class now provides a "tobitmap" method which returns a string + containing an XBM representation of the image. Quite handy to use + with Tk. - + More conversions, including "RGB" to "1" and more. +- More conversions, including "RGB" to "1" and more. - (0.2a1 released) +0.2a1 +----- - + Where earlier versions accepted lists, this version accepts arbitrary - Python sequences (including strings, in some cases). A few resource - leaks were plugged in the process. +- Where earlier versions accepted lists, this version accepts arbitrary + Python sequences (including strings, in some cases). A few resource + leaks were plugged in the process. - + The Image "paste" method now allows the box to extend outside - the target image. The size of the box, the image to be pasted, - and the optional mask must still match. +- The Image "paste" method now allows the box to extend outside + the target image. The size of the box, the image to be pasted, + and the optional mask must still match. - + The ImageDraw module now supports filled polygons, outlined and - filled ellipses, and text. Font support is rudimentary, though. +- The ImageDraw module now supports filled polygons, outlined and + filled ellipses, and text. Font support is rudimentary, though. - + The Image "point" method now takes an optional mode argument, - allowing you to convert the image while translating it. Currently, - this can only be used to convert "L" or "P" images to "1" images - (creating thresholded images or "matte" masks). +- The Image "point" method now takes an optional mode argument, + allowing you to convert the image while translating it. Currently, + this can only be used to convert "L" or "P" images to "1" images + (creating thresholded images or "matte" masks). - + An Image "getpixel" method has been added. For single band images, - it returns the pixel value at a given position as an integer. - For n-band images, it returns an n-tuple of integers. +- An Image "getpixel" method has been added. For single band images, + it returns the pixel value at a given position as an integer. + For n-band images, it returns an n-tuple of integers. - + An Image "getdata" method has been added. It returns a sequence - object representing the image as a 1-dimensional array. Only len() - and [] can be used with this sequence. This method returns a - reference to the existing image data, so changes in the image - will be immediately reflected in the sequence object. +- An Image "getdata" method has been added. It returns a sequence + object representing the image as a 1-dimensional array. Only len() + and [] can be used with this sequence. This method returns a + reference to the existing image data, so changes in the image + will be immediately reflected in the sequence object. - + Fixed alignment problems in the Windows BMP writer. +- Fixed alignment problems in the Windows BMP writer. - + If converting an "RGB" image to "RGB" or "L", you can give a second - argument containing a colour conversion matrix. +- If converting an "RGB" image to "RGB" or "L", you can give a second + argument containing a colour conversion matrix. - + An Image "getbbox" method has been added. It returns the bounding - box of data in an image, considering the value 0 as background. +- An Image "getbbox" method has been added. It returns the bounding + box of data in an image, considering the value 0 as background. - + An Image "offset" method has been added. It returns a new image - where the contents of the image have been offset the given distance - in X and/or Y direction. Data wraps between edges. +- An Image "offset" method has been added. It returns a new image + where the contents of the image have been offset the given distance + in X and/or Y direction. Data wraps between edges. - + Saves PDF images. The driver creates a binary PDF 1.1 files, using - JPEG compression for "L", "RGB", and "CMYK" images, and hex encoding - (same as for PostScript) for other formats. +- Saves PDF images. The driver creates a binary PDF 1.1 files, using + JPEG compression for "L", "RGB", and "CMYK" images, and hex encoding + (same as for PostScript) for other formats. - + The "paste" method now accepts "1" masks. Zero means transparent, - any other pixel value means opaque. This is faster than using an - "L" transparency mask. +- The "paste" method now accepts "1" masks. Zero means transparent, + any other pixel value means opaque. This is faster than using an + "L" transparency mask. - + Properly writes EPS files (and properly prints images to PostScript - printers as well). +- Properly writes EPS files (and properly prints images to PostScript + printers as well). - + Reads 4-bit BMP files, as well as 4 and 8-bit Windows ICO and CUR - files. Cursor animations are not supported. +- Reads 4-bit BMP files, as well as 4 and 8-bit Windows ICO and CUR + files. Cursor animations are not supported. - + Fixed alignment problems in the Sun raster loader. +- Fixed alignment problems in the Sun raster loader. - + Added "draft" and "thumbnail" methods. The draft method is used - to optimize loading of JPEG and PCD files, the thumbnail method is - used to create a thumbnail representation of an image. +- Added "draft" and "thumbnail" methods. The draft method is used + to optimize loading of JPEG and PCD files, the thumbnail method is + used to create a thumbnail representation of an image. - + Added Windows display support, via the ImageWin class (see the - handbook for details). +- Added Windows display support, via the ImageWin class (see the + handbook for details). - + Added raster conversion for EPS files. This requires GNU or Aladdin - Ghostscript, and probably works on UNIX only. +- Added raster conversion for EPS files. This requires GNU or Aladdin + Ghostscript, and probably works on UNIX only. - + Reads PhotoCD (PCD) images. The base resolution (768x512) can be - read from a PhotoCD file. +- Reads PhotoCD (PCD) images. The base resolution (768x512) can be + read from a PhotoCD file. - + Eliminated some compiler warnings. Bindings now compile cleanly in C++ - mode. Note that the Imaging library itself must be compiled in C mode. +- Eliminated some compiler warnings. Bindings now compile cleanly in C++ + mode. Note that the Imaging library itself must be compiled in C mode. - + Added "bdf2pil.py", which converts BDF fonts into images with associated - metrics. This is definitely work in progress. For info, see description - in script for details. +- Added "bdf2pil.py", which converts BDF fonts into images with associated + metrics. This is definitely work in progress. For info, see description + in script for details. - + Fixed a bug in the "ImageEnhance.py" module. +- Fixed a bug in the "ImageEnhance.py" module. - + Fixed a bug in the netpbm save hack in "GifImagePlugin.py" +- Fixed a bug in the netpbm save hack in "GifImagePlugin.py" - + Fixed 90 and 270 degree rotation of rectangular images. +- Fixed 90 and 270 degree rotation of rectangular images. - + Properly reads 8-bit TIFF palette-color images. +- Properly reads 8-bit TIFF palette-color images. - + Reads plane separated RGB and CMYK TIFF images. +- Reads plane separated RGB and CMYK TIFF images. - + Added driver debug mode. This is enabled by setting Image.DEBUG - to a non-zero value. Try the -D option to "pilfile.py" and see what - happens. +- Added driver debug mode. This is enabled by setting Image.DEBUG + to a non-zero value. Try the -D option to "pilfile.py" and see what + happens. - + Don't crash on "atend" constructs in PostScript files. +- Don't crash on "atend" constructs in PostScript files. - + Only the Image module imports _imaging directly. Other modules - should refer to the binding module as "Image.core". +- Only the Image module imports _imaging directly. Other modules + should refer to the binding module as "Image.core". - *** Changes from release 0.0 to 0.1 (b1) *** +0.0 to 0.1 (b1) +--------------- - + A handbook is available (distributed separately). +- A handbook is available (distributed separately). - + The coordinate system is changed so that (0,0) is now located - in the upper left corner. This is in compliancy with ISO 12087 - and 90% of all other image processing and graphics libraries. +- The coordinate system is changed so that (0,0) is now located + in the upper left corner. This is in compliancy with ISO 12087 + and 90% of all other image processing and graphics libraries. - + Modes "1" (bilevel) and "P" (palette) have been introduced. Note - that bilevel images are stored with one byte per pixel. +- Modes "1" (bilevel) and "P" (palette) have been introduced. Note + that bilevel images are stored with one byte per pixel. - + The Image "crop" and "paste" methods now accepts None as the - box argument, to refer to the full image (self, that is). +- The Image "crop" and "paste" methods now accepts None as the + box argument, to refer to the full image (self, that is). - + The Image "crop" method now works properly. +- The Image "crop" method now works properly. - + The Image "point" method is now available. You can use either a - lookup table or a function taking one argument. +- The Image "point" method is now available. You can use either a + lookup table or a function taking one argument. - + The Image join function has been renamed to "merge". +- The Image join function has been renamed to "merge". - + An Image "composite" function has been added. It is identical - to copy() followed by paste(mask). +- An Image "composite" function has been added. It is identical + to copy() followed by paste(mask). - + An Image "eval" function has been added. It is currently identical - to point(function); that is, only a single image can be processed. +- An Image "eval" function has been added. It is currently identical + to point(function); that is, only a single image can be processed. - + A set of channel operations has been added. See the "ImageChops" - module, test_chops.py, and the handbook for details. +- A set of channel operations has been added. See the "ImageChops" + module, test_chops.py, and the handbook for details. - + Added the "pilconvert" utility, which converts image files. Note - that the number of output formats are still quite restricted. +- Added the "pilconvert" utility, which converts image files. Note + that the number of output formats are still quite restricted. - + Added the "pilfile" utility, which quickly identifies image files - (without loading them, in most cases). +- Added the "pilfile" utility, which quickly identifies image files + (without loading them, in most cases). - + Added the "pilprint" utility, which prints image files to PostScript - printers. +- Added the "pilprint" utility, which prints image files to PostScript + printers. - + Added a rudimentary version of the "pilview" utility, which is - simple image viewer based on Tk. Only File/Exit and Image/Next - works properly. +- Added a rudimentary version of the "pilview" utility, which is + simple image viewer based on Tk. Only File/Exit and Image/Next + works properly. - + An interface to Tk has been added. See "Lib/ImageTk.py" and README - for details. +- An interface to Tk has been added. See "Lib/ImageTk.py" and README + for details. - + An interface to Jack Jansen's Img library has been added (thanks to - Jack). This allows you to read images through the Img extensions file - format handlers. See the file "Lib/ImgExtImagePlugin.py" for details. +- An interface to Jack Jansen's Img library has been added (thanks to + Jack). This allows you to read images through the Img extensions file + format handlers. See the file "Lib/ImgExtImagePlugin.py" for details. - + PostScript printing is provided through the PSDraw module. See the - handbook for details. +- PostScript printing is provided through the PSDraw module. See the + handbook for details. diff --git a/LICENSE b/LICENSE index 40aabc3239f..616808a485d 100644 --- a/LICENSE +++ b/LICENSE @@ -5,7 +5,7 @@ The Python Imaging Library (PIL) is Pillow is the friendly PIL fork. It is - Copyright © 2010-2022 by Alex Clark and contributors + Copyright © 2010-2023 by Alex Clark and contributors Like PIL, Pillow is licensed under the open source HPND License: diff --git a/MANIFEST.in b/MANIFEST.in index f00d96fbf89..db24b19b40f 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,7 +1,6 @@ include *.c include *.h include *.in -include *.lock include *.md include *.py include *.rst @@ -10,7 +9,6 @@ include *.txt include *.yaml include LICENSE include Makefile -include Pipfile include tox.ini graft Tests graft src @@ -26,6 +24,7 @@ exclude .coveragerc exclude .editorconfig exclude .readthedocs.yml exclude codecov.yml +exclude renovate.json global-exclude .git* global-exclude *.pyc global-exclude *.so diff --git a/Makefile b/Makefile index 0dac63d3961..a2545b54e61 100644 --- a/Makefile +++ b/Makefile @@ -9,17 +9,20 @@ clean: .PHONY: coverage coverage: - pytest -qq + python3 -c "import pytest" > /dev/null 2>&1 || python3 -m pip install pytest + python3 -m pytest -qq rm -r htmlcov || true - coverage report + python3 -c "import coverage" > /dev/null 2>&1 || python3 -m pip install coverage + python3 -m coverage report .PHONY: doc doc: + python3 -c "import PIL" > /dev/null 2>&1 || python3 -m pip install . $(MAKE) -C docs html .PHONY: doccheck doccheck: - $(MAKE) -C docs html + $(MAKE) doc # Don't make our tests rely on the links in the docs being up every single build. # We don't control them. But do check, and update them to the target of their redirects. $(MAKE) -C docs linkcheck || true @@ -33,20 +36,16 @@ help: @echo "Welcome to Pillow development. Please use \`make \` where is one of" @echo " clean remove build products" @echo " coverage run coverage test (in progress)" - @echo " doc make html docs" - @echo " docserve run an http server on the docs directory" + @echo " doc make HTML docs" + @echo " docserve run an HTTP server on the docs directory" @echo " html to make standalone HTML files" @echo " inplace make inplace extension" @echo " install make and install" @echo " install-coverage make and install with C coverage" - @echo " install-req install documentation and test dependencies" - @echo " install-venv (deprecated) install in virtualenv" @echo " lint run the lint checks" - @echo " lint-fix run black and isort to (mostly) fix lint issues." + @echo " lint-fix run Black and isort to (mostly) fix lint issues" @echo " release-test run code and package tests before release" - @echo " test run tests on installed pillow" - @echo " upload build and upload sdists to PyPI" - @echo " upload-test build and upload sdists to test.pythonpackages.com" + @echo " test run tests on installed Pillow" .PHONY: inplace inplace: clean @@ -54,12 +53,12 @@ inplace: clean .PHONY: install install: - python3 -m pip install . + python3 -m pip -v install . python3 selftest.py .PHONY: install-coverage install-coverage: - CFLAGS="-coverage -Werror=implicit-function-declaration" python3 -m pip install --global-option="build_ext" . + CFLAGS="-coverage -Werror=implicit-function-declaration" python3 -m pip -v install --global-option="build_ext" . python3 selftest.py .PHONY: debug @@ -68,59 +67,54 @@ debug: # for our stuff, kills optimization, and redirects to dev null so we # see any build failures. make clean > /dev/null - CFLAGS='-g -O0' python3 -m pip install --global-option="build_ext" . > /dev/null - -.PHONY: install-req -install-req: - python3 -m pip install -r requirements.txt - -.PHONY: install-venv -install-venv: - echo "'install-venv' is deprecated and will be removed in a future Pillow release" - virtualenv . - bin/pip install -r requirements.txt + CFLAGS='-g -O0' python3 -m pip -v install --global-option="build_ext" . > /dev/null .PHONY: release-test release-test: - $(MAKE) install-req - python3 -m pip install -e . + python3 -m pip install -e .[tests] python3 selftest.py python3 -m pytest Tests python3 -m pip install . -rm dist/*.egg -rmdir dist python3 -m pytest -qq - check-manifest - pyroma . + python3 -m check_manifest + python3 -m pyroma . $(MAKE) readme .PHONY: sdist 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: - pytest -qq + python3 -c "import pytest" > /dev/null 2>&1 || python3 -m pip install pytest + python3 -m pytest -qq .PHONY: valgrind valgrind: - python3 -c "import pytest_valgrind" || pip3 install pytest-valgrind + python3 -c "import pytest_valgrind" > /dev/null 2>&1 || python3 -m pip install pytest-valgrind PYTHONMALLOC=malloc valgrind --suppressions=Tests/oss-fuzz/python.supp --leak-check=no \ --log-file=/tmp/valgrind-output \ python3 -m pytest --no-memcheck -vv --valgrind --valgrind-log=/tmp/valgrind-output .PHONY: readme readme: - python3 setup.py --long-description | markdown2 > .long-description.html && open .long-description.html + python3 -c "import markdown2" > /dev/null 2>&1 || python3 -m pip install markdown2 + python3 -m markdown2 README.md > .long-description.html && open .long-description.html .PHONY: lint lint: - tox --help > /dev/null || python3 -m pip install tox - tox -e lint + python3 -c "import tox" > /dev/null 2>&1 || python3 -m pip install tox + python3 -m tox -e lint .PHONY: lint-fix lint-fix: - black --target-version py37 . - isort . + python3 -c "import black" > /dev/null 2>&1 || python3 -m pip install black + python3 -c "import isort" > /dev/null 2>&1 || python3 -m pip install isort + python3 -m black --target-version py37 . + python3 -m isort . diff --git a/Pipfile b/Pipfile deleted file mode 100644 index 1e611a63ce7..00000000000 --- a/Pipfile +++ /dev/null @@ -1,22 +0,0 @@ -[[source]] -url = "https://pypi.org/simple" -verify_ssl = true -name = "pypi" - -[packages] -black = "*" -check-manifest = "*" -coverage = "*" -defusedxml = "*" -packaging = "*" -markdown2 = "*" -olefile = "*" -pyroma = "*" -pytest = "*" -pytest-cov = "*" -pytest-timeout = "*" - -[dev-packages] - -[requires] -python_version = "3.9" diff --git a/Pipfile.lock b/Pipfile.lock deleted file mode 100644 index 600b19050f5..00000000000 --- a/Pipfile.lock +++ /dev/null @@ -1,324 +0,0 @@ -{ - "_meta": { - "hash": { - "sha256": "e5cad23bf4187647d53b613a64dc4792b7064bf86b08dfb5737580e32943f54d" - }, - "pipfile-spec": 6, - "requires": { - "python_version": "3.9" - }, - "sources": [ - { - "name": "pypi", - "url": "https://pypi.org/simple", - "verify_ssl": true - } - ] - }, - "default": { - "attrs": { - "hashes": [ - "sha256:149e90d6d8ac20db7a955ad60cf0e6881a3f20d37096140088356da6c716b0b1", - "sha256:ef6aaac3ca6cd92904cdd0d83f629a15f18053ec84e6432106f7a4d04ae4f5fb" - ], - "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'", - "version": "==21.2.0" - }, - "black": { - "hashes": [ - "sha256:77b80f693a569e2e527958459634f18df9b0ba2625ba4e0c2d5da5be42e6f2b3", - "sha256:a615e69ae185e08fdd73e4715e260e2479c861b5740057fde6e8b4e3b7dd589f" - ], - "index": "pypi", - "version": "==21.12b0" - }, - "build": { - "hashes": [ - "sha256:1aaadcd69338252ade4f7ec1265e1a19184bf916d84c9b7df095f423948cb89f", - "sha256:21b7ebbd1b22499c4dac536abc7606696ea4d909fd755e00f09f3c0f2c05e3c8" - ], - "markers": "python_version >= '3.6'", - "version": "==0.7.0" - }, - "certifi": { - "hashes": [ - "sha256:78884e7c1d4b00ce3cea67b44566851c4343c120abd683433ce934a68ea58872", - "sha256:d62a0163eb4c2344ac042ab2bdf75399a71a2d8c7d47eac2e2ee91b9d6339569" - ], - "version": "==2021.10.8" - }, - "charset-normalizer": { - "hashes": [ - "sha256:1eecaa09422db5be9e29d7fc65664e6c33bd06f9ced7838578ba40d58bdf3721", - "sha256:b0b883e8e874edfdece9c28f314e3dd5badf067342e42fb162203335ae61aa2c" - ], - "markers": "python_version >= '3'", - "version": "==2.0.9" - }, - "check-manifest": { - "hashes": [ - "sha256:365c94d65de4c927d9d8b505371d08ee19f9f369c86b9ac3db97c2754c827c95", - "sha256:56dadd260a9c7d550b159796d2894b6d0bcc176a94cbc426d9bb93e5e48d12ce" - ], - "index": "pypi", - "version": "==0.47" - }, - "click": { - "hashes": [ - "sha256:353f466495adaeb40b6b5f592f9f91cb22372351c84caeb068132442a4518ef3", - "sha256:410e932b050f5eed773c4cda94de75971c89cdb3155a72a0831139a79e5ecb5b" - ], - "markers": "python_version >= '3.6'", - "version": "==8.0.3" - }, - "coverage": { - "hashes": [ - "sha256:01774a2c2c729619760320270e42cd9e797427ecfddd32c2a7b639cdc481f3c0", - "sha256:03b20e52b7d31be571c9c06b74746746d4eb82fc260e594dc662ed48145e9efd", - "sha256:0a7726f74ff63f41e95ed3a89fef002916c828bb5fcae83b505b49d81a066884", - "sha256:1219d760ccfafc03c0822ae2e06e3b1248a8e6d1a70928966bafc6838d3c9e48", - "sha256:13362889b2d46e8d9f97c421539c97c963e34031ab0cb89e8ca83a10cc71ac76", - "sha256:174cf9b4bef0db2e8244f82059a5a72bd47e1d40e71c68ab055425172b16b7d0", - "sha256:17e6c11038d4ed6e8af1407d9e89a2904d573be29d51515f14262d7f10ef0a64", - "sha256:215f8afcc02a24c2d9a10d3790b21054b58d71f4b3c6f055d4bb1b15cecce685", - "sha256:22e60a3ca5acba37d1d4a2ee66e051f5b0e1b9ac950b5b0cf4aa5366eda41d47", - "sha256:2641f803ee9f95b1f387f3e8f3bf28d83d9b69a39e9911e5bfee832bea75240d", - "sha256:276651978c94a8c5672ea60a2656e95a3cce2a3f31e9fb2d5ebd4c215d095840", - "sha256:3f7c17209eef285c86f819ff04a6d4cbee9b33ef05cbcaae4c0b4e8e06b3ec8f", - "sha256:3feac4084291642165c3a0d9eaebedf19ffa505016c4d3db15bfe235718d4971", - "sha256:49dbff64961bc9bdd2289a2bda6a3a5a331964ba5497f694e2cbd540d656dc1c", - "sha256:4e547122ca2d244f7c090fe3f4b5a5861255ff66b7ab6d98f44a0222aaf8671a", - "sha256:5829192582c0ec8ca4a2532407bc14c2f338d9878a10442f5d03804a95fac9de", - "sha256:5d6b09c972ce9200264c35a1d53d43ca55ef61836d9ec60f0d44273a31aa9f17", - "sha256:600617008aa82032ddeace2535626d1bc212dfff32b43989539deda63b3f36e4", - "sha256:619346d57c7126ae49ac95b11b0dc8e36c1dd49d148477461bb66c8cf13bb521", - "sha256:63c424e6f5b4ab1cf1e23a43b12f542b0ec2e54f99ec9f11b75382152981df57", - "sha256:6dbc1536e105adda7a6312c778f15aaabe583b0e9a0b0a324990334fd458c94b", - "sha256:6e1394d24d5938e561fbeaa0cd3d356207579c28bd1792f25a068743f2d5b282", - "sha256:86f2e78b1eff847609b1ca8050c9e1fa3bd44ce755b2ec30e70f2d3ba3844644", - "sha256:8bdfe9ff3a4ea37d17f172ac0dff1e1c383aec17a636b9b35906babc9f0f5475", - "sha256:8e2c35a4c1f269704e90888e56f794e2d9c0262fb0c1b1c8c4ee44d9b9e77b5d", - "sha256:92b8c845527eae547a2a6617d336adc56394050c3ed8a6918683646328fbb6da", - "sha256:9365ed5cce5d0cf2c10afc6add145c5037d3148585b8ae0e77cc1efdd6aa2953", - "sha256:9a29311bd6429be317c1f3fe4bc06c4c5ee45e2fa61b2a19d4d1d6111cb94af2", - "sha256:9a2b5b52be0a8626fcbffd7e689781bf8c2ac01613e77feda93d96184949a98e", - "sha256:a4bdeb0a52d1d04123b41d90a4390b096f3ef38eee35e11f0b22c2d031222c6c", - "sha256:a9c8c4283e17690ff1a7427123ffb428ad6a52ed720d550e299e8291e33184dc", - "sha256:b637c57fdb8be84e91fac60d9325a66a5981f8086c954ea2772efe28425eaf64", - "sha256:bf154ba7ee2fd613eb541c2bc03d3d9ac667080a737449d1a3fb342740eb1a74", - "sha256:c254b03032d5a06de049ce8bca8338a5185f07fb76600afff3c161e053d88617", - "sha256:c332d8f8d448ded473b97fefe4a0983265af21917d8b0cdcb8bb06b2afe632c3", - "sha256:c7912d1526299cb04c88288e148c6c87c0df600eca76efd99d84396cfe00ef1d", - "sha256:cfd9386c1d6f13b37e05a91a8583e802f8059bebfccde61a418c5808dea6bbfa", - "sha256:d5d2033d5db1d58ae2d62f095e1aefb6988af65b4b12cb8987af409587cc0739", - "sha256:dca38a21e4423f3edb821292e97cec7ad38086f84313462098568baedf4331f8", - "sha256:e2cad8093172b7d1595b4ad66f24270808658e11acf43a8f95b41276162eb5b8", - "sha256:e3db840a4dee542e37e09f30859f1612da90e1c5239a6a2498c473183a50e781", - "sha256:edcada2e24ed68f019175c2b2af2a8b481d3d084798b8c20d15d34f5c733fa58", - "sha256:f467bbb837691ab5a8ca359199d3429a11a01e6dfb3d9dcc676dc035ca93c0a9", - "sha256:f506af4f27def639ba45789fa6fde45f9a217da0be05f8910458e4557eed020c", - "sha256:f614fc9956d76d8a88a88bb41ddc12709caa755666f580af3a688899721efecd", - "sha256:f9afb5b746781fc2abce26193d1c817b7eb0e11459510fba65d2bd77fe161d9e", - "sha256:fb8b8ee99b3fffe4fd86f4c81b35a6bf7e4462cba019997af2fe679365db0c49" - ], - "index": "pypi", - "version": "==6.2" - }, - "defusedxml": { - "hashes": [ - "sha256:1bb3032db185915b62d7c6209c5a8792be6a32ab2fedacc84e01b52c51aa3e69", - "sha256:a352e7e428770286cc899e2542b6cdaedb2b4953ff269a210103ec58f6198a61" - ], - "index": "pypi", - "version": "==0.7.1" - }, - "docutils": { - "hashes": [ - "sha256:23010f129180089fbcd3bc08cfefccb3b890b0050e1ca00c867036e9d161b98c", - "sha256:679987caf361a7539d76e584cbeddc311e3aee937877c87346f31debc63e9d06" - ], - "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'", - "version": "==0.18.1" - }, - "idna": { - "hashes": [ - "sha256:84d9dd047ffa80596e0f246e2eab0b391788b0503584e8945f2368256d2735ff", - "sha256:9d643ff0a55b762d5cdb124b8eaa99c66322e2157b69160bc32796e824360e6d" - ], - "markers": "python_version >= '3'", - "version": "==3.3" - }, - "iniconfig": { - "hashes": [ - "sha256:011e24c64b7f47f6ebd835bb12a743f2fbe9a26d4cecaa7f53bc4f35ee9da8b3", - "sha256:bc3af051d7d14b2ee5ef9969666def0cd1a000e121eaea580d4a313df4b37f32" - ], - "version": "==1.1.1" - }, - "markdown2": { - "hashes": [ - "sha256:8f4ac8d9a124ab408c67361090ed512deda746c04362c36c2ec16190c720c2b0", - "sha256:91113caf23aa662570fe21984f08fe74f814695c0a0ea8e863a8b4c4f63f9f6e" - ], - "index": "pypi", - "version": "==2.4.2" - }, - "mypy-extensions": { - "hashes": [ - "sha256:090fedd75945a69ae91ce1303b5824f428daf5a028d2f6ab8a299250a846f15d", - "sha256:2d82818f5bb3e369420cb3c4060a7970edba416647068eb4c5343488a6c604a8" - ], - "version": "==0.4.3" - }, - "olefile": { - "hashes": [ - "sha256:133b031eaf8fd2c9399b78b8bc5b8fcbe4c31e85295749bb17a87cba8f3c3964" - ], - "index": "pypi", - "version": "==0.46" - }, - "packaging": { - "hashes": [ - "sha256:dd47c42927d89ab911e606518907cc2d3a1f38bbd026385970643f9c5b8ecfeb", - "sha256:ef103e05f519cdc783ae24ea4e2e0f508a9c99b2d4969652eed6a2e1ea5bd522" - ], - "index": "pypi", - "version": "==21.3" - }, - "pathspec": { - "hashes": [ - "sha256:7d15c4ddb0b5c802d161efc417ec1a2558ea2653c2e8ad9c19098201dc1c993a", - "sha256:e564499435a2673d586f6b2130bb5b95f04a3ba06f81b8f895b651a3c76aabb1" - ], - "version": "==0.9.0" - }, - "pep517": { - "hashes": [ - "sha256:931378d93d11b298cf511dd634cf5ea4cb249a28ef84160b3247ee9afb4e8ab0", - "sha256:dd884c326898e2c6e11f9e0b64940606a93eb10ea022a2e067959f3a110cf161" - ], - "version": "==0.12.0" - }, - "platformdirs": { - "hashes": [ - "sha256:367a5e80b3d04d2428ffa76d33f124cf11e8fff2acdaa9b43d545f5c7d661ef2", - "sha256:8868bbe3c3c80d42f20156f22e7131d2fb321f5bc86a2a345375c6481a67021d" - ], - "markers": "python_version >= '3.6'", - "version": "==2.4.0" - }, - "pluggy": { - "hashes": [ - "sha256:4224373bacce55f955a878bf9cfa763c1e360858e330072059e10bad68531159", - "sha256:74134bbf457f031a36d68416e1509f34bd5ccc019f0bcc952c7b909d06b37bd3" - ], - "markers": "python_version >= '3.6'", - "version": "==1.0.0" - }, - "py": { - "hashes": [ - "sha256:51c75c4126074b472f746a24399ad32f6053d1b34b68d2fa41e558e6f4a98719", - "sha256:607c53218732647dff4acdfcd50cb62615cedf612e72d1724fb1a0cc6405b378" - ], - "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'", - "version": "==1.11.0" - }, - "pygments": { - "hashes": [ - "sha256:b8e67fe6af78f492b3c4b3e2970c0624cbf08beb1e493b2c99b9fa1b67a20380", - "sha256:f398865f7eb6874156579fdf36bc840a03cab64d1cde9e93d68f46a425ec52c6" - ], - "markers": "python_version >= '3.5'", - "version": "==2.10.0" - }, - "pyparsing": { - "hashes": [ - "sha256:04ff808a5b90911829c55c4e26f75fa5ca8a2f5f36aa3a51f68e27033341d3e4", - "sha256:d9bdec0013ef1eb5a84ab39a3b3868911598afa494f5faa038647101504e2b81" - ], - "markers": "python_version >= '3.6'", - "version": "==3.0.6" - }, - "pyroma": { - "hashes": [ - "sha256:0fba67322913026091590e68e0d9e0d4fbd6420fcf34d315b2ad6985ab104d65", - "sha256:f8c181e0d5d292f11791afc18f7d0218a83c85cf64d6f8fb1571ce9d29a24e4a" - ], - "index": "pypi", - "version": "==3.2" - }, - "pytest": { - "hashes": [ - "sha256:131b36680866a76e6781d13f101efb86cf674ebb9762eb70d3082b6f29889e89", - "sha256:7310f8d27bc79ced999e760ca304d69f6ba6c6649c0b60fb0e04a4a77cacc134" - ], - "index": "pypi", - "version": "==6.2.5" - }, - "pytest-cov": { - "hashes": [ - "sha256:578d5d15ac4a25e5f961c938b85a05b09fdaae9deef3bb6de9a6e766622ca7a6", - "sha256:e7f0f5b1617d2210a2cabc266dfe2f4c75a8d32fb89eafb7ad9d06f6d076d470" - ], - "index": "pypi", - "version": "==3.0.0" - }, - "pytest-timeout": { - "hashes": [ - "sha256:e6f98b54dafde8d70e4088467ff621260b641eb64895c4195b6e5c8f45638112", - "sha256:fe9c3d5006c053bb9e062d60f641e6a76d6707aedb645350af9593e376fcc717" - ], - "index": "pypi", - "version": "==2.0.2" - }, - "requests": { - "hashes": [ - "sha256:6c1246513ecd5ecd4528a0906f910e8f0f9c6b8ec72030dc9fd154dc1a6efd24", - "sha256:b8aa58f8cf793ffd8782d3d8cb19e66ef36f7aba4353eec859e74678b01b07a7" - ], - "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4, 3.5'", - "version": "==2.26.0" - }, - "setuptools": { - "hashes": [ - "sha256:5ec2bbb534ed160b261acbbdd1b463eb3cf52a8d223d96a8ab9981f63798e85c", - "sha256:75fd345a47ce3d79595b27bf57e6f49c2ca7904f3c7ce75f8a87012046c86b0b" - ], - "markers": "python_version >= '3.7'", - "version": "==60.0.0" - }, - "toml": { - "hashes": [ - "sha256:806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b", - "sha256:b3bda1d108d5dd99f4a20d24d9c348e91c4db7ab1b749200bded2f839ccbe68f" - ], - "markers": "python_version >= '2.6' and python_version not in '3.0, 3.1, 3.2'", - "version": "==0.10.2" - }, - "tomli": { - "hashes": [ - "sha256:05b6166bff487dc068d322585c7ea4ef78deed501cc124060e0f238e89a9231f", - "sha256:e3069e4be3ead9668e21cb9b074cd948f7b3113fd9c8bba083f48247aab8b11c" - ], - "markers": "python_version >= '3.6'", - "version": "==1.2.3" - }, - "typing-extensions": { - "hashes": [ - "sha256:4ca091dea149f945ec56afb48dae714f21e8692ef22a395223bcd328961b6a0e", - "sha256:7f001e5ac290a0c0401508864c7ec868be4e701886d5b573a9528ed3973d9d3b" - ], - "markers": "python_version >= '3.6'", - "version": "==4.0.1" - }, - "urllib3": { - "hashes": [ - "sha256:4987c65554f7a2dbf30c18fd48778ef124af6fab771a377103da0585e2336ece", - "sha256:c4fdf4019605b6e5423637e01bc9fe4daef873709a7973e195ceba0a62bbc844" - ], - "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4' and python_version < '4'", - "version": "==1.26.7" - } - }, - "develop": {} -} diff --git a/RELEASING.md b/RELEASING.md index cbedd449c0c..b0506748470 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -24,13 +24,12 @@ Released quarterly on January 2nd, April 1st, July 1st and October 15th. * [ ] Create and check source distribution: ```bash make sdist - twine check 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.: ```bash - twine check dist/* - twine upload dist/Pillow-5.2.0* + python3 -m twine check --strict dist/* + python3 -m twine upload dist/Pillow-5.2.0* ``` * [ ] Publish the [release on GitHub](https://github.com/python-pillow/Pillow/releases) * [ ] In compliance with [PEP 440](https://www.python.org/dev/peps/pep-0440/), increment and append `.dev0` to version identifier in `src/PIL/_version.py` @@ -61,13 +60,12 @@ Released as needed for security, installation or critical bug fixes. * [ ] Create and check source distribution: ```bash make sdist - twine check 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.: ```bash - twine check dist/* - twine upload dist/Pillow-5.2.1* + python3 -m twine check --strict dist/* + python3 -m twine upload dist/Pillow-5.2.1* ``` * [ ] Publish the [release on GitHub](https://github.com/python-pillow/Pillow/releases) @@ -91,7 +89,6 @@ Released as needed privately to individual vendors for critical security-related * [ ] Create and check source distribution: ```bash make sdist - twine check 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/32bit_segfault_check.py b/Tests/32bit_segfault_check.py index e19cdf7a918..2ff7f908f6d 100755 --- a/Tests/32bit_segfault_check.py +++ b/Tests/32bit_segfault_check.py @@ -4,5 +4,5 @@ from PIL import Image -if sys.maxsize < 2 ** 32: +if sys.maxsize < 2**32: im = Image.new("L", (999999, 999999), 0) diff --git a/Tests/README.rst b/Tests/README.rst index 55464578702..2d014e5a46e 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/check_large_memory.py b/Tests/check_large_memory.py index c191ffc1eb8..d98f4a694ef 100644 --- a/Tests/check_large_memory.py +++ b/Tests/check_large_memory.py @@ -23,7 +23,7 @@ XDIM = 48000 -pytestmark = pytest.mark.skipif(sys.maxsize <= 2 ** 32, reason="requires 64-bit system") +pytestmark = pytest.mark.skipif(sys.maxsize <= 2**32, reason="requires 64-bit system") def _write_png(tmp_path, xdim, ydim): diff --git a/Tests/check_large_memory_numpy.py b/Tests/check_large_memory_numpy.py index 70ae6d230b8..24cb1f722bf 100644 --- a/Tests/check_large_memory_numpy.py +++ b/Tests/check_large_memory_numpy.py @@ -19,7 +19,7 @@ XDIM = 48000 -pytestmark = pytest.mark.skipif(sys.maxsize <= 2 ** 32, reason="requires 64-bit system") +pytestmark = pytest.mark.skipif(sys.maxsize <= 2**32, reason="requires 64-bit system") def _write_png(tmp_path, xdim, ydim): 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 00000000000..c065f59a9da Binary files /dev/null and b/Tests/fonts/10x20-ISO8859-1-fewer-characters.pcf differ diff --git a/Tests/fonts/LICENSE.txt b/Tests/fonts/LICENSE.txt index 104ff677cad..da559b3d3f2 100644 --- a/Tests/fonts/LICENSE.txt +++ b/Tests/fonts/LICENSE.txt @@ -8,6 +8,7 @@ TINY5x3GX.ttf, from http://velvetyne.fr/fonts/tiny ArefRuqaa-Regular.ttf, from https://github.com/google/fonts/tree/master/ofl/arefruqaa ter-x20b.pcf, from http://terminus-font.sourceforge.net/ BungeeColor-Regular_colr_Windows.ttf, from https://github.com/djrrb/bungee +OpenSans.woff2, from https://fonts.googleapis.com/css?family=Open+Sans All of the above fonts are published under the SIL Open Font License (OFL) v1.1 (http://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&id=OFL), which allows you to copy, modify, and redistribute them if you need to. diff --git a/Tests/fonts/OpenSans.woff2 b/Tests/fonts/OpenSans.woff2 new file mode 100644 index 00000000000..15339ea9ccd Binary files /dev/null and b/Tests/fonts/OpenSans.woff2 differ diff --git a/Tests/fonts/fuzz_font-5203009437302784 b/Tests/fonts/fuzz_font-5203009437302784 new file mode 100644 index 00000000000..0465e48c204 --- /dev/null +++ b/Tests/fonts/fuzz_font-5203009437302784 @@ -0,0 +1,10 @@ +STARTFONT +FONT +SIZE 10 +FONTBOUNDINGBOX +CHARS +STARTCHAR +ENCODING +BBX 2 5 +ENDCHAR +ENDFONT diff --git a/Tests/helper.py b/Tests/helper.py index 8504993fb5d..0d1d03ac8c1 100644 --- a/Tests/helper.py +++ b/Tests/helper.py @@ -30,7 +30,6 @@ def upload(a, b): a.show() b.show() - elif "GITHUB_ACTIONS" in os.environ: HAS_UPLOADER = True @@ -44,7 +43,6 @@ def upload(a, b): b.save(os.path.join(tmpdir, "b.png")) return tmpdir - else: try: import test_image_results @@ -210,12 +208,11 @@ def _get_mem_usage(self): # ru_maxrss # This is the maximum resident set size utilized (in bytes). return mem / 1024 # Kb - else: - # linux - # man 2 getrusage - # ru_maxrss (since Linux 2.6.32) - # This is the maximum resident set size used (in kilobytes). - return mem # Kb + # linux + # man 2 getrusage + # ru_maxrss (since Linux 2.6.32) + # This is the maximum resident set size used (in kilobytes). + return mem # Kb def _test_leak(self, core): start_mem = self._get_mem_usage() @@ -287,7 +284,7 @@ def magick_command(): if imagemagick and shutil.which(imagemagick[0]): return imagemagick - elif graphicsmagick and shutil.which(graphicsmagick[0]): + if graphicsmagick and shutil.which(graphicsmagick[0]): return graphicsmagick @@ -326,7 +323,7 @@ def is_mingw(): return sysconfig.get_platform() == "mingw" -class cached_property: +class CachedProperty: def __init__(self, func): self.func = func diff --git a/Tests/images/1.eps b/Tests/images/1.eps new file mode 100644 index 00000000000..727dc9b7f04 Binary files /dev/null and b/Tests/images/1.eps differ diff --git a/Tests/images/16bit.r.tif b/Tests/images/16bit.r.tif new file mode 100644 index 00000000000..0f3996e95eb Binary files /dev/null and b/Tests/images/16bit.r.tif differ diff --git a/Tests/images/ati1.dds b/Tests/images/ati1.dds new file mode 100644 index 00000000000..747e4b1b98a 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 00000000000..790d7d7dbb2 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 00000000000..3ac5f7956ea Binary files /dev/null and b/Tests/images/ati2.dds differ diff --git a/Tests/images/bc6h.dds b/Tests/images/bc6h.dds new file mode 100644 index 00000000000..77993a0c1ea Binary files /dev/null and b/Tests/images/bc6h.dds differ diff --git a/Tests/images/bc6h.png b/Tests/images/bc6h.png new file mode 100644 index 00000000000..609f114890c Binary files /dev/null and b/Tests/images/bc6h.png differ diff --git a/Tests/images/bc6h_sf.dds b/Tests/images/bc6h_sf.dds new file mode 100644 index 00000000000..2ab1b195b19 Binary files /dev/null and b/Tests/images/bc6h_sf.dds differ diff --git a/Tests/images/bc6h_sf.png b/Tests/images/bc6h_sf.png new file mode 100644 index 00000000000..6a3b73d5fc9 Binary files /dev/null and b/Tests/images/bc6h_sf.png differ diff --git a/Tests/images/blp/blp1_jpeg.png b/Tests/images/blp/blp1_jpeg.png new file mode 100644 index 00000000000..be151f205ed Binary files /dev/null and b/Tests/images/blp/blp1_jpeg.png differ diff --git a/Tests/images/blp/blp1_jpeg2.blp b/Tests/images/blp/blp1_jpeg2.blp new file mode 100644 index 00000000000..890180e9b47 Binary files /dev/null and b/Tests/images/blp/blp1_jpeg2.blp differ diff --git a/Tests/images/bw_gradient.imt b/Tests/images/bw_gradient.imt new file mode 100644 index 00000000000..d765cf95fac Binary files /dev/null and b/Tests/images/bw_gradient.imt differ diff --git a/Tests/images/child_ifd.tiff b/Tests/images/child_ifd.tiff new file mode 100644 index 00000000000..700185d88ae Binary files /dev/null and b/Tests/images/child_ifd.tiff differ diff --git a/Tests/images/child_ifd_jpeg.tiff b/Tests/images/child_ifd_jpeg.tiff new file mode 100644 index 00000000000..f5e3d129d5d Binary files /dev/null and b/Tests/images/child_ifd_jpeg.tiff differ diff --git a/Tests/images/comment_after_last_frame.gif b/Tests/images/comment_after_last_frame.gif new file mode 100644 index 00000000000..9f5c7b8da47 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 00000000000..8188b684732 Binary files /dev/null and b/Tests/images/comment_after_only_frame.gif differ diff --git a/Tests/images/cross_scan_line.png b/Tests/images/cross_scan_line.png new file mode 100644 index 00000000000..64b68ed338d Binary files /dev/null and b/Tests/images/cross_scan_line.png differ diff --git a/Tests/images/cross_scan_line.tga b/Tests/images/cross_scan_line.tga new file mode 100644 index 00000000000..5ef8c8154d4 Binary files /dev/null and b/Tests/images/cross_scan_line.tga differ diff --git a/Tests/images/cross_scan_line_truncated.tga b/Tests/images/cross_scan_line_truncated.tga new file mode 100644 index 00000000000..cec4357e3ac 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 0efc9eaf74b..2ecfa8586e8 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 00000000000..0d5ff03f525 Binary files /dev/null and b/Tests/images/decompression_bomb_extents.gif differ diff --git a/Tests/images/duplicate_frame.gif b/Tests/images/duplicate_frame.gif new file mode 100644 index 00000000000..ef0c894a540 Binary files /dev/null and b/Tests/images/duplicate_frame.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 00000000000..ac315ee99f3 Binary files /dev/null and b/Tests/images/duplicate_number_of_loops.gif differ diff --git a/Tests/images/flower_thumbnail.png b/Tests/images/flower_thumbnail.png new file mode 100644 index 00000000000..4a362535f25 Binary files /dev/null and b/Tests/images/flower_thumbnail.png differ diff --git a/Tests/images/hopper.fits b/Tests/images/hopper.fits index 85afa4ac167..7f28f75e5a8 100644 Binary files a/Tests/images/hopper.fits and b/Tests/images/hopper.fits differ diff --git a/Tests/images/hopper_16bit.pgm b/Tests/images/hopper_16bit.pgm new file mode 100644 index 00000000000..e482493dd40 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 00000000000..a48ab55441a --- /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 00000000000..216a94ffa89 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 00000000000..9f5c6e501ff --- /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 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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 0 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 0 0 0 0 1 1 1 1 1 1 1 1 0 0 0 0 1 1 0 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 0 1 1 1 1 1 1 1 1 0 1 1 1 1 0 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0 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 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 0 1 1 1 1 1 1 1 1 0 1 1 1 0 0 0 0 0 0 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 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 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 0 1 1 1 1 1 1 1 1 0 1 1 0 0 0 0 0 0 0 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 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 0 0 0 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 0 1 1 1 1 1 1 1 1 0 1 0 0 0 0 0 0 0 0 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 0 0 0 0 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 0 0 0 0 0 1 1 1 1 1 1 0 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 0 0 0 0 0 0 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 0 0 0 0 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 0 0 0 0 0 0 1 1 1 1 1 1 0 0 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 0 0 0 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 0 0 0 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 0 0 0 0 0 0 1 1 1 1 1 1 1 0 0 1 1 0 0 1 1 1 1 1 1 0 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 0 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 0 0 0 0 0 0 0 1 1 1 1 1 1 0 0 0 0 0 0 1 1 1 1 1 1 0 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 0 0 0 1 1 1 1 1 1 1 0 1 1 1 1 1 0 0 0 0 0 1 1 0 0 0 0 1 1 1 1 1 0 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 0 0 0 0 1 1 1 1 1 0 0 0 0 0 0 1 1 1 1 1 1 1 0 0 1 1 1 1 1 0 1 1 1 1 1 1 1 1 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 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 0 0 1 1 1 1 1 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 0 0 0 0 0 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 0 0 0 0 0 0 0 0 0 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 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 0 0 1 1 1 1 1 1 0 0 0 0 0 0 0 1 1 1 1 1 1 1 0 0 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 0 0 0 0 1 1 1 1 1 1 1 1 0 0 0 0 0 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 0 1 1 1 1 1 1 1 1 1 0 0 0 0 0 1 1 1 1 1 0 0 0 0 0 1 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 0 0 0 1 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 0 1 1 1 1 1 1 1 1 1 0 0 1 0 0 0 1 1 1 1 0 0 0 0 0 1 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 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 0 0 1 1 1 1 1 1 1 1 1 0 0 0 0 1 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 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 0 0 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 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 0 1 1 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 1 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 1 1 1 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 1 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 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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 0 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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 0 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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 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 0 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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 0 0 1 1 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 0 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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 0 0 1 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 0 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 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 0 0 0 0 0 1 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 0 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 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 0 0 0 0 0 0 1 1 1 1 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 0 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 1 1 1 1 1 1 0 0 0 0 0 0 0 0 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 0 0 1 1 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 1 1 1 1 1 0 0 1 0 0 0 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 1 1 0 0 0 0 0 0 0 1 1 1 1 1 0 1 0 0 0 0 0 0 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 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 1 1 0 1 1 0 0 0 0 0 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 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 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 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 1 0 0 0 1 0 0 1 1 1 1 1 1 1 1 1 1 0 0 0 0 1 1 0 0 1 1 1 1 1 1 1 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 0 0 0 1 1 0 0 1 1 1 1 0 0 0 0 0 0 0 1 1 0 0 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 0 1 0 0 0 0 1 1 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 1 1 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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 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 0 0 0 0 0 0 1 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 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 0 1 1 0 0 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 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 1 1 1 1 1 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 0 0 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 0 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1 1 1 0 0 0 0 0 0 0 1 1 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 0 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 1 0 0 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 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 0 1 1 1 1 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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 0 1 1 1 1 0 0 0 1 0 0 0 0 0 1 1 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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 0 1 1 1 1 0 0 1 1 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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 0 1 1 1 1 0 0 1 1 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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 0 1 0 0 0 0 0 1 1 0 1 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 0 0 0 0 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 1 1 1 1 1 0 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 1 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 1 1 1 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 1 1 1 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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 0 0 0 0 0 0 0 0 0 0 1 1 0 0 1 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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 0 0 0 0 0 0 0 0 0 0 1 0 1 1 0 0 0 0 1 1 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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 0 0 0 0 0 0 0 0 0 1 0 1 1 0 0 0 0 0 1 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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 0 0 0 0 0 0 0 0 0 1 0 1 0 1 0 0 0 0 1 1 0 0 1 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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 0 0 0 0 0 0 1 1 1 0 1 0 0 0 0 1 1 1 0 0 0 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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 0 0 0 0 0 0 1 1 1 0 0 0 1 0 0 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 0 0 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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 0 0 0 0 0 1 1 1 0 0 0 1 0 1 1 1 1 0 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 0 0 0 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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 0 1 0 0 0 1 1 1 0 1 0 1 1 1 1 1 0 0 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 0 0 0 0 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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 0 1 0 0 0 1 1 1 0 1 1 1 1 1 1 1 0 0 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 0 0 0 0 0 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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 0 1 0 0 0 1 1 1 1 1 1 1 1 1 1 1 0 0 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 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 0 0 0 1 1 1 1 1 1 1 1 1 1 1 0 0 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 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 1 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 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 0 0 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 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 0 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 0 0 1 1 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 0 0 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 0 0 0 1 0 0 0 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 0 0 0 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 0 0 0 1 1 0 0 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 0 0 0 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 0 0 0 1 1 0 1 1 0 0 1 1 1 1 1 1 1 1 1 1 0 1 1 1 0 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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 0 0 0 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 0 0 0 1 1 0 0 1 1 0 1 1 1 1 1 1 1 1 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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 0 0 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 0 0 0 0 1 1 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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 0 0 0 0 0 1 1 0 0 0 0 1 1 1 1 1 1 1 1 1 0 1 1 1 0 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 0 0 0 0 0 0 0 0 0 0 0 0 0 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 0 0 0 0 0 0 1 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 0 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 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 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 0 0 0 0 0 0 0 1 0 0 0 1 1 1 1 1 1 1 1 0 1 1 0 0 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 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 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 0 0 0 0 0 0 0 1 0 0 0 0 1 1 1 1 1 0 1 1 0 0 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 0 0 0 0 0 0 0 0 0 1 1 1 1 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 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 1 0 0 1 0 0 0 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 0 0 0 0 0 0 0 0 1 1 1 1 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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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 0 0 0 0 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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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 0 0 0 0 0 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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 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 0 0 0 0 0 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 0 0 0 0 0 0 0 0 0 1 1 1 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 0 0 0 0 0 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 0 0 0 0 0 0 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 0 0 0 0 0 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 0 0 0 0 0 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 0 0 0 0 0 0 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 0 0 0 0 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 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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 0 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 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 0 0 0 0 0 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 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 0 0 0 0 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 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 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 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 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 0 0 0 0 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 0 0 0 0 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 0 0 0 0 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 0 0 0 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 0 0 0 0 0 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 0 0 0 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 0 0 0 0 0 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 0 0 0 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 0 0 0 0 0 0 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 0 0 0 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 0 0 0 0 0 0 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 0 0 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 0 0 0 0 0 0 0 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 0 0 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 0 0 0 0 0 0 0 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 0 0 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 0 0 0 0 0 0 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 0 0 0 0 0 0 0 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 0 0 0 0 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 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 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 0 0 0 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 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 1 0 0 0 0 0 0 0 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 0 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 0 1 1 1 1 1 1 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 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 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 0 1 1 1 1 1 1 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 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 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 0 1 1 1 1 1 1 1 1 1 1 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 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 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 0 0 0 1 0 1 0 1 0 1 0 1 0 1 1 0 0 0 1 1 1 0 0 0 1 1 1 1 1 1 1 1 1 1 1 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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 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 0 0 0 1 0 1 0 1 0 1 0 1 0 1 1 0 0 0 1 1 1 1 0 0 1 1 1 1 1 1 1 1 1 1 1 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 0 0 0 0 0 0 0 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 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 1 0 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 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 0 0 0 1 1 1 0 0 0 1 0 0 0 1 1 0 0 1 1 1 1 1 1 1 1 1 0 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 0 0 0 0 1 1 1 1 0 0 1 0 0 0 1 1 0 0 1 1 1 1 1 1 1 1 1 0 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 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 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 00000000000..23d7ada964b 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 00000000000..a63406cf460 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 00000000000..37d152c73f3 --- /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 00000000000..c39a92a0bd6 --- /dev/null +++ b/Tests/images/hopper_8bit_plain.ppm @@ -0,0 +1,4 @@ +P3 +128 128 +255 +20 21 67 17 18 62 9 10 54 21 23 62 24 26 65 24 27 60 13 17 44 16 19 54 29 28 86 30 27 94 21 20 80 17 17 71 25 25 77 24 25 73 20 21 69 25 25 77 29 29 93 31 30 96 25 26 83 17 19 70 14 18 65 15 19 66 15 21 71 22 27 82 24 28 91 23 24 88 15 14 74 29 25 75 26 16 51 116 105 122 240 225 228 180 157 143 216 171 142 196 157 128 193 180 172 115 117 129 17 20 51 32 36 74 32 32 70 27 13 28 83 42 14 207 165 125 83 70 51 19 21 20 36 37 57 120 117 146 209 200 229 243 230 248 255 245 244 252 240 226 250 238 224 245 239 225 239 236 227 194 198 201 36 47 69 44 59 98 82 103 160 67 92 156 64 96 155 64 99 155 69 106 159 66 103 158 77 108 172 71 104 175 68 101 182 55 91 169 69 104 170 62 98 160 61 96 164 67 104 174 65 104 173 61 104 173 59 103 174 55 102 172 55 102 172 57 102 167 58 103 158 62 102 163 65 101 179 70 102 185 67 103 177 66 103 173 66 100 172 66 100 172 68 102 176 67 103 177 68 104 180 67 106 181 65 104 181 63 105 181 61 105 180 62 104 180 63 102 179 65 101 179 67 100 179 66 99 178 63 101 176 63 102 177 63 102 177 64 103 178 64 103 178 64 103 178 64 103 178 64 103 178 64 103 178 64 103 178 63 102 177 63 102 177 64 103 178 65 104 179 66 105 180 66 105 180 65 102 180 64 101 179 66 102 178 69 105 179 76 110 184 81 115 186 84 117 188 85 118 187 86 119 186 86 119 186 84 119 187 83 118 186 79 116 187 78 115 186 77 115 188 78 116 189 20 21 67 17 18 62 10 12 53 21 23 64 23 25 64 23 26 59 12 16 43 15 18 51 27 26 83 28 26 91 20 19 77 16 16 68 24 24 76 24 24 74 21 22 70 25 27 78 27 27 89 30 30 94 24 25 81 16 18 67 14 18 63 14 18 63 14 20 68 20 25 80 16 20 81 25 26 90 20 19 79 25 21 72 32 25 59 138 126 146 187 172 177 111 87 75 208 164 137 90 50 25 57 46 42 86 87 105 57 60 95 25 28 71 16 15 57 36 21 40 90 46 21 203 160 125 85 71 58 29 29 37 15 15 41 28 27 61 84 74 109 151 139 163 212 197 200 251 238 230 254 241 232 249 240 231 241 236 230 206 205 210 39 41 62 29 37 73 78 90 140 77 94 148 78 100 150 61 85 133 52 75 119 60 83 127 73 93 144 79 98 156 76 97 162 77 102 166 72 101 157 70 101 158 73 106 173 63 100 171 56 96 168 62 104 176 60 104 177 56 100 173 58 100 172 64 108 173 67 110 165 63 103 164 62 98 174 64 99 180 67 103 177 66 103 173 67 101 173 68 102 174 69 103 177 68 104 178 68 106 181 67 106 181 67 106 181 64 106 180 63 107 180 63 105 179 64 103 178 66 102 178 67 100 179 67 100 177 65 103 178 63 102 177 63 102 177 63 102 177 63 102 177 64 103 178 64 103 178 65 104 179 65 104 179 65 104 179 64 103 178 64 103 178 63 102 177 63 102 177 63 102 177 64 103 178 68 105 183 67 104 182 67 103 179 68 104 178 74 108 182 78 112 183 83 116 187 85 118 187 87 120 187 87 120 187 86 121 189 84 119 187 81 118 189 80 117 188 79 117 190 80 118 191 20 21 65 18 20 61 11 13 54 22 24 65 23 25 64 21 24 59 10 14 39 14 17 48 25 26 80 26 26 86 17 18 72 14 16 65 22 24 73 23 25 74 20 22 71 26 27 81 25 25 85 28 30 87 24 26 77 16 19 64 14 19 61 15 20 62 14 21 67 19 25 77 26 30 91 22 23 87 16 16 76 26 22 73 36 28 65 123 114 135 107 94 103 81 56 49 202 160 135 96 58 37 38 25 32 27 28 56 18 21 64 26 28 79 41 39 89 30 14 40 106 61 42 209 163 137 69 53 54 17 15 37 25 24 64 32 29 76 25 17 64 43 32 66 61 47 60 211 197 197 246 232 231 250 236 235 246 234 236 231 221 229 143 134 151 31 25 51 37 31 67 39 37 74 35 34 66 26 26 54 51 49 73 39 35 58 43 37 63 52 48 75 43 42 73 57 63 95 70 84 119 82 104 151 73 102 168 80 116 192 60 101 180 69 112 191 62 103 182 63 102 181 65 101 177 65 102 172 66 102 162 66 102 162 68 105 176 73 109 185 68 105 176 66 104 175 67 104 175 68 105 176 69 105 179 69 105 179 68 106 179 66 106 178 69 109 181 66 108 180 66 108 180 65 107 179 66 106 178 66 104 177 66 102 178 66 102 178 66 104 179 65 104 179 63 102 177 63 102 177 63 102 177 64 103 178 65 104 179 66 105 180 65 104 179 64 103 178 64 103 178 64 103 178 64 103 178 63 102 177 63 102 177 63 102 177 69 106 184 68 105 183 68 104 180 68 104 178 71 105 179 76 110 181 81 115 186 85 120 188 85 120 188 86 121 189 86 121 189 85 120 188 82 119 190 81 118 189 81 119 192 82 120 193 18 20 59 17 19 58 12 14 55 23 25 66 23 25 66 20 23 58 9 13 38 14 17 48 26 28 77 27 28 84 17 19 68 14 17 62 22 24 73 23 25 76 20 21 75 26 27 83 24 26 83 29 32 85 25 27 75 17 20 63 15 20 58 16 21 61 15 22 68 18 24 76 29 33 94 18 22 85 15 15 75 26 23 76 29 23 61 75 65 90 50 36 49 98 75 69 210 170 144 88 52 30 32 20 32 22 22 56 24 26 74 21 22 76 33 30 83 32 13 41 90 45 26 212 166 140 73 56 66 22 18 51 19 17 64 27 24 77 31 24 75 37 26 66 39 26 44 200 185 192 255 242 249 155 140 147 138 123 130 183 167 177 67 51 64 34 20 37 47 33 56 37 23 46 33 20 40 87 74 91 135 121 134 132 116 127 85 68 78 63 47 58 54 43 57 47 45 59 43 46 63 31 42 70 62 80 130 72 97 163 78 108 180 62 95 172 66 99 178 68 101 180 67 100 177 66 100 171 72 108 168 78 114 174 72 106 178 59 95 171 68 106 179 68 106 177 68 106 177 70 107 178 71 107 181 71 107 181 69 107 180 67 105 178 68 108 180 66 109 178 66 109 178 67 107 176 67 107 177 67 105 176 67 105 178 67 105 178 66 105 180 65 104 179 65 104 179 64 103 178 64 103 178 65 104 179 66 105 180 66 105 180 63 102 177 64 103 178 64 103 178 64 103 178 65 104 179 65 104 179 64 103 178 64 103 178 66 103 181 67 104 182 68 104 180 67 103 177 70 104 176 74 108 179 80 114 185 84 119 187 82 117 185 83 118 186 83 118 186 81 118 188 81 118 189 81 118 189 81 119 192 82 120 193 16 18 56 17 19 57 13 15 56 23 24 68 23 24 68 20 22 60 10 14 41 15 19 48 27 29 77 28 29 83 18 21 66 15 18 61 22 24 72 23 25 76 20 21 78 25 26 83 23 26 81 29 32 83 26 29 74 17 20 61 15 20 58 16 21 61 15 22 68 17 23 75 13 19 77 22 26 89 22 22 82 20 17 70 23 16 58 40 31 60 29 16 33 101 80 75 196 160 126 75 41 14 35 25 36 18 21 56 29 32 77 30 32 81 27 25 74 29 11 35 122 78 51 205 160 127 45 27 39 24 22 59 23 24 72 19 19 69 32 29 76 34 26 65 50 41 60 213 201 211 210 197 207 57 41 54 37 21 34 28 12 23 42 26 37 42 26 36 50 34 45 162 146 157 147 134 144 81 68 78 145 132 141 247 234 241 122 110 112 40 29 33 127 119 130 170 167 176 82 78 77 49 47 50 41 39 61 48 50 89 85 92 147 94 108 173 79 99 172 76 104 178 74 108 179 71 109 174 68 107 166 68 106 168 73 106 183 74 109 190 69 107 180 68 108 178 68 108 180 70 108 181 71 109 184 70 108 183 69 107 180 68 106 179 68 106 177 67 107 176 67 108 174 67 108 174 67 107 176 67 107 176 67 107 177 67 107 177 66 106 178 66 106 178 66 106 178 66 106 178 66 106 178 66 106 178 66 106 178 65 105 177 65 105 177 65 105 177 65 105 177 65 105 177 65 105 177 65 105 177 65 105 177 65 104 179 64 101 179 66 103 181 67 105 180 67 105 178 68 105 176 70 107 177 76 110 181 79 114 182 77 112 180 78 113 181 78 115 185 78 115 185 78 115 186 77 115 186 78 116 189 79 117 190 15 18 53 17 19 57 14 16 57 25 26 70 23 24 68 20 22 60 10 14 41 16 20 49 26 29 74 27 29 80 19 22 65 15 18 59 23 25 73 23 24 78 19 19 79 24 24 84 22 25 80 28 32 80 25 28 73 15 18 59 12 17 55 14 19 59 13 20 66 15 21 73 16 22 80 25 29 90 18 20 79 15 15 69 25 20 61 28 19 50 29 17 37 97 78 74 206 170 134 77 46 15 39 31 44 23 27 65 26 31 73 20 23 68 19 17 64 44 27 45 125 82 47 209 167 129 51 34 44 28 26 63 17 20 63 18 21 66 29 26 69 21 15 49 51 44 60 220 213 221 91 81 92 50 38 52 27 15 29 30 16 29 35 22 29 99 84 87 244 230 229 255 249 248 255 251 255 218 207 213 146 136 144 255 253 255 174 169 165 163 159 156 254 247 254 255 252 255 250 242 231 179 169 160 50 37 46 53 41 63 56 48 85 90 91 137 95 105 158 77 96 152 71 97 156 77 112 170 79 115 173 68 106 169 64 100 176 70 105 186 70 110 182 69 109 179 69 109 181 70 110 182 71 109 184 71 109 184 69 107 182 68 106 179 66 104 175 66 105 172 67 106 173 66 107 171 67 108 174 67 107 176 68 108 178 68 108 178 66 106 178 67 107 179 67 107 179 68 108 180 67 107 179 67 107 179 66 106 178 65 105 177 68 108 180 67 107 179 66 106 178 65 105 177 64 104 176 64 104 176 64 104 176 64 104 176 65 103 178 66 104 179 67 105 178 67 105 178 68 105 176 69 106 177 72 106 177 73 108 176 74 109 177 73 110 178 74 111 181 75 112 182 74 112 183 75 113 184 76 114 187 77 115 188 17 17 51 20 20 56 18 17 59 28 27 71 25 23 70 21 20 60 9 13 42 15 19 48 25 26 72 27 27 77 18 21 62 16 19 60 24 26 74 24 25 81 19 19 81 24 24 88 23 25 82 29 32 83 25 27 75 14 17 62 12 15 58 14 19 61 13 19 67 14 20 72 25 31 89 22 26 87 13 15 74 18 18 70 25 19 63 26 19 52 30 21 42 97 79 77 196 162 124 79 50 16 30 21 38 19 22 65 30 35 77 31 34 77 25 24 66 29 13 26 119 77 35 203 162 118 51 34 42 17 16 50 14 18 55 31 35 70 28 28 62 39 37 61 47 45 56 185 184 189 166 163 170 150 147 156 31 25 37 28 20 31 131 122 123 254 247 239 230 222 209 165 157 144 239 232 226 247 243 242 255 254 255 249 250 252 239 246 238 254 255 248 254 244 242 221 206 201 217 203 190 241 227 218 204 189 196 59 45 60 49 38 55 137 133 150 191 192 210 147 154 180 103 117 156 82 104 154 78 107 163 74 109 173 71 109 184 71 110 189 71 111 181 70 110 179 70 110 180 70 109 184 70 109 186 70 109 186 69 108 185 68 106 181 66 104 175 68 105 173 68 105 173 67 106 171 67 108 174 67 107 176 65 108 177 65 107 179 68 108 180 68 108 180 68 108 180 67 107 179 67 107 179 67 107 179 67 107 179 67 107 179 69 109 181 67 107 179 66 106 178 64 104 176 63 103 175 63 103 175 64 104 176 65 105 177 67 105 180 66 104 179 66 104 177 67 105 178 68 106 177 68 106 177 69 106 176 68 105 175 70 107 177 72 109 179 74 111 182 74 112 183 74 112 185 74 112 185 75 113 186 76 114 187 19 18 52 21 21 57 19 18 58 29 28 72 25 24 68 21 20 60 10 11 39 14 18 47 22 23 69 25 25 75 18 20 61 15 18 59 24 26 74 24 25 81 19 19 83 24 24 88 24 26 85 31 34 89 26 28 79 14 16 64 12 14 62 15 17 65 15 19 67 15 20 75 14 19 77 18 22 83 18 20 77 19 21 72 15 13 53 30 23 56 32 22 46 90 72 72 197 165 127 84 55 25 24 16 40 25 27 76 29 33 80 19 22 67 26 25 69 39 22 38 144 102 60 193 150 105 41 24 32 21 20 52 25 29 58 26 30 57 27 27 53 107 106 124 215 216 220 250 252 249 254 255 255 136 135 140 26 23 32 69 64 70 128 120 117 93 86 70 129 122 96 104 97 69 81 74 58 108 101 93 167 166 164 224 226 223 220 226 214 165 166 152 113 98 91 104 84 75 145 128 108 136 120 104 83 69 69 110 97 106 41 31 40 55 48 56 237 235 238 250 253 255 241 247 255 189 202 236 124 145 188 84 111 164 72 106 170 75 110 178 76 111 177 73 111 176 71 110 179 70 108 181 70 109 186 69 108 187 69 108 187 68 107 182 68 104 178 68 105 175 68 105 173 68 105 173 68 107 174 65 108 176 65 107 179 64 108 179 70 110 182 69 109 181 67 107 179 66 106 178 66 106 178 67 107 179 68 108 180 68 108 180 67 107 179 66 106 178 64 104 176 62 102 174 62 102 174 63 103 175 65 105 177 66 106 178 67 105 180 66 104 179 65 103 176 66 104 177 68 106 177 70 108 179 69 108 177 69 108 177 71 108 178 71 110 179 73 111 182 74 112 183 75 113 186 75 113 186 76 114 187 76 114 187 23 19 52 24 23 57 112 110 149 37 35 75 22 19 62 18 18 56 13 14 42 13 14 44 25 23 70 30 30 82 17 18 62 12 14 55 36 37 85 29 28 85 16 16 78 22 22 86 20 20 82 33 33 93 21 20 77 19 19 71 13 13 65 16 18 67 10 13 64 12 17 72 19 24 82 18 23 81 21 24 79 14 16 65 16 14 54 25 20 52 33 25 48 93 74 76 199 166 135 77 46 26 30 20 55 26 26 86 27 29 86 27 30 83 26 24 73 36 19 38 132 90 52 197 154 112 44 24 33 34 31 62 21 23 46 41 43 64 194 192 213 248 246 255 255 255 255 250 251 245 254 255 249 106 106 104 34 29 33 35 26 27 38 28 19 147 135 113 204 190 153 255 244 203 248 231 203 157 140 122 244 230 221 207 197 187 218 213 193 208 200 181 166 141 134 255 243 232 234 215 183 226 211 180 93 81 69 32 23 26 50 44 58 39 35 50 184 184 192 252 255 255 243 250 255 247 255 255 244 255 255 194 211 239 109 128 171 86 107 160 86 112 169 79 111 170 70 103 170 81 118 188 62 99 177 76 115 194 71 110 189 67 106 183 70 106 182 70 107 178 72 107 175 70 107 175 69 108 177 66 109 178 66 108 182 65 109 182 69 109 181 67 107 179 66 106 178 67 107 179 67 107 179 66 106 178 67 107 179 69 109 181 65 105 177 65 105 177 64 104 176 63 103 175 63 103 175 64 104 176 66 106 178 68 108 180 66 104 177 68 106 179 70 108 181 69 107 180 68 106 177 67 105 176 68 106 177 68 108 178 69 107 178 69 107 178 69 107 178 69 107 178 70 108 181 71 109 182 72 110 185 72 110 185 23 18 48 36 33 64 203 199 234 88 86 123 35 31 68 13 12 44 19 19 43 14 15 43 33 31 80 23 20 73 9 8 52 15 16 60 34 35 83 17 17 69 24 23 80 24 24 84 29 29 91 28 28 88 21 20 77 20 20 74 16 16 68 11 11 63 11 13 64 19 22 75 21 23 80 18 23 78 16 19 72 18 20 68 28 26 65 27 22 54 31 23 47 85 69 72 198 163 135 78 45 28 30 18 56 26 26 90 27 29 88 26 29 84 24 22 71 34 17 36 134 91 57 198 154 115 45 26 30 15 11 34 76 78 91 226 226 236 250 247 255 255 252 255 250 245 239 255 255 243 252 250 238 90 86 77 33 24 25 41 31 30 44 30 21 134 118 95 205 186 144 238 217 172 243 220 186 255 245 221 255 250 241 255 242 234 255 253 234 255 251 234 255 249 239 248 222 207 246 226 189 228 212 176 98 85 69 61 49 49 35 24 38 35 31 46 148 147 153 251 255 255 251 255 255 237 245 247 249 255 255 247 255 255 229 236 255 171 182 212 97 116 158 77 103 154 80 109 167 80 113 180 75 111 185 70 109 188 63 101 182 73 112 191 69 107 182 70 106 180 72 106 177 70 107 177 69 107 178 68 108 180 66 108 182 65 109 184 68 107 182 66 106 178 65 105 177 67 107 179 67 107 179 66 106 178 67 107 179 69 109 181 66 106 178 66 106 178 65 105 177 65 105 177 64 104 176 65 105 177 67 107 179 68 108 180 67 105 178 67 105 178 68 106 179 68 106 179 67 105 176 66 106 176 66 106 176 66 106 176 68 108 178 68 108 178 69 107 178 69 107 178 70 108 181 71 109 182 72 110 185 72 110 185 18 12 40 35 31 58 214 209 239 222 219 248 45 40 70 24 22 46 15 14 32 33 33 59 22 19 66 26 23 78 21 19 66 22 21 65 24 22 69 40 38 85 20 18 67 21 21 73 21 20 77 23 22 80 29 26 81 19 16 69 11 9 59 18 18 68 25 25 75 10 12 63 25 28 81 24 27 80 17 19 70 16 17 63 26 24 61 25 20 52 32 27 50 85 69 72 198 163 133 83 48 28 33 19 54 27 26 86 28 30 87 25 28 79 22 23 67 31 17 32 147 104 70 197 154 112 45 26 20 93 88 95 251 251 249 255 255 250 255 247 245 255 246 243 255 248 237 253 240 224 231 220 202 73 61 47 50 36 35 37 21 22 45 27 23 70 51 34 233 211 174 225 202 160 234 210 176 244 222 199 235 214 211 230 214 215 215 206 201 225 217 206 244 230 217 234 218 195 194 179 140 233 217 181 88 66 53 53 33 34 63 46 54 55 44 52 157 153 150 254 255 250 246 250 253 252 255 255 252 253 255 255 255 253 255 255 248 248 249 251 201 211 236 108 126 166 85 108 158 86 115 173 78 113 181 62 100 175 81 119 200 63 101 182 68 105 183 69 105 181 71 105 177 69 106 176 68 106 177 67 107 179 65 107 183 64 108 183 67 106 181 65 105 177 65 105 177 66 106 178 66 106 178 66 106 178 67 107 179 69 109 181 67 107 179 67 107 179 67 107 179 66 106 178 66 106 178 66 106 178 68 108 180 69 109 181 70 108 179 69 107 178 69 107 178 69 107 178 68 108 178 68 108 178 67 107 179 65 107 179 67 109 181 66 108 180 68 108 180 68 108 180 70 108 183 71 109 184 72 110 185 73 111 186 23 15 39 41 36 58 200 195 217 241 238 255 130 125 145 82 79 96 172 170 183 91 89 110 26 20 68 27 22 78 19 15 65 19 18 62 29 28 70 122 121 161 34 34 72 21 20 60 30 28 77 29 29 81 30 28 77 22 20 67 9 7 54 14 12 59 14 12 59 17 18 66 21 23 72 21 25 73 23 25 73 17 19 60 18 16 53 24 19 51 33 27 53 83 67 70 200 164 130 89 53 27 34 20 46 27 27 79 29 32 85 24 28 75 23 25 64 33 19 32 153 110 78 185 140 99 74 55 41 249 244 240 246 243 228 255 255 237 255 245 232 241 221 210 190 168 155 190 169 152 223 205 183 72 57 38 24 9 4 34 18 21 36 17 19 54 34 25 127 106 75 235 216 176 221 201 168 255 246 225 255 248 248 255 247 255 255 250 254 249 245 242 255 250 238 255 248 222 222 209 167 179 164 125 59 37 23 41 16 19 43 22 29 39 20 24 126 113 105 243 235 224 255 252 248 255 253 250 247 242 238 255 255 244 255 255 236 255 255 244 251 255 255 210 220 247 99 117 155 84 107 157 77 108 172 78 115 186 65 104 183 67 108 188 65 104 181 66 104 179 67 104 175 69 103 174 67 104 175 66 104 177 63 105 181 63 105 181 66 106 178 64 104 176 64 104 176 66 106 178 67 107 179 66 106 178 66 106 178 68 108 180 68 108 180 68 108 180 68 108 180 67 107 179 67 107 179 67 107 179 68 108 180 69 109 181 72 110 181 70 108 179 69 107 178 68 108 178 69 109 179 69 109 179 66 108 180 64 106 178 67 109 181 67 109 181 69 109 181 69 109 181 70 108 183 71 109 184 72 110 185 73 111 186 31 22 41 33 26 42 198 192 204 253 250 255 240 234 244 231 228 235 196 194 199 74 71 88 31 24 68 26 18 75 21 14 65 24 21 64 34 32 69 180 179 210 92 92 118 29 30 58 20 20 56 31 30 70 23 21 61 21 19 58 21 19 58 27 25 64 4 3 43 17 19 60 14 17 62 18 21 66 20 21 65 25 24 64 19 18 52 26 21 53 27 21 49 77 58 62 203 165 128 95 59 25 34 20 35 26 25 65 28 32 77 22 27 69 23 27 62 34 22 32 144 100 71 193 148 107 232 211 190 253 246 228 255 255 230 253 241 215 176 155 134 157 131 116 135 107 95 81 54 37 50 30 5 38 22 0 33 18 13 42 27 32 36 21 28 49 34 31 199 183 157 234 220 183 168 153 120 225 213 191 255 246 247 255 252 255 252 255 255 255 255 255 255 247 237 252 238 211 168 158 109 230 219 174 119 103 87 53 35 35 48 26 38 55 32 40 77 53 43 143 121 100 208 187 166 232 215 195 255 253 237 255 253 240 251 247 235 252 252 244 245 243 244 250 252 255 180 190 217 88 107 147 76 106 160 70 108 173 70 109 184 65 107 183 65 104 181 66 104 177 67 104 174 69 104 172 67 104 174 66 104 175 65 104 179 65 104 179 66 106 178 64 104 174 65 105 175 66 106 176 67 107 177 66 106 176 66 106 176 68 108 178 67 107 177 68 108 178 68 108 178 68 108 178 67 107 177 66 106 176 67 107 177 68 108 178 70 108 179 68 106 177 66 106 176 65 105 175 66 106 178 65 107 179 64 106 178 63 105 177 67 109 181 67 109 181 67 109 183 67 109 183 70 109 184 71 110 185 73 111 186 74 112 187 40 32 45 139 131 142 231 225 229 244 240 241 241 237 236 240 236 233 166 162 159 39 36 47 29 20 63 31 22 77 28 20 71 24 19 60 31 27 60 196 196 220 161 163 178 24 26 41 32 32 58 32 33 64 93 92 123 100 99 130 23 20 51 14 10 43 24 23 57 14 14 52 25 27 66 51 54 95 14 16 57 22 22 60 22 21 55 26 21 53 26 20 48 77 58 64 205 162 127 101 61 26 32 19 29 23 23 59 27 32 74 20 25 67 23 27 62 34 22 34 134 89 68 232 186 153 255 236 212 255 248 227 239 230 201 137 121 95 122 95 76 71 39 26 38 8 0 41 15 0 30 10 0 36 21 0 24 13 7 24 13 17 40 27 37 35 21 20 144 130 103 179 165 126 216 203 161 241 227 198 234 223 217 255 251 255 245 246 250 251 250 248 226 210 197 227 208 178 206 193 141 215 203 153 105 90 69 46 28 26 62 40 52 47 24 30 53 30 16 44 20 0 53 29 3 117 95 72 185 166 149 230 217 201 254 244 234 255 253 244 255 253 246 255 253 252 235 241 255 113 130 160 89 117 165 69 105 165 64 104 174 70 114 187 65 107 181 68 106 179 69 106 176 71 106 174 69 106 174 69 106 176 68 106 179 67 107 179 66 106 176 65 105 175 65 105 175 67 107 177 67 107 177 66 106 176 66 106 176 68 108 178 66 106 176 67 107 177 68 108 178 68 108 178 67 107 177 66 106 176 66 106 176 66 106 176 70 108 179 69 107 178 67 107 177 66 106 176 65 107 179 65 107 179 65 107 179 65 107 179 66 108 180 66 108 180 67 109 183 67 109 183 71 110 185 72 111 186 75 113 188 75 113 188 178 168 176 234 228 232 245 240 237 255 251 245 247 243 234 233 231 219 119 116 107 18 15 22 35 27 68 35 26 81 18 10 61 19 14 54 40 37 66 211 210 228 212 213 218 83 86 91 78 79 97 187 188 209 207 205 227 80 78 100 22 18 43 24 21 48 17 17 45 15 16 47 43 46 81 133 135 173 33 35 73 17 17 55 21 20 54 24 18 52 31 24 55 77 56 65 204 159 126 105 62 30 34 18 31 23 23 61 28 32 80 19 23 71 23 26 67 33 21 41 129 85 76 254 206 186 255 241 227 246 234 218 117 105 83 71 50 31 38 5 0 42 9 4 34 6 2 26 8 0 105 93 67 120 113 87 36 32 23 30 24 26 25 13 23 50 36 33 140 125 92 255 240 190 252 233 177 230 209 162 179 159 134 240 224 209 255 249 237 255 246 233 210 187 171 233 208 177 255 235 182 255 238 186 105 85 58 57 37 28 53 34 36 45 27 27 48 32 16 118 103 80 48 31 13 55 36 22 44 22 11 99 75 65 174 148 135 210 187 171 255 248 232 246 237 228 230 233 238 196 211 234 70 97 140 84 119 175 71 112 178 66 110 181 66 108 180 68 108 178 70 107 175 72 107 173 72 107 173 70 107 175 69 107 178 68 108 178 67 107 177 66 106 176 66 106 176 68 108 178 68 108 178 66 106 176 66 106 176 67 107 177 66 106 176 67 107 177 68 108 178 68 108 178 67 107 177 66 106 176 65 105 175 66 106 176 71 109 180 71 109 180 69 109 179 68 108 178 66 108 180 66 108 180 66 110 181 67 111 182 64 108 181 65 109 182 66 108 182 67 109 183 71 110 185 73 112 187 76 114 189 77 115 190 184 176 187 229 222 229 246 240 240 250 247 242 251 248 241 251 248 243 176 172 169 65 59 71 28 20 61 36 26 76 24 16 57 39 32 63 47 43 60 202 199 206 232 231 227 226 225 221 241 240 246 230 228 242 161 158 179 29 27 49 29 27 51 18 18 44 9 9 37 20 19 50 51 51 79 211 211 237 71 68 95 24 21 48 27 23 48 26 20 46 36 29 60 66 46 57 203 158 127 107 63 34 35 18 34 25 24 64 30 34 82 20 24 72 24 27 68 32 22 47 115 80 84 255 219 211 248 229 222 144 134 124 37 25 9 26 8 0 41 12 8 128 97 95 117 92 85 60 43 25 45 34 4 157 151 119 36 29 10 71 63 50 87 74 66 51 35 19 116 98 58 209 189 138 214 193 138 212 190 141 231 208 177 173 152 131 110 93 77 121 104 88 190 164 147 209 184 154 214 192 143 225 205 155 118 97 66 63 42 23 78 60 46 48 32 16 86 75 47 150 139 107 41 27 1 115 97 77 129 106 90 48 21 4 59 28 7 99 71 49 180 159 140 248 236 224 241 236 240 220 225 244 109 125 158 80 107 152 78 110 167 74 112 175 69 107 178 68 108 180 69 107 178 70 107 177 70 107 175 70 107 175 69 108 177 69 107 178 68 108 178 66 106 176 66 106 176 68 108 178 68 108 178 66 106 176 66 106 176 67 107 177 66 106 176 67 107 177 68 108 178 68 108 178 67 107 177 66 106 176 65 105 175 65 105 175 69 107 178 69 107 178 69 109 179 68 108 178 64 106 178 64 106 178 66 108 180 67 111 182 65 107 181 65 107 181 66 108 182 67 109 183 71 110 185 73 112 187 76 114 189 77 115 190 30 22 46 53 46 64 123 118 125 249 247 250 246 243 252 206 202 216 194 190 205 92 86 112 33 22 65 39 28 70 30 20 44 80 73 81 173 164 165 243 236 230 242 234 221 240 232 219 244 235 228 220 213 220 59 54 77 33 29 62 22 22 56 24 27 60 5 5 39 18 18 46 71 67 84 234 226 237 151 141 149 34 23 29 63 54 57 123 115 126 50 44 70 69 52 62 205 162 130 111 70 40 31 18 35 17 20 61 28 33 75 25 30 70 21 21 59 31 25 53 93 79 92 195 180 185 148 138 139 31 23 20 29 23 11 33 25 14 42 22 21 192 169 163 222 200 177 210 190 155 201 183 143 162 147 104 209 194 151 238 223 182 252 234 194 231 214 171 233 215 169 139 121 75 117 98 56 54 35 2 48 30 8 64 46 32 53 34 27 51 34 24 54 35 18 64 47 21 98 82 46 193 178 139 211 193 157 248 230 194 255 243 205 192 174 134 202 185 139 156 139 93 233 216 172 236 217 177 196 173 139 74 50 16 119 93 60 80 54 27 64 42 28 178 160 156 254 239 244 227 219 232 159 157 178 98 105 133 93 111 149 82 108 157 76 109 176 66 104 179 70 112 188 64 106 180 73 113 182 68 107 174 70 107 175 70 107 177 71 109 180 69 107 178 68 106 177 68 106 177 69 107 178 70 108 179 69 107 178 68 106 177 69 107 180 68 106 179 68 106 179 67 105 178 67 105 178 67 105 178 68 106 179 69 107 180 69 109 179 70 110 180 71 111 181 72 112 182 71 111 181 71 111 181 71 111 183 70 112 184 72 112 184 71 111 183 71 111 183 71 111 183 72 112 184 73 113 185 75 115 187 76 116 188 28 21 54 29 23 49 86 82 96 245 243 254 191 188 207 65 61 84 57 53 80 44 37 71 29 20 63 55 45 82 152 143 160 225 216 219 253 243 241 246 236 227 252 242 230 250 238 226 244 231 223 114 103 109 36 27 54 29 25 62 23 23 61 4 7 42 30 31 61 19 17 38 80 72 83 234 224 225 218 205 199 153 140 132 204 193 187 133 124 129 35 27 51 53 35 47 202 159 125 114 73 41 32 20 34 17 21 58 28 34 70 27 31 66 24 20 55 25 21 48 23 19 36 7 4 13 20 14 18 22 17 14 14 11 2 29 25 16 32 18 18 60 41 35 153 133 108 168 148 113 74 54 17 194 175 133 245 227 181 198 180 132 194 176 128 242 224 178 255 239 197 252 234 196 255 243 215 207 190 170 128 110 98 91 74 67 44 26 26 67 49 47 120 102 90 211 194 176 255 247 225 250 233 205 255 237 204 245 227 189 219 200 157 255 237 192 252 230 183 161 139 92 207 184 140 222 199 157 212 186 149 246 220 185 224 198 165 66 42 16 38 19 5 58 38 37 202 183 189 194 178 189 114 106 117 53 52 68 32 42 69 74 96 137 80 108 171 69 105 179 68 109 188 61 105 180 70 113 181 67 108 174 69 106 174 69 106 174 70 109 178 68 106 177 67 105 176 67 105 176 68 106 177 68 106 177 68 106 177 67 105 176 69 107 180 69 107 180 68 106 179 68 106 179 68 106 179 69 107 180 70 108 181 71 109 182 71 111 181 72 112 182 73 113 183 73 113 183 72 112 182 72 112 182 73 113 185 74 114 186 73 113 185 73 113 185 73 113 185 73 113 185 74 114 186 75 115 187 76 116 188 77 117 189 16 10 48 37 32 64 79 76 95 234 233 249 126 124 146 28 25 52 27 24 53 23 17 53 31 22 69 44 33 75 99 91 112 181 174 182 227 218 223 255 246 245 250 241 236 248 237 233 235 220 225 177 165 179 48 39 68 34 28 64 13 11 51 15 15 49 23 22 40 30 27 36 117 107 115 246 234 234 232 218 207 192 178 167 184 170 167 57 47 56 31 22 51 62 42 54 198 154 119 121 78 43 33 20 30 18 21 54 29 32 65 29 30 60 23 18 48 20 15 38 28 22 36 19 14 20 20 14 16 23 18 15 17 17 7 20 17 8 19 7 9 34 18 18 27 9 0 50 32 12 76 58 36 122 104 80 70 50 23 51 32 2 197 178 146 213 196 166 188 171 143 160 144 119 114 97 79 88 72 59 77 59 55 90 74 74 62 45 51 89 70 74 86 65 62 98 75 69 162 138 128 177 154 140 233 208 188 237 213 189 153 127 100 98 73 42 134 107 77 135 108 78 40 11 0 62 32 4 124 94 70 217 186 165 197 166 146 180 154 137 177 159 149 60 45 42 65 50 53 36 25 33 22 15 23 15 14 28 19 30 50 30 50 85 80 106 163 74 108 179 68 110 184 62 106 177 70 114 179 69 110 174 71 110 177 71 108 176 70 109 178 69 108 177 68 106 177 68 106 177 69 107 178 69 107 178 68 106 177 68 106 177 70 108 179 70 108 179 69 107 180 69 107 180 70 108 181 71 109 182 72 110 183 73 111 184 71 111 181 72 112 182 73 113 183 74 114 184 73 113 183 73 113 183 74 114 184 75 115 185 73 113 185 73 113 185 74 114 186 75 115 187 75 115 187 76 116 188 77 117 189 77 117 189 20 14 58 32 28 65 62 59 86 204 205 226 64 61 90 31 27 60 29 25 58 13 9 46 22 14 63 40 31 76 21 16 39 40 34 48 79 71 84 202 194 205 254 244 252 253 242 250 250 236 251 238 224 247 111 102 133 30 24 62 26 21 61 45 44 75 94 93 101 143 139 138 216 205 209 247 233 232 209 193 180 194 180 167 104 90 90 28 17 31 27 17 51 49 28 43 196 150 114 126 82 43 32 17 24 22 23 51 30 31 59 24 24 50 20 15 38 19 10 29 11 5 15 22 16 20 25 16 17 19 14 10 9 9 0 16 16 6 28 19 22 27 15 19 36 22 21 25 10 5 23 8 1 37 23 14 69 53 40 44 28 13 44 28 12 46 30 14 43 30 14 46 32 19 41 27 18 30 17 11 40 26 26 34 22 26 28 15 22 46 31 38 43 24 26 38 18 19 61 40 37 50 29 24 63 40 32 66 44 31 79 56 40 89 66 48 193 168 148 200 175 155 209 183 166 85 59 42 47 19 5 44 18 5 116 89 78 153 133 122 67 53 44 41 32 27 32 22 23 24 15 20 29 24 30 10 10 20 16 25 42 0 15 48 69 94 148 75 109 173 70 109 178 64 107 176 69 113 176 69 110 172 72 111 176 73 110 178 72 111 180 72 111 180 72 110 181 72 110 181 72 110 181 71 109 180 71 109 180 70 108 179 71 109 180 71 109 180 71 109 182 71 109 182 71 109 182 72 110 183 72 110 183 73 111 184 71 111 181 72 112 182 73 113 183 73 113 183 73 113 183 73 113 183 74 114 184 75 115 185 72 112 184 73 113 185 74 114 186 75 115 187 76 116 188 76 116 188 77 117 189 77 117 189 27 23 73 31 28 73 57 56 90 144 145 175 29 28 62 29 27 64 26 24 61 16 14 54 19 12 63 23 17 63 26 21 51 21 16 38 40 35 57 199 191 214 243 234 253 120 111 132 137 124 150 204 190 223 207 197 234 59 51 92 26 20 58 48 44 69 89 84 88 156 149 143 210 198 198 232 217 214 232 216 203 191 174 164 53 41 43 30 19 36 29 19 56 51 30 47 194 146 108 130 85 43 30 14 15 26 24 48 30 28 49 19 16 35 18 9 28 19 8 24 22 15 22 17 11 11 21 12 13 27 22 18 19 21 10 13 14 6 21 15 19 9 0 7 26 19 26 20 14 18 20 11 16 33 24 27 22 14 12 32 24 21 31 22 17 20 11 6 27 18 13 24 17 11 32 24 21 26 21 18 40 34 36 28 22 26 35 28 35 28 22 26 35 29 31 34 28 28 30 21 22 36 26 25 46 35 31 33 22 16 35 22 14 48 35 26 108 96 84 140 128 116 231 219 207 221 209 197 91 77 68 44 31 22 32 19 11 23 14 5 19 12 4 21 16 12 19 13 15 13 8 12 19 15 16 13 14 19 0 7 20 4 20 46 52 76 124 72 104 163 68 106 171 66 107 173 66 110 171 66 107 169 70 109 174 73 112 179 73 112 181 74 113 182 74 113 182 74 113 182 74 113 182 73 112 181 73 111 182 73 111 182 73 111 182 73 111 182 73 111 182 72 110 181 72 110 181 72 110 181 72 110 181 72 110 181 73 113 183 73 113 183 74 114 184 74 114 184 73 113 183 74 114 184 75 115 185 76 116 186 73 113 185 74 114 186 75 115 187 76 116 188 77 117 189 77 117 189 77 117 189 77 117 189 10 7 62 27 25 74 40 39 79 56 56 92 23 22 62 31 30 70 22 22 60 15 13 53 27 23 74 26 23 70 30 26 61 34 31 60 27 22 54 200 195 227 190 183 214 46 39 70 35 25 60 42 31 71 94 85 130 86 79 121 21 15 51 25 20 43 24 19 23 38 30 27 139 125 125 234 219 216 238 221 213 198 183 178 119 108 114 33 24 43 29 21 58 40 22 38 190 142 102 139 92 46 32 14 14 26 23 42 24 23 39 14 12 25 19 8 22 19 9 18 14 8 10 23 17 17 16 10 10 11 7 4 22 25 16 10 15 9 14 12 17 28 22 32 14 8 20 21 15 27 18 12 22 10 5 12 22 17 23 19 13 17 18 12 14 39 30 33 38 29 32 29 20 21 24 18 18 24 18 20 17 13 14 19 14 18 27 22 26 20 15 19 24 22 25 11 11 13 22 20 21 31 27 28 22 16 16 34 29 26 33 25 22 34 26 23 48 41 35 98 91 85 54 47 41 34 27 21 24 17 11 29 24 18 13 8 2 20 17 12 12 13 7 8 9 4 15 13 14 20 18 21 11 10 8 17 18 20 4 13 22 8 23 46 42 65 107 75 104 160 71 106 170 71 110 175 70 111 173 68 109 171 71 110 177 75 114 183 74 113 182 75 114 183 76 115 184 76 115 184 75 114 183 74 113 182 74 112 183 74 112 183 75 113 184 75 113 184 74 112 183 74 112 183 73 111 182 73 111 182 72 110 181 72 110 181 75 115 185 75 115 185 75 115 185 75 115 185 74 114 184 74 114 184 76 116 186 77 117 187 75 115 187 76 116 188 76 116 188 77 117 189 78 118 190 79 119 191 79 119 191 79 119 191 22 21 78 29 29 81 23 24 68 26 28 69 43 44 90 31 32 76 17 19 57 18 18 56 22 20 69 27 25 74 9 7 44 28 27 61 39 34 74 201 196 237 101 96 136 34 29 69 34 27 68 44 37 81 37 30 81 39 33 79 26 21 53 15 10 30 21 15 27 20 11 16 107 95 97 248 234 234 203 188 191 199 186 193 202 192 200 52 48 65 13 9 44 43 26 42 185 137 97 150 102 56 35 17 13 21 18 35 16 16 26 12 11 19 23 13 22 18 8 16 22 16 16 16 12 11 22 18 17 12 11 9 11 18 11 11 20 15 17 18 23 5 2 13 17 11 23 12 4 15 22 14 25 22 14 25 5 0 6 27 17 25 22 12 20 13 2 8 19 8 14 23 12 16 27 16 20 34 23 27 23 14 17 27 18 19 26 17 18 24 18 18 21 16 20 22 20 23 27 23 24 23 19 20 26 20 22 33 27 27 17 8 9 22 14 12 18 10 8 15 7 5 22 17 13 12 7 3 20 15 11 13 10 5 3 0 0 14 15 10 10 15 9 9 14 10 13 13 15 17 15 18 5 4 2 7 9 8 14 21 27 5 18 37 44 63 105 83 110 165 75 109 172 76 114 179 73 114 176 72 113 177 74 113 182 76 114 185 74 113 182 75 114 183 77 116 185 77 116 185 75 114 183 74 113 182 74 113 182 75 114 183 76 115 184 76 115 184 76 114 185 75 113 184 75 113 184 75 113 184 74 112 183 74 112 183 76 116 185 76 116 185 76 116 186 75 115 185 74 114 184 74 114 184 75 115 185 76 116 186 76 116 186 76 116 186 76 116 188 76 116 188 77 117 189 78 118 190 80 120 192 80 120 192 15 14 72 35 35 89 20 21 69 24 25 71 34 34 84 35 36 82 25 27 65 10 12 50 16 14 61 23 21 68 20 20 58 18 18 56 42 40 87 161 159 208 30 28 75 33 32 76 27 26 70 32 30 77 28 25 80 25 21 71 20 17 48 21 18 39 18 11 29 22 14 29 133 122 130 230 219 227 88 75 92 45 34 50 148 142 154 127 124 141 24 24 58 32 18 31 181 133 93 156 110 61 39 21 17 17 17 29 11 11 19 13 12 17 25 18 25 18 9 14 18 14 13 10 9 7 22 18 19 12 12 12 13 22 17 9 20 16 12 15 22 14 14 24 14 11 20 15 12 19 9 6 13 18 15 22 22 17 24 4 0 5 22 15 22 14 7 14 19 10 15 17 8 13 17 8 11 14 5 8 15 9 11 18 12 12 14 8 8 17 11 11 18 14 15 13 11 14 12 8 9 15 11 12 11 5 7 11 5 7 23 14 15 18 9 10 19 10 11 22 16 16 10 4 4 13 9 6 15 11 10 8 7 5 25 24 22 8 10 7 11 17 15 1 7 5 15 16 20 10 10 12 19 18 16 17 17 17 7 12 16 4 15 33 47 65 105 87 112 166 77 109 170 76 114 179 74 114 176 73 114 180 73 111 182 74 112 185 75 114 183 76 115 184 78 117 186 78 117 186 76 115 184 75 114 183 75 114 183 76 115 184 76 115 184 76 115 184 76 114 185 76 114 185 76 114 185 76 114 185 76 114 185 76 114 185 75 115 184 75 115 184 75 115 185 74 114 184 72 112 182 72 112 182 74 114 184 75 115 185 76 116 186 75 115 185 75 115 187 75 115 187 76 116 188 77 117 189 79 119 191 80 120 192 16 17 73 25 27 78 22 24 73 28 30 78 30 32 83 34 36 84 21 24 59 15 18 51 22 24 65 19 20 64 13 15 53 25 27 66 39 39 89 52 52 104 31 31 81 21 23 71 29 31 79 28 30 79 27 28 84 25 25 75 19 19 53 13 13 39 15 11 38 19 14 37 151 142 163 171 161 185 29 19 46 16 10 36 28 27 43 47 50 67 22 26 55 28 16 26 167 122 80 158 111 65 34 19 12 12 14 26 11 14 21 15 16 20 17 15 20 19 14 18 15 14 12 16 16 16 15 13 16 11 12 16 9 18 15 6 16 15 8 11 20 10 13 22 5 9 12 9 15 13 10 16 14 8 14 14 9 13 14 13 14 16 12 12 14 7 7 9 10 10 12 13 13 15 11 11 13 10 10 10 14 14 14 13 13 11 10 10 8 12 12 10 16 14 15 14 12 15 14 10 11 14 10 11 16 10 12 16 10 12 17 8 11 16 7 10 14 8 10 16 10 12 16 10 12 13 9 8 10 10 10 12 14 13 11 13 12 6 10 9 7 16 15 5 13 15 10 13 18 14 13 18 14 13 11 17 17 17 14 19 23 2 13 31 50 65 104 90 113 167 80 110 172 78 113 179 71 109 174 79 118 185 74 112 185 82 120 193 77 116 185 78 117 184 79 118 185 79 118 185 77 116 183 76 115 182 75 114 183 75 114 183 75 114 183 76 115 184 77 116 185 77 116 185 77 116 185 77 116 185 76 115 184 76 115 184 75 114 183 75 114 183 74 113 182 74 113 182 75 114 183 77 116 185 78 116 187 79 117 188 79 117 188 77 115 186 75 113 184 75 113 184 77 115 186 78 116 187 77 115 188 77 115 188 17 19 70 25 27 78 22 24 73 28 30 79 30 31 85 33 35 83 19 22 57 12 15 46 17 19 58 21 23 64 19 21 59 26 28 69 27 27 79 32 33 89 22 23 77 25 28 79 23 29 77 24 30 80 26 29 84 24 26 77 18 20 58 13 14 45 15 12 43 18 13 45 133 127 161 66 58 95 22 16 54 25 21 54 13 15 36 12 17 37 13 19 45 35 24 30 161 116 74 162 115 69 31 16 9 12 14 26 9 14 18 13 17 20 15 15 17 16 14 17 9 9 9 18 18 18 17 16 21 9 10 14 5 14 11 9 18 17 15 15 23 18 17 25 13 17 16 11 18 11 9 16 9 7 14 7 6 11 7 9 11 10 13 15 14 19 19 19 12 12 12 14 14 14 13 13 13 12 12 12 14 14 14 12 14 13 10 10 8 11 11 9 11 9 10 13 9 10 14 8 10 15 9 9 19 10 11 20 11 12 21 11 12 20 10 11 16 7 8 20 11 12 19 13 13 15 11 12 9 9 9 8 10 9 10 11 13 9 13 14 3 11 13 1 6 9 7 7 15 11 10 15 10 8 9 10 10 10 13 16 21 10 18 37 42 57 96 90 111 166 83 113 175 82 117 183 76 114 179 81 120 187 75 113 186 81 119 194 78 117 186 79 118 185 80 119 186 80 119 186 79 118 185 78 117 184 77 116 185 77 116 185 78 117 186 78 117 186 79 118 187 79 118 187 78 117 186 78 117 186 77 116 185 77 116 185 78 117 186 77 116 185 76 115 184 76 115 184 76 115 184 77 116 185 78 116 187 79 117 188 79 117 188 77 115 186 75 113 184 75 113 184 76 114 185 77 115 186 77 115 188 77 115 188 18 18 68 27 27 77 24 24 74 30 30 82 30 29 86 33 33 83 19 19 55 12 13 44 16 18 56 21 23 62 20 22 60 23 25 66 18 19 73 17 18 75 18 19 73 29 32 85 21 28 80 22 29 81 24 30 82 24 28 76 19 20 64 14 14 52 12 13 43 15 14 48 55 52 99 21 17 67 34 31 74 9 9 45 4 8 37 17 23 47 16 22 46 28 18 19 155 111 66 171 124 78 28 13 6 12 16 27 7 15 18 11 17 17 13 14 18 14 14 16 21 21 23 16 16 18 10 8 13 12 11 16 16 21 17 15 17 14 10 5 9 10 4 8 13 12 8 9 10 2 11 12 4 18 18 10 18 17 12 15 11 8 13 9 6 17 11 11 16 10 10 16 10 10 16 10 10 16 10 10 17 11 11 16 12 11 16 10 10 17 11 11 21 12 13 21 12 13 21 11 12 21 11 10 21 9 9 20 8 8 21 7 6 20 6 5 23 11 11 20 10 9 18 10 8 18 12 12 16 14 15 14 14 14 13 14 16 11 15 18 11 15 18 6 10 13 12 11 19 20 15 21 17 13 14 12 10 11 10 13 18 5 13 32 34 49 88 91 112 167 85 115 177 85 120 184 78 116 179 82 121 188 76 114 187 82 120 193 79 118 187 80 119 186 81 120 187 82 121 188 81 120 187 80 119 186 80 119 186 80 119 186 81 120 187 81 120 187 81 120 189 81 120 189 80 119 188 79 118 187 79 118 187 78 117 186 80 119 188 80 119 188 79 118 187 78 117 186 77 116 185 78 117 186 78 117 186 79 118 187 78 116 187 77 115 186 76 114 185 75 113 184 76 114 185 77 115 186 77 115 186 77 115 186 18 19 65 26 27 75 23 23 73 29 29 83 30 29 87 34 31 84 18 18 54 10 11 42 22 22 60 20 22 61 13 15 53 20 21 65 22 23 79 18 19 76 21 24 79 27 33 85 22 29 84 22 29 83 24 30 82 23 27 75 17 20 65 11 13 52 11 12 42 14 14 48 13 10 65 27 26 84 24 22 71 13 15 54 16 19 52 18 22 51 9 13 38 34 22 22 155 108 64 180 132 84 28 13 6 15 18 27 7 15 17 9 18 17 12 13 17 13 13 15 13 13 15 14 14 16 15 10 16 15 10 14 14 13 8 13 10 5 20 8 8 31 15 15 31 14 7 26 9 1 22 5 0 25 6 0 28 9 2 29 8 3 30 9 4 33 9 7 35 11 9 32 8 6 32 8 8 33 9 9 29 8 7 29 8 7 31 10 9 32 11 10 30 9 8 31 10 9 34 10 8 35 11 7 37 12 8 38 13 8 41 14 7 42 15 8 37 12 7 32 9 3 29 8 3 27 9 5 24 8 8 19 7 7 17 7 8 16 10 12 13 11 14 7 6 11 11 6 13 17 10 17 17 11 11 18 14 13 15 16 21 5 14 31 28 43 82 94 115 168 87 117 177 84 120 182 77 115 177 80 119 184 78 116 187 85 123 194 81 120 189 82 121 188 83 122 189 83 122 189 82 121 188 82 121 188 82 121 188 82 121 188 83 122 189 83 122 189 82 121 190 82 121 190 82 121 190 81 120 189 81 120 189 80 119 188 81 120 189 81 120 189 80 119 188 79 118 187 79 118 187 79 118 187 79 118 187 79 118 187 78 116 187 77 115 186 77 115 186 76 114 185 77 115 186 77 115 186 78 116 187 79 117 188 19 18 62 27 25 72 24 22 72 30 27 84 31 26 90 35 30 88 19 17 56 11 12 43 24 24 62 22 21 61 11 13 52 19 20 64 27 28 84 20 20 80 25 28 83 28 31 86 25 30 88 25 30 88 25 28 81 22 24 72 16 17 61 9 12 47 9 13 38 12 15 46 22 22 76 26 26 86 15 15 67 23 24 68 7 9 47 9 10 41 12 13 41 36 20 21 157 106 63 181 130 83 29 12 4 17 17 25 8 13 16 11 17 15 12 13 15 13 13 15 5 5 7 18 13 17 23 14 19 21 11 12 23 14 7 26 13 5 25 4 1 29 0 0 42 1 0 56 9 1 66 19 11 73 24 17 79 30 23 87 37 30 91 41 34 94 41 35 88 35 29 80 27 21 77 26 22 75 24 20 66 15 11 64 13 9 66 17 13 64 16 12 73 25 21 73 28 23 81 34 28 88 41 33 99 51 39 109 60 46 116 67 52 120 71 56 124 76 62 114 68 55 99 55 44 79 39 31 59 22 16 43 8 4 37 3 1 31 5 4 21 11 10 15 11 12 19 9 17 18 9 14 15 6 7 16 12 11 16 17 22 5 14 31 17 32 71 92 115 167 87 118 175 84 120 180 79 118 177 81 121 182 81 118 186 87 124 194 82 121 188 83 122 187 84 123 188 84 123 188 83 122 187 82 121 186 83 122 189 84 123 190 82 121 188 82 121 188 82 121 188 82 121 188 82 121 188 82 121 188 82 121 190 82 121 190 81 120 189 81 120 189 80 119 188 80 119 188 80 119 188 80 119 188 80 119 188 81 120 189 79 117 188 79 117 188 78 116 187 78 116 187 78 116 187 78 116 187 80 118 189 80 118 189 19 18 60 27 26 70 24 21 74 29 25 84 31 24 91 35 29 89 20 18 58 13 12 44 20 18 57 23 22 62 17 16 56 19 20 66 27 28 85 17 17 77 26 29 84 26 29 84 28 30 91 27 29 90 26 27 84 23 24 72 15 17 55 9 13 42 9 14 36 12 15 46 20 22 71 19 20 77 26 27 83 12 13 61 6 5 45 18 17 51 20 17 48 32 13 17 159 106 62 174 120 73 31 11 2 14 15 20 8 14 14 10 16 14 13 15 14 14 14 14 18 16 17 15 9 11 16 4 8 22 8 8 25 11 2 25 5 0 40 10 2 66 26 18 115 61 51 144 82 71 168 106 93 178 116 103 181 118 103 182 119 104 185 119 103 184 118 102 181 115 99 170 104 88 169 103 89 163 100 85 148 85 70 142 79 64 144 82 69 141 79 66 144 85 71 145 86 70 153 92 74 162 101 82 174 112 91 187 123 98 193 129 102 196 132 105 185 124 96 186 126 102 187 129 109 184 128 111 169 117 103 132 84 72 84 37 27 41 4 0 22 4 2 15 6 7 22 11 17 23 12 16 18 8 7 14 10 7 13 14 18 4 13 28 5 21 57 90 113 163 87 118 173 87 123 181 84 123 180 84 124 183 83 121 186 86 123 191 84 123 188 84 123 188 85 124 189 84 123 188 84 123 188 83 122 187 84 123 190 84 123 190 83 122 189 82 121 188 82 121 188 82 121 188 82 121 188 83 122 189 83 122 191 83 122 191 82 121 190 81 120 189 81 120 189 81 120 189 81 120 189 82 121 190 82 121 190 82 121 190 80 118 189 80 118 189 80 118 189 80 118 189 79 117 188 80 118 189 81 119 190 83 121 192 21 19 59 29 26 71 25 20 74 30 24 84 32 22 91 36 27 90 22 17 58 14 13 47 16 14 53 24 23 63 18 17 59 18 19 65 26 27 84 15 15 77 28 31 86 24 26 83 28 28 92 28 25 92 27 25 88 25 23 73 18 19 50 11 13 34 9 14 36 12 16 45 17 20 61 11 14 65 22 23 80 16 16 70 22 21 61 21 17 50 11 5 39 42 19 27 169 112 69 168 112 63 36 14 3 13 12 17 8 12 11 10 15 11 13 13 13 14 12 13 19 15 16 19 10 11 20 5 8 26 6 7 34 14 3 58 32 17 116 80 68 179 131 119 200 143 124 210 148 127 216 154 131 217 155 130 219 155 128 220 156 128 225 160 130 228 163 133 229 164 132 218 155 122 221 158 125 222 159 126 205 144 113 199 138 107 202 141 112 198 137 108 207 143 115 207 142 112 210 144 112 215 149 114 225 157 120 229 161 122 230 161 119 227 158 116 221 154 111 214 151 110 209 147 110 207 148 114 210 155 125 201 147 121 167 117 94 126 87 70 52 32 25 25 14 12 17 2 5 22 7 10 20 10 8 16 11 7 14 15 17 9 19 31 2 18 52 92 116 164 86 119 172 87 124 179 85 125 177 85 126 180 85 123 185 85 123 186 86 125 190 86 125 190 86 125 190 86 125 190 84 123 188 84 123 188 85 124 189 85 124 189 84 123 190 84 123 190 83 122 189 83 122 189 82 121 188 83 122 189 83 122 189 83 122 189 83 122 191 83 122 191 83 122 191 83 122 191 83 122 191 83 122 191 83 122 191 83 122 191 81 120 189 82 121 190 82 120 191 81 119 190 81 119 190 81 119 190 83 121 192 85 123 194 26 21 53 32 27 67 27 20 72 29 23 85 30 23 91 34 28 90 20 18 58 14 13 45 15 13 50 24 22 62 16 15 57 17 15 64 28 27 84 18 19 76 31 34 89 23 26 81 25 25 87 27 25 90 27 25 88 26 23 76 19 20 50 12 14 35 11 13 34 12 16 43 19 23 58 21 24 69 18 19 75 22 21 78 11 10 52 15 14 48 19 13 51 35 11 24 175 120 79 165 109 60 40 18 5 15 13 16 12 13 8 13 14 8 14 10 9 15 9 11 17 7 8 35 19 20 44 18 19 54 23 18 98 67 49 158 124 99 196 154 132 208 157 136 214 157 130 210 149 120 211 147 119 223 160 129 237 174 143 244 179 147 246 182 147 247 183 147 243 181 144 234 172 135 243 181 142 248 189 149 237 177 140 234 174 138 239 179 143 237 174 139 241 175 141 239 173 138 241 173 136 246 178 139 249 184 142 250 186 142 246 182 136 239 177 130 225 163 116 229 166 122 227 164 121 220 156 118 217 157 120 216 160 123 205 153 116 184 140 113 150 121 107 88 65 59 42 17 12 32 9 3 29 11 7 19 11 8 15 15 15 12 20 33 4 23 56 95 122 169 85 121 173 83 122 177 83 123 175 84 123 178 85 124 181 85 125 186 87 127 189 87 126 191 87 126 191 86 125 190 85 124 189 85 124 189 85 124 189 86 125 190 86 125 190 85 124 189 84 123 190 83 122 187 83 122 189 83 122 187 83 122 189 83 122 189 85 124 191 85 124 191 85 124 193 84 123 190 84 123 192 84 123 192 83 122 191 83 122 191 82 121 190 83 122 191 83 122 191 83 122 191 82 120 191 82 120 191 84 122 193 86 124 195 79 71 86 42 33 60 29 21 72 37 28 93 26 21 87 33 32 89 20 24 61 11 15 44 14 15 46 25 25 63 22 19 64 22 20 70 18 18 70 28 31 84 26 32 84 19 26 80 26 28 85 25 25 85 25 23 86 27 24 79 20 20 58 12 12 38 12 13 33 15 17 38 16 19 52 26 29 72 17 18 72 15 16 70 20 21 67 11 10 50 12 10 49 37 17 29 163 114 74 171 120 73 30 8 0 16 11 8 14 11 2 18 14 5 24 14 13 26 10 13 60 35 39 105 71 72 104 56 54 125 73 60 174 127 97 198 153 114 213 167 133 221 171 138 221 162 128 227 164 129 231 166 134 233 168 138 235 170 142 241 176 148 246 181 153 249 185 157 251 190 161 246 187 155 240 181 147 243 184 150 241 182 150 243 182 151 253 192 163 253 189 161 241 176 146 255 190 158 255 190 158 248 185 152 236 177 145 252 198 164 250 200 163 240 192 154 243 191 154 226 170 133 235 171 135 222 156 121 231 166 128 219 157 116 214 162 115 192 144 106 188 143 124 159 115 102 130 83 63 91 53 34 34 6 2 22 8 8 20 16 17 6 14 27 10 28 66 94 124 176 84 125 177 78 121 174 87 126 181 87 124 179 87 128 184 85 125 184 87 127 188 86 126 188 85 125 187 85 125 187 86 126 188 86 126 188 85 125 187 84 124 186 85 125 187 84 124 186 83 122 187 84 124 186 84 123 188 84 124 186 84 123 188 83 122 187 84 123 188 84 123 188 84 123 190 84 123 188 84 123 190 84 123 190 84 123 190 84 123 190 85 124 191 85 124 191 84 123 190 85 124 191 86 125 194 87 126 195 89 128 197 90 129 198 198 186 188 40 29 43 38 27 67 36 29 81 22 19 74 59 61 109 35 40 72 13 19 45 20 21 49 22 21 55 14 8 54 27 23 74 21 18 73 21 22 76 18 24 76 20 27 79 20 26 78 22 25 80 24 24 84 25 25 79 20 19 61 13 12 43 12 13 34 15 17 38 18 21 56 28 31 76 21 23 74 17 19 70 19 20 66 12 14 53 14 14 52 30 14 24 156 111 70 180 132 84 28 9 0 16 11 8 23 19 10 12 5 0 14 0 0 52 30 33 112 80 83 123 79 78 127 68 60 161 99 78 199 143 106 213 160 116 219 167 127 218 164 126 226 168 130 228 168 131 234 171 138 239 174 144 245 179 153 250 184 160 252 188 163 253 189 164 244 184 158 244 184 156 243 186 156 249 192 162 246 186 158 240 179 151 246 182 157 243 179 154 250 189 160 249 188 159 249 184 156 251 185 159 243 182 154 237 180 151 228 177 148 228 179 147 231 180 149 244 189 158 227 162 130 221 152 119 225 157 120 220 157 116 212 155 110 197 145 105 196 144 120 182 127 106 181 124 94 133 83 56 83 50 41 30 10 11 24 16 14 6 10 21 14 32 70 92 122 174 82 123 175 78 121 176 88 124 182 85 119 180 86 125 182 87 127 186 88 128 189 87 127 189 86 126 188 86 126 188 87 127 189 87 127 189 87 127 189 86 126 188 87 127 189 86 126 188 85 125 187 85 125 187 86 126 188 86 126 188 85 125 187 84 124 186 85 124 189 85 124 189 86 125 190 86 125 190 86 125 190 86 125 190 86 125 192 86 125 192 86 125 192 86 125 192 86 125 192 87 126 193 87 126 193 88 127 194 88 127 196 88 127 196 244 231 223 158 148 147 35 26 45 49 44 74 134 132 169 171 174 207 28 32 59 7 9 32 27 25 49 34 31 62 29 22 66 28 21 75 23 17 79 28 26 89 21 23 80 20 25 80 16 22 72 18 24 74 24 25 82 25 25 79 20 19 61 12 12 46 11 13 38 15 16 44 18 20 59 25 27 75 22 23 77 19 22 73 17 20 63 15 17 55 20 21 52 29 14 19 159 115 70 172 126 74 26 8 0 22 17 21 16 12 9 21 13 10 47 29 29 89 63 64 108 73 69 110 66 55 142 86 69 183 123 97 199 144 105 209 156 112 221 165 128 220 164 129 232 176 139 235 179 142 238 182 149 241 182 152 238 176 151 233 171 148 229 167 144 227 167 143 238 178 152 239 182 155 242 185 156 248 191 162 243 183 157 236 174 151 243 178 156 241 176 154 228 171 142 236 176 148 240 170 145 234 158 135 233 157 134 216 142 117 196 129 103 184 123 94 191 132 102 190 131 99 207 142 112 209 143 111 201 135 103 206 142 107 205 145 109 205 149 114 194 143 114 188 135 104 188 133 94 169 119 86 116 83 68 47 26 21 21 8 2 20 19 27 28 42 77 99 125 174 91 126 180 86 125 184 95 126 190 90 121 185 92 126 190 93 131 194 90 128 191 88 128 190 87 127 189 88 128 190 89 129 191 89 129 191 89 129 191 88 128 190 89 129 191 88 128 190 87 127 189 87 127 189 88 128 190 87 127 189 86 126 188 86 126 188 87 126 191 88 127 192 88 127 192 89 128 193 89 128 193 89 128 193 89 128 195 89 128 195 87 126 193 87 126 193 88 127 194 89 128 195 89 128 195 89 128 195 88 127 194 88 127 194 244 230 219 234 223 217 107 98 101 203 200 211 230 228 250 94 94 118 25 26 47 14 12 33 71 68 87 120 115 138 27 17 54 31 21 71 28 18 78 26 20 80 23 23 77 21 25 73 14 21 65 17 24 70 23 26 81 24 24 78 19 18 62 11 11 45 11 12 40 15 16 46 21 23 64 24 26 77 21 24 79 22 25 76 18 21 62 14 19 51 20 24 51 29 15 15 162 119 68 173 128 73 27 11 0 17 14 21 5 1 2 24 14 13 56 35 34 86 55 52 106 68 55 122 77 58 165 111 87 186 129 99 185 132 92 198 145 103 213 152 121 215 152 121 202 142 106 197 139 102 192 132 98 184 123 94 181 117 90 183 119 94 193 129 104 201 139 114 228 167 139 237 178 148 242 183 153 244 185 155 240 179 151 241 177 150 250 186 161 242 180 155 216 161 131 230 170 142 235 163 139 219 139 116 219 132 112 197 112 91 187 109 86 188 116 91 170 105 77 184 120 92 209 144 116 211 146 118 232 166 140 210 146 119 199 139 111 198 142 115 194 145 115 189 140 107 179 126 86 173 124 91 144 113 95 86 66 57 35 18 11 17 10 18 37 48 80 102 126 174 95 126 183 87 121 184 91 122 187 91 122 187 90 123 190 90 125 191 90 128 191 89 129 191 88 128 190 89 129 191 90 130 192 90 130 192 90 130 192 89 129 191 90 130 192 89 129 191 88 128 190 89 129 191 89 129 191 89 129 191 89 129 191 88 128 190 90 129 194 90 129 194 90 129 194 90 129 194 90 129 194 90 129 194 89 128 195 89 128 195 88 127 194 88 127 194 89 128 195 89 128 195 90 129 196 90 129 196 90 129 196 90 129 196 237 220 213 250 237 231 246 237 232 231 225 227 188 184 198 40 39 57 18 17 35 21 18 35 81 75 85 222 214 225 59 47 71 41 30 64 28 19 64 16 10 58 40 38 78 29 31 69 16 24 61 18 25 67 23 26 77 22 22 74 17 16 58 12 11 45 12 12 40 14 15 46 23 24 68 22 24 75 19 22 77 22 25 76 17 21 59 10 15 44 16 21 43 28 17 11 155 110 55 180 135 78 31 14 4 13 11 22 15 13 18 31 19 19 56 31 27 95 61 51 125 84 64 141 95 69 166 115 86 178 125 93 187 138 98 206 152 114 216 152 125 220 150 124 221 150 118 212 139 104 199 126 93 192 118 89 192 118 91 195 124 96 206 135 107 215 146 117 217 151 117 234 170 135 241 179 142 240 178 141 236 174 137 243 180 145 252 189 156 239 178 147 231 178 146 220 163 134 217 145 120 216 134 112 220 132 112 182 94 72 155 73 49 154 78 54 146 76 50 156 90 64 177 111 87 198 133 111 224 159 139 210 149 130 219 164 143 184 136 114 180 135 112 192 148 121 192 142 109 150 106 77 140 114 99 91 72 65 59 38 35 32 20 30 48 57 86 108 130 177 102 131 189 90 121 186 90 124 188 95 130 196 94 129 197 90 125 191 91 129 192 89 129 191 89 129 191 89 129 191 90 130 192 91 131 193 90 130 192 90 130 192 90 130 192 89 129 191 89 129 191 89 129 191 91 131 193 91 131 193 91 131 193 90 130 192 93 131 196 93 131 196 92 130 195 92 130 195 91 129 194 90 128 193 89 127 192 89 127 192 91 129 194 90 128 193 90 127 195 90 127 195 91 128 196 93 130 198 94 131 199 95 132 200 253 234 230 240 225 218 234 223 217 228 220 218 99 93 103 32 28 43 37 33 50 14 8 22 102 93 96 233 223 224 164 151 160 44 31 48 36 25 55 102 95 129 153 150 179 44 45 75 19 25 59 19 27 66 23 25 74 21 22 70 18 16 56 15 11 44 14 11 38 13 13 41 15 14 56 19 19 69 14 15 69 14 16 64 11 15 52 8 12 39 14 19 39 32 19 11 158 113 56 166 120 61 31 14 4 20 18 29 19 14 20 40 26 25 95 64 59 134 95 80 137 95 70 148 103 72 161 114 86 180 133 103 194 150 115 196 146 113 201 136 114 208 137 115 206 139 110 188 122 90 168 101 72 160 93 66 160 93 67 162 95 69 165 98 71 167 100 71 201 135 103 222 156 121 231 165 130 227 162 124 223 158 120 234 170 132 250 184 149 241 178 143 230 176 140 223 164 132 215 146 117 204 127 101 192 110 86 161 79 55 143 67 43 146 74 50 131 63 40 111 45 23 118 51 32 112 47 29 102 41 23 106 50 33 98 51 33 105 64 46 105 68 50 123 85 66 129 84 61 129 91 70 131 109 98 95 80 75 58 34 34 41 25 36 66 73 101 112 135 177 106 132 191 91 125 189 90 128 191 97 136 201 94 133 198 91 129 194 90 130 192 90 130 192 89 129 191 90 130 192 91 131 193 91 131 193 91 131 193 90 130 192 91 131 193 90 130 192 90 130 192 91 131 193 92 132 194 92 132 194 92 132 194 91 131 193 94 132 197 94 132 197 93 131 196 93 131 196 92 130 195 91 129 194 90 128 193 90 128 193 92 130 195 92 130 195 91 128 196 91 128 196 92 129 197 94 131 199 96 133 201 97 134 202 241 220 215 247 230 223 235 222 216 238 228 227 94 86 97 40 33 49 16 9 25 20 12 23 87 77 75 235 225 215 247 234 226 114 103 101 182 170 182 231 222 241 134 129 151 27 27 53 19 25 59 20 25 65 23 24 72 23 21 68 22 18 53 19 15 42 16 13 32 14 11 32 18 14 47 32 29 72 24 22 69 10 11 55 8 11 44 11 13 38 16 19 38 32 17 10 174 125 69 158 109 51 34 16 6 19 16 25 13 4 7 48 29 23 129 93 81 146 101 80 132 87 58 140 95 64 150 108 83 179 139 114 186 149 122 180 134 108 194 133 114 195 132 114 184 132 110 163 117 94 144 98 75 136 88 68 136 88 68 146 94 73 162 105 85 178 117 96 170 106 79 197 132 104 221 152 121 230 159 129 227 156 124 235 164 132 255 182 153 254 185 152 243 181 144 225 163 124 201 132 99 187 116 86 173 102 74 151 84 57 112 48 23 82 20 0 105 42 24 129 66 49 151 84 68 139 76 61 134 77 60 115 68 50 71 35 13 66 37 19 135 105 97 117 84 79 74 34 26 96 61 55 101 83 81 104 89 92 62 35 40 55 35 47 84 90 114 114 136 175 100 129 185 89 124 188 84 128 189 86 132 192 83 127 188 88 129 191 92 132 193 91 131 192 90 130 191 91 131 192 91 131 192 91 131 192 91 131 192 90 130 191 93 133 194 93 133 194 92 132 193 92 132 193 92 132 193 93 133 194 92 132 193 91 131 192 94 132 195 94 132 195 94 132 195 94 132 195 94 132 195 93 131 194 93 131 196 92 130 195 93 131 196 93 131 196 93 131 196 93 131 196 94 132 197 95 133 198 96 134 199 96 134 199 246 227 213 255 241 231 253 239 236 234 223 227 217 209 222 59 52 68 36 28 43 24 14 22 108 97 91 228 216 200 251 238 221 245 233 219 223 211 211 194 184 195 44 39 61 20 17 48 18 22 59 19 24 66 25 23 72 25 22 67 25 20 52 22 17 37 19 13 23 16 10 22 34 29 52 58 52 86 44 39 79 17 15 54 13 12 43 15 15 41 17 18 39 29 11 7 169 118 65 170 117 63 40 20 9 16 9 16 34 23 19 77 53 41 146 105 85 150 103 77 137 90 60 126 82 55 110 72 53 117 81 65 97 65 44 79 38 18 93 34 18 74 12 0 63 14 0 63 20 3 70 27 11 75 29 14 71 25 9 71 22 5 87 32 12 105 44 23 140 74 48 179 110 81 223 150 118 252 177 145 252 177 145 249 175 140 255 187 155 255 192 157 250 183 140 233 166 123 203 134 95 170 102 67 121 56 26 116 55 27 147 91 68 191 136 116 164 106 92 178 116 103 189 123 111 196 132 120 164 106 92 184 137 117 255 225 199 130 102 81 49 20 16 70 38 39 70 30 30 77 42 40 87 67 68 99 80 82 86 55 60 79 53 64 115 113 134 130 146 180 109 136 189 99 135 197 93 138 197 86 135 191 83 130 186 93 138 197 93 133 194 92 132 193 91 131 192 91 131 192 92 132 193 92 132 193 91 131 192 90 130 191 96 136 197 95 135 196 94 134 195 93 133 194 93 133 194 93 133 194 92 132 193 91 131 192 94 132 195 95 133 196 95 133 196 95 133 196 95 133 196 95 133 196 95 133 198 95 133 198 93 131 196 94 132 197 94 132 197 95 133 198 95 133 198 95 133 198 95 133 198 95 133 198 193 177 152 247 234 217 214 203 201 224 214 223 239 230 247 172 165 183 32 24 37 66 55 61 208 195 189 241 228 212 239 224 203 235 222 203 223 212 206 101 91 102 41 32 63 21 15 59 21 22 68 21 23 71 24 20 71 32 25 69 19 10 37 80 72 85 57 49 47 55 47 45 147 139 150 166 158 181 32 25 58 23 17 51 10 7 36 17 15 39 15 13 37 34 14 13 166 112 65 166 110 59 52 25 14 28 16 16 49 31 19 124 96 74 169 123 97 147 96 67 122 75 47 98 56 32 57 21 9 76 43 34 83 54 40 79 42 26 72 16 1 163 101 86 233 174 160 215 157 145 184 126 114 166 108 96 168 110 96 193 134 116 199 134 114 146 79 53 137 63 34 121 45 11 175 97 58 208 131 87 251 174 130 251 177 132 241 168 123 236 164 116 222 148 99 199 125 76 164 91 48 174 105 66 227 160 131 182 122 96 156 104 83 89 38 21 78 24 12 85 27 16 109 42 34 125 58 49 166 104 89 162 107 86 190 146 117 229 193 167 87 53 44 73 38 36 121 77 74 99 59 57 89 61 58 112 84 81 138 96 97 120 84 88 141 127 140 119 125 151 116 136 187 102 134 193 93 136 191 94 141 195 89 134 189 89 134 191 93 133 194 94 132 194 94 132 194 94 132 194 93 131 193 93 131 193 93 131 193 93 131 193 95 133 195 95 133 195 96 134 196 97 135 197 97 135 197 96 134 196 96 134 196 96 134 196 95 133 196 95 133 196 95 133 196 96 134 197 96 134 197 96 134 197 95 133 196 95 133 196 96 134 197 95 133 196 95 133 198 95 133 198 95 133 198 95 133 198 96 134 199 96 134 199 159 147 121 225 213 197 78 67 73 64 52 72 100 92 116 155 147 170 96 88 103 63 54 59 214 200 197 233 219 206 230 218 196 230 217 198 199 189 180 48 38 47 33 23 58 23 17 65 20 18 68 23 23 75 24 20 71 33 24 67 26 16 40 80 69 75 118 108 99 139 129 119 190 179 183 86 75 89 20 12 36 12 6 34 20 14 42 17 13 38 15 11 36 33 13 15 169 112 69 164 106 56 55 23 10 67 48 44 97 70 51 147 112 84 162 111 80 136 81 51 107 57 30 90 47 28 45 8 0 52 19 14 38 8 0 69 32 16 165 112 96 174 112 99 180 120 110 141 82 74 102 43 35 90 32 21 88 30 16 84 25 7 138 73 53 205 135 110 194 119 88 190 112 76 201 119 79 205 124 79 228 150 104 230 153 107 227 153 106 206 132 83 203 126 74 184 104 53 188 107 62 187 109 71 176 102 73 158 92 70 89 32 15 118 65 51 72 15 6 95 36 28 94 27 18 93 23 11 114 45 29 136 72 47 122 65 35 111 60 31 113 67 51 103 59 48 95 47 35 74 28 15 70 32 19 111 71 59 161 107 97 186 135 131 194 164 166 162 153 172 113 126 171 112 138 197 103 138 194 95 136 190 96 137 193 102 142 201 96 135 194 96 134 196 96 134 196 95 133 195 95 133 195 95 133 195 95 133 195 95 133 195 97 135 197 97 135 197 98 136 198 98 136 198 98 136 198 97 135 197 97 135 197 96 134 196 96 134 197 96 134 197 96 134 197 97 135 198 96 134 197 96 134 197 96 134 197 95 133 196 94 132 195 95 133 196 95 133 198 96 134 199 96 134 199 97 135 200 98 136 201 98 136 201 149 137 123 195 184 182 42 30 52 42 32 67 22 14 53 35 28 61 32 25 43 32 25 32 132 121 119 228 215 206 244 231 215 241 229 213 224 215 206 118 111 118 37 30 63 27 21 67 24 21 74 30 27 82 26 19 73 27 19 60 26 14 36 57 45 47 119 107 93 123 111 95 118 107 105 42 30 40 22 13 34 18 9 36 15 9 35 18 12 38 21 17 44 32 11 16 172 114 74 182 121 74 58 20 7 74 45 39 144 108 86 167 122 91 151 94 64 118 59 29 88 34 10 84 37 21 88 47 43 79 41 38 54 20 8 133 91 75 155 98 81 163 104 90 127 74 66 84 37 31 74 27 21 69 22 14 72 25 15 71 22 8 98 41 24 123 58 38 173 101 76 173 94 64 174 91 59 210 126 90 213 129 93 195 113 75 200 121 82 196 117 74 195 113 63 170 87 35 209 120 78 202 112 78 174 86 62 117 36 17 131 59 45 94 30 18 50 0 0 82 20 9 88 20 7 96 23 8 104 26 4 132 52 25 136 60 28 144 74 40 166 107 75 142 87 57 124 67 38 124 67 40 131 77 49 170 113 86 193 125 102 156 91 73 169 119 112 187 159 171 127 128 172 119 138 196 101 127 184 100 131 188 107 142 200 100 136 196 98 137 196 98 137 196 98 137 196 98 137 196 98 137 196 98 137 196 97 136 195 97 136 195 99 138 197 99 138 197 100 139 198 100 139 198 99 138 197 99 138 197 98 137 196 97 136 195 98 136 198 98 136 198 98 136 198 98 136 198 97 135 197 97 135 197 97 135 198 96 134 197 95 133 196 96 134 197 97 135 198 98 136 199 98 136 199 98 136 199 98 136 199 98 136 199 126 115 119 118 107 121 29 19 56 34 24 74 32 24 73 26 19 60 15 10 32 18 12 22 48 39 40 208 197 193 240 227 219 214 203 197 236 228 226 205 199 209 46 42 69 12 10 50 17 17 67 27 27 81 27 22 76 26 17 60 34 22 42 71 59 61 129 117 103 115 103 87 46 35 31 17 6 14 26 17 36 27 18 45 11 5 31 16 12 37 24 20 47 32 11 18 156 101 62 190 127 83 65 23 9 84 47 41 189 143 120 178 123 92 164 99 69 156 91 63 115 57 35 121 70 53 93 46 38 98 54 45 80 39 21 126 78 56 117 54 36 148 82 66 91 33 22 81 28 20 93 43 32 62 12 1 54 2 0 84 31 15 133 72 54 154 86 65 124 48 22 146 62 34 157 70 40 207 118 84 193 107 72 229 147 110 254 174 137 250 173 131 227 147 98 213 127 78 223 130 89 219 122 90 175 79 55 191 100 81 170 89 72 150 78 63 137 70 54 129 62 45 127 54 37 136 58 36 151 65 40 159 69 42 173 84 52 188 106 69 205 136 95 187 124 83 197 133 95 177 113 77 162 97 59 162 92 56 178 102 68 127 51 25 110 44 28 174 131 138 137 132 172 117 133 192 104 124 183 104 130 189 111 141 203 94 128 189 102 138 198 100 139 198 100 139 198 100 139 198 100 139 198 100 139 198 100 139 198 100 139 198 101 140 199 101 140 199 101 140 199 101 140 199 101 140 199 100 139 198 99 138 197 98 137 196 98 136 198 98 136 198 99 137 199 99 137 199 99 137 199 99 137 199 98 136 199 98 136 199 98 136 199 99 137 200 100 138 201 100 138 201 99 137 200 98 136 199 97 135 198 96 134 197 82 72 97 66 56 90 42 32 82 20 12 69 21 16 72 31 28 73 18 15 42 17 13 27 32 26 30 207 197 198 154 143 149 50 39 47 108 100 113 180 176 193 115 113 137 20 20 54 20 22 70 26 27 81 28 25 78 22 15 57 23 11 35 72 59 66 126 113 104 135 122 113 110 98 100 14 4 15 17 9 32 19 13 39 20 16 41 15 13 37 18 15 42 32 13 17 154 102 63 185 122 78 68 22 7 114 69 64 182 125 106 137 71 45 138 66 41 158 88 63 155 93 70 153 96 76 147 91 74 167 115 94 148 94 66 128 69 39 133 61 37 131 53 33 127 48 31 121 44 28 128 52 36 129 56 37 153 82 62 153 82 60 156 82 57 188 109 79 202 115 85 217 127 93 220 128 91 223 133 96 164 79 40 237 158 117 255 192 151 255 193 150 246 169 123 187 105 58 246 154 117 240 143 111 228 128 102 206 110 86 189 103 80 205 127 104 191 116 93 184 110 85 178 98 73 175 89 62 185 94 65 204 111 80 210 117 83 197 112 73 201 124 80 202 134 89 218 151 108 186 117 76 177 102 62 174 95 54 199 117 79 205 125 92 118 41 21 158 106 110 129 123 161 112 128 187 117 137 196 107 131 193 104 135 199 102 138 200 101 140 199 101 140 199 101 140 199 101 140 199 101 140 199 101 140 199 101 140 199 101 140 199 102 141 200 102 141 200 102 141 200 102 141 200 101 140 199 100 139 198 99 138 197 98 137 196 100 136 198 100 136 198 101 137 199 102 138 200 102 138 200 102 138 200 102 138 200 102 138 200 101 137 199 102 138 200 103 138 202 103 138 202 102 137 201 101 136 200 100 135 199 99 134 198 41 33 72 25 18 60 23 16 68 30 25 81 30 27 82 29 28 72 11 11 39 13 10 27 44 38 48 209 199 210 86 74 94 32 22 49 39 29 63 32 28 61 52 52 78 21 26 56 20 24 69 17 20 71 24 24 76 29 23 67 29 19 44 68 56 66 98 87 83 126 115 111 157 146 154 88 77 94 18 9 36 17 12 42 19 16 43 18 18 42 15 15 39 27 12 15 159 110 69 177 116 71 61 12 0 129 78 75 157 91 75 136 61 40 165 87 67 170 93 73 163 97 73 152 90 65 193 132 104 201 138 107 163 101 64 162 94 57 136 55 28 136 48 26 129 37 16 138 46 23 167 79 55 208 124 98 231 150 123 220 141 111 205 122 92 216 130 97 215 122 88 244 150 114 255 172 134 238 146 107 161 78 38 230 152 113 252 183 141 255 194 152 255 186 143 228 149 108 236 148 112 251 158 125 223 128 98 207 116 85 238 153 122 228 148 115 241 162 131 253 173 140 247 160 130 231 140 109 209 114 82 235 141 107 236 146 111 218 135 95 217 140 98 212 141 99 210 142 103 184 115 76 180 98 60 214 129 90 222 139 99 203 120 86 144 62 40 161 105 106 131 127 164 106 128 185 117 139 197 105 134 194 96 134 196 105 147 207 101 141 200 102 141 200 102 141 200 102 141 200 102 141 200 102 141 200 102 141 200 102 141 200 103 142 201 103 142 201 103 142 201 102 141 200 102 141 200 101 140 199 100 139 198 99 138 197 101 137 199 101 137 199 102 138 200 102 138 200 103 139 201 103 139 201 103 139 201 103 139 201 100 136 198 101 137 199 102 137 201 103 138 202 103 138 202 103 138 202 103 138 202 103 138 202 21 14 55 25 20 61 25 22 67 27 28 74 20 23 68 17 21 59 10 11 39 14 13 31 47 43 57 153 144 165 24 12 52 35 22 75 38 27 87 18 13 67 20 20 58 9 15 47 22 29 71 19 25 73 21 23 74 24 21 66 24 15 44 29 18 34 26 16 17 39 29 30 93 82 96 113 103 127 25 18 51 26 20 54 10 10 36 17 19 42 14 19 39 25 14 12 162 117 75 181 123 75 58 9 0 104 48 47 134 64 52 127 48 31 182 99 83 169 88 69 156 86 60 159 93 61 193 123 87 218 147 105 186 114 66 191 112 69 164 75 45 157 61 37 160 62 37 181 86 58 205 116 86 242 157 128 242 159 129 244 161 131 230 145 114 214 125 93 203 110 76 253 156 123 255 181 146 217 124 90 186 102 66 246 170 134 255 190 155 246 180 145 255 187 151 236 162 125 196 116 81 249 167 130 254 170 133 222 140 102 201 122 81 233 154 111 248 166 126 243 155 117 236 142 106 227 130 95 208 114 78 224 136 100 230 151 112 216 142 103 222 148 113 215 144 112 211 148 117 198 131 102 185 104 74 224 138 105 249 169 132 214 134 101 147 65 44 172 116 119 132 134 172 103 134 189 103 134 191 104 139 197 94 141 197 96 145 203 100 142 200 102 141 200 103 142 201 103 142 201 103 142 201 103 142 201 103 142 201 104 143 202 103 142 201 103 142 201 103 142 201 103 142 201 103 142 201 102 141 200 101 140 199 100 139 198 102 138 198 102 138 198 103 139 201 103 139 201 103 139 201 103 139 201 102 138 200 102 138 200 101 137 199 101 137 199 102 137 201 102 137 201 103 138 202 103 138 202 104 139 203 104 139 203 24 22 61 18 16 55 22 21 65 16 17 61 25 28 71 24 26 65 13 14 42 12 13 34 33 30 51 59 53 81 30 18 66 36 25 85 28 19 84 27 21 81 20 21 65 17 21 59 15 19 64 25 29 77 24 26 74 19 18 60 22 19 48 16 13 30 15 9 19 19 13 23 24 16 37 32 26 54 25 21 56 25 24 58 12 13 43 9 13 38 12 17 37 27 16 14 146 102 57 179 121 71 63 16 0 87 36 33 153 83 73 124 41 25 201 114 95 210 125 104 184 108 82 147 74 41 190 112 74 210 129 86 201 121 72 197 114 70 203 114 82 188 94 66 174 77 45 205 111 77 198 109 77 219 134 103 207 126 96 190 111 80 179 98 68 200 117 85 255 178 144 255 168 133 240 150 115 187 98 64 220 137 105 253 177 145 255 190 159 255 190 158 246 180 146 255 189 155 199 125 90 228 152 116 239 161 123 255 189 149 246 171 129 213 136 92 212 133 90 195 112 70 208 119 79 195 106 66 199 111 73 202 120 80 229 156 113 223 151 111 207 131 99 207 133 104 199 136 105 196 129 100 202 118 92 185 95 69 222 142 109 221 144 114 150 75 56 174 125 129 124 130 166 108 141 194 102 133 188 107 143 201 97 144 200 94 143 201 102 142 201 103 142 201 103 142 201 103 142 201 104 143 202 104 143 202 104 143 202 104 143 202 104 143 202 104 143 202 104 143 202 104 143 202 104 143 202 103 142 201 102 141 200 101 140 199 104 140 200 104 140 200 104 140 202 103 139 201 103 139 201 102 138 200 101 137 199 101 137 199 103 139 201 103 139 201 102 137 201 102 137 201 102 137 201 103 138 202 103 138 202 103 138 202 18 19 50 20 20 56 20 18 65 24 22 72 29 27 74 23 22 62 14 13 44 14 11 38 23 20 49 23 17 53 25 19 65 30 23 74 27 23 74 21 19 68 18 19 65 23 21 68 26 19 71 32 25 77 22 23 67 18 24 58 12 19 45 6 14 33 12 15 32 9 10 30 14 11 38 16 15 47 14 17 52 18 22 59 7 12 44 13 17 46 14 16 41 29 13 13 153 102 55 182 122 70 52 11 0 62 19 13 170 104 92 134 53 32 223 132 105 213 122 91 176 95 66 155 76 46 203 114 82 208 118 83 216 128 90 201 118 78 209 129 94 186 103 69 166 76 39 199 109 72 196 112 76 193 114 83 195 121 92 198 127 99 230 159 131 255 189 157 255 188 153 251 173 135 228 149 110 183 103 66 241 165 131 251 176 147 255 195 170 255 190 163 255 193 160 255 195 160 230 161 128 204 131 99 250 174 142 255 182 150 255 182 148 255 197 160 255 183 145 243 171 131 225 152 111 210 137 96 215 140 98 232 157 115 236 161 119 227 150 108 218 136 99 210 132 94 200 133 90 197 128 87 179 89 65 143 48 28 196 110 83 216 142 117 168 109 95 150 117 124 126 134 170 113 141 191 106 135 191 104 136 195 104 142 204 104 146 206 105 144 203 106 142 200 105 141 199 105 141 199 106 142 200 107 143 201 106 142 200 106 142 200 106 142 200 105 141 199 106 142 200 108 144 202 107 143 201 105 141 199 103 139 197 104 140 198 106 142 202 106 142 202 105 141 203 104 140 202 103 139 201 102 138 200 101 137 199 101 137 199 102 138 200 102 138 200 103 138 202 103 138 202 103 138 202 103 138 202 103 138 202 103 138 202 18 22 51 19 22 57 21 19 68 24 22 72 29 26 73 22 20 59 14 11 40 12 9 36 21 17 50 20 15 55 21 18 63 26 23 70 24 23 67 19 18 62 16 17 63 21 17 67 29 18 74 33 24 77 22 24 65 16 25 56 9 21 45 4 17 36 12 17 39 12 12 38 11 7 40 20 18 55 11 13 51 10 14 51 19 24 56 13 17 46 17 17 41 35 15 14 162 110 63 190 130 76 38 2 0 76 39 30 163 104 88 159 81 58 230 141 107 213 123 88 159 76 46 156 75 46 197 108 78 202 109 76 218 128 93 216 132 96 208 134 97 178 104 65 186 103 61 209 124 83 228 148 111 244 169 137 252 183 154 255 193 167 255 200 172 255 190 161 251 183 148 255 196 157 206 132 93 218 144 105 247 174 141 248 177 147 255 188 163 255 198 172 255 196 165 250 187 154 255 195 163 213 142 112 230 153 125 252 175 147 255 186 156 255 182 151 253 183 149 254 186 149 241 176 136 231 164 122 234 165 123 237 164 121 227 150 108 217 138 97 222 140 102 212 135 93 176 110 60 215 144 100 202 110 87 151 54 35 175 88 61 212 142 117 182 134 124 157 135 147 129 142 177 114 142 192 107 133 190 104 134 194 104 140 202 101 139 201 107 143 203 106 142 200 105 141 199 105 141 199 106 142 200 107 143 201 106 142 200 106 142 200 108 144 202 106 142 200 106 142 200 107 143 201 107 143 201 105 141 199 105 141 199 106 142 200 106 142 202 106 142 202 105 141 203 104 140 202 103 139 201 103 139 201 102 138 200 102 138 200 103 139 201 103 139 201 103 138 202 103 138 202 103 138 202 104 139 203 104 139 203 104 139 203 17 22 52 18 22 57 19 20 68 21 22 70 27 26 68 20 20 54 12 12 36 10 10 34 20 19 50 20 18 57 22 19 64 27 24 71 25 24 68 21 20 62 17 18 62 21 19 68 28 19 74 31 24 76 20 23 64 14 23 54 10 20 45 8 16 37 16 16 40 16 11 41 20 13 47 19 13 51 13 11 50 10 13 48 21 24 55 7 9 34 19 17 38 37 18 14 153 101 53 185 128 73 87 49 26 183 147 135 233 177 160 184 114 88 219 135 99 218 133 96 154 75 44 178 102 70 207 123 89 192 103 69 202 114 78 214 130 93 207 133 94 190 119 77 161 83 37 185 104 61 243 165 127 255 199 166 255 193 164 255 197 169 255 205 177 255 198 169 255 198 163 249 180 141 180 111 70 238 169 130 250 182 147 255 189 157 254 188 162 255 198 171 255 196 165 253 188 156 255 189 158 239 165 136 187 107 80 236 155 128 255 174 145 255 176 146 255 187 155 255 184 149 235 166 127 223 151 111 228 155 114 226 151 109 217 138 97 212 133 92 213 133 96 191 116 76 189 125 77 215 146 104 242 152 128 182 87 67 189 102 74 192 124 101 177 136 134 147 134 152 120 138 178 108 139 193 106 137 194 109 141 202 110 145 209 105 143 206 107 143 203 106 142 200 106 142 200 106 142 200 106 142 200 107 143 201 107 143 201 106 142 200 109 145 203 107 143 201 106 142 200 107 143 201 107 143 201 106 142 200 106 142 200 108 144 202 106 142 202 106 142 202 105 141 201 105 141 201 104 140 202 104 140 202 104 140 202 104 140 202 103 139 201 103 139 201 104 140 202 104 140 202 104 139 203 104 139 203 104 139 203 104 139 203 15 20 52 17 21 58 18 19 67 21 22 68 26 26 64 20 21 49 13 14 34 12 13 33 19 18 49 20 18 57 23 20 67 26 24 73 26 25 69 23 22 64 20 22 63 23 21 68 26 19 71 28 24 75 18 21 62 12 21 52 8 18 43 7 13 35 18 14 41 17 8 39 26 14 50 17 6 46 21 17 54 15 15 49 16 17 45 15 16 37 18 15 32 27 8 1 125 75 24 215 159 102 180 140 115 209 173 159 233 185 165 216 152 124 239 161 123 198 116 78 185 111 76 220 147 114 223 145 109 185 103 66 182 97 60 201 117 80 199 126 83 204 133 87 206 125 80 190 107 65 226 146 109 255 185 153 255 192 165 255 194 169 255 183 158 247 173 146 236 161 129 178 104 69 178 102 66 231 157 120 243 170 137 255 188 157 255 188 162 249 183 157 255 194 164 255 197 165 255 197 167 251 176 147 180 99 72 162 78 52 213 127 102 231 147 119 232 151 122 227 148 117 226 150 116 236 160 124 246 171 132 245 167 128 227 148 109 207 128 89 197 119 83 190 118 80 196 132 88 219 150 109 248 162 135 226 134 111 188 103 72 190 124 102 166 135 140 138 135 162 116 139 183 107 142 198 107 139 198 107 141 202 104 142 205 99 139 201 108 144 204 107 143 201 106 142 200 106 142 200 107 143 201 107 143 201 107 143 201 107 143 201 108 144 202 106 142 200 106 142 200 107 143 201 108 144 202 106 142 200 107 143 201 108 144 202 106 142 202 106 142 202 106 142 202 105 141 201 105 141 203 105 141 203 106 142 204 106 142 204 104 140 202 104 140 202 104 140 202 104 140 202 105 140 204 105 140 204 105 140 204 105 140 204 15 19 56 17 20 61 17 19 67 19 22 65 23 26 59 17 22 44 11 14 29 11 14 29 15 16 44 17 17 55 21 19 66 24 22 71 25 24 68 21 23 64 21 23 64 24 23 67 25 21 71 26 24 73 16 21 61 11 20 51 10 17 43 8 12 37 18 11 42 17 6 40 22 7 46 20 8 48 25 19 57 16 15 47 15 15 39 26 25 43 16 10 22 50 31 17 171 124 70 211 157 97 189 148 120 209 172 156 230 188 164 209 154 123 226 154 114 214 137 95 213 144 105 238 170 133 224 155 114 185 110 70 183 98 61 197 112 73 189 116 71 203 129 82 229 142 99 201 109 70 204 114 80 227 138 108 249 163 138 252 166 143 219 133 110 198 110 86 169 82 54 165 76 46 226 140 107 243 158 127 251 168 138 255 184 157 255 193 170 255 184 161 255 190 161 255 186 157 253 179 152 255 185 159 244 160 136 192 104 80 178 88 64 183 93 67 165 78 51 166 81 52 195 112 80 227 147 112 236 156 119 238 159 120 227 145 107 197 117 80 195 121 86 195 125 89 191 128 87 214 146 107 244 160 132 210 123 96 183 99 65 200 138 117 153 133 145 126 136 172 112 142 192 109 145 203 107 141 202 108 142 203 106 144 207 102 142 203 108 144 204 107 143 201 106 142 200 106 142 200 107 143 201 108 144 202 107 143 201 107 143 201 107 143 201 106 142 200 106 142 200 109 145 203 109 145 203 107 143 201 106 142 200 107 143 201 107 141 202 107 141 202 107 141 202 107 141 202 107 141 202 107 141 202 108 142 205 108 142 205 106 140 203 106 140 203 106 140 203 106 140 203 107 141 204 107 141 204 107 141 205 107 141 205 17 21 59 19 22 63 18 20 68 19 22 65 21 24 55 15 20 39 9 13 24 10 14 26 15 16 44 17 16 56 21 19 68 24 22 72 23 24 70 23 25 66 22 24 65 24 23 65 24 20 70 26 24 71 17 21 59 14 20 52 11 18 44 12 14 39 19 14 44 17 7 41 20 8 46 23 13 50 20 14 50 20 17 46 18 15 36 12 8 22 32 21 29 142 119 103 214 165 107 217 163 101 185 141 112 219 180 163 231 194 167 209 163 129 213 148 108 227 154 113 212 144 105 230 165 125 225 160 118 197 126 84 191 106 69 195 107 69 186 112 65 199 125 78 232 145 102 226 132 94 199 106 73 164 73 44 161 69 44 173 81 58 173 81 60 174 79 57 142 48 22 215 121 93 254 163 134 243 154 124 247 162 133 254 173 146 255 187 164 254 180 155 254 185 156 255 186 157 249 175 148 251 171 146 240 154 131 232 141 120 183 91 68 229 137 114 242 150 125 235 145 119 245 158 130 246 161 130 227 143 109 220 138 101 219 137 100 201 123 85 202 129 94 189 121 86 202 140 101 220 155 117 229 150 119 188 103 74 219 135 101 194 135 117 142 133 152 115 136 181 106 141 195 104 144 203 104 140 200 108 142 203 109 147 209 108 146 208 109 145 205 108 144 202 107 143 201 107 143 201 108 144 202 108 144 202 108 144 202 107 143 201 107 143 201 106 142 200 107 143 201 109 145 203 109 145 203 107 143 201 106 142 200 106 142 200 107 141 202 107 141 202 107 141 202 107 141 202 107 141 202 108 142 203 108 142 205 108 142 205 107 141 204 107 141 204 107 141 204 107 141 204 107 141 204 107 141 204 108 142 206 108 142 206 18 20 61 20 21 65 19 20 68 19 20 64 20 24 53 14 20 36 7 14 22 8 14 26 14 18 45 17 19 58 21 21 71 23 23 75 23 24 72 23 24 68 22 24 65 23 22 66 22 19 66 24 22 69 15 19 57 14 20 52 12 19 45 12 16 41 19 16 45 14 9 41 20 13 47 20 14 48 15 12 43 21 19 43 17 13 30 23 13 22 97 81 84 209 181 160 225 175 116 222 167 103 181 132 100 223 182 162 224 189 161 187 144 109 201 139 98 231 162 120 215 147 108 220 157 114 222 161 116 200 131 89 192 107 70 193 103 66 193 116 70 202 128 79 206 125 80 230 145 104 227 142 105 213 127 94 216 129 101 230 140 114 222 132 108 194 102 77 164 73 46 236 147 117 223 136 106 212 129 97 228 149 118 232 157 128 244 173 145 240 170 144 231 162 133 224 153 125 232 156 130 209 129 104 213 127 104 213 122 101 164 69 49 192 97 75 245 151 126 254 160 135 253 162 135 241 152 122 223 139 105 214 132 95 214 132 95 213 135 99 202 129 94 189 123 88 201 137 101 220 155 117 205 129 95 219 139 106 230 150 115 189 136 120 141 141 167 113 143 193 106 145 202 104 144 205 102 138 196 104 139 197 105 141 199 102 138 198 109 145 203 108 144 202 107 143 201 107 143 201 108 144 202 108 144 202 108 144 202 108 144 202 109 145 203 107 143 201 108 144 202 109 145 203 109 145 203 107 143 201 106 142 200 107 143 201 108 142 203 107 141 202 107 141 202 107 141 202 107 141 202 108 142 203 108 142 203 108 142 203 107 141 204 107 141 204 107 141 204 108 142 205 108 142 205 108 142 205 108 142 205 108 142 205 18 17 57 20 19 61 20 18 65 19 21 62 22 23 53 14 20 36 8 15 23 10 16 28 12 16 43 16 18 57 19 19 71 20 20 74 20 21 69 20 21 67 19 20 64 20 19 63 20 14 62 22 19 64 14 16 54 13 20 49 12 19 45 11 17 41 16 18 43 11 11 39 13 10 41 16 15 46 17 17 43 15 13 34 19 13 25 69 57 61 175 154 153 203 167 145 216 164 104 225 167 103 185 132 100 226 181 160 227 192 162 167 129 92 193 135 95 215 150 108 235 170 130 219 156 113 211 153 107 190 123 80 191 105 70 199 109 74 204 126 80 201 128 77 195 118 72 214 135 92 221 139 101 232 148 114 244 157 129 248 161 134 223 133 107 161 71 45 144 54 27 168 81 53 143 60 30 148 69 38 176 101 70 180 109 79 196 127 98 201 131 105 202 133 104 197 126 98 168 92 66 159 79 54 117 33 9 145 57 35 120 25 5 156 60 38 215 119 95 239 145 120 237 146 119 226 137 107 230 143 113 222 139 105 213 133 96 221 145 109 205 135 99 190 124 89 197 133 97 169 101 64 219 145 108 237 161 125 202 127 95 197 151 138 129 135 167 103 138 194 102 142 203 105 145 206 109 144 200 113 146 200 112 147 203 108 143 199 109 145 203 108 144 202 107 143 201 107 143 201 108 144 202 109 145 203 108 144 202 108 144 202 111 147 205 109 145 203 108 144 202 109 145 203 108 144 202 107 143 201 107 143 201 109 145 203 108 142 203 107 141 202 107 141 202 107 141 202 107 141 202 108 142 203 108 142 203 108 142 203 108 142 205 108 142 205 108 142 205 108 142 205 108 142 205 108 142 205 109 143 206 109 143 206 13 11 48 27 25 64 21 18 63 16 15 55 37 36 67 14 17 36 8 12 23 14 18 30 22 23 51 7 6 46 21 21 73 27 27 81 21 21 71 19 20 66 13 14 58 22 21 65 25 17 64 31 24 68 19 22 57 9 16 44 9 17 40 13 21 42 14 20 42 4 9 31 10 14 39 9 13 38 15 20 40 18 20 35 77 70 78 161 145 146 195 165 163 210 168 144 220 164 103 221 162 96 190 136 102 228 182 159 215 180 150 168 130 94 191 138 98 220 157 116 200 135 95 197 134 91 144 86 40 177 112 70 198 114 80 199 110 76 207 126 81 214 141 90 201 127 80 207 130 86 220 141 102 223 141 104 231 146 115 215 128 100 167 77 50 144 54 27 220 133 105 188 103 74 122 41 11 119 40 10 122 47 16 130 59 29 142 73 44 142 73 44 137 66 38 133 59 32 151 75 49 133 53 28 150 66 42 212 126 103 166 74 51 114 19 0 171 77 52 208 114 89 217 126 99 209 120 90 222 137 106 212 129 95 215 137 99 222 148 109 208 139 100 207 139 102 191 125 90 179 111 74 183 111 71 189 117 79 215 148 119 181 142 135 127 140 175 104 143 202 103 143 204 105 144 203 108 143 197 110 141 195 110 143 197 112 145 199 108 143 199 109 144 202 110 145 203 109 144 202 109 144 202 108 143 201 109 144 202 110 145 203 112 147 205 111 146 204 109 144 202 108 143 201 107 142 200 106 141 199 106 141 199 105 140 198 107 141 202 106 140 201 106 140 201 106 140 201 108 142 203 108 142 203 108 142 203 107 141 202 108 142 203 108 142 203 108 142 205 108 142 205 109 143 206 110 144 207 111 145 208 111 145 208 29 24 54 22 17 49 19 12 53 36 31 71 21 18 47 19 20 40 15 17 29 0 3 18 17 18 46 22 21 61 16 14 63 16 16 68 21 22 70 16 17 63 15 16 62 16 15 59 22 14 61 23 16 58 14 14 48 10 16 42 10 18 37 12 19 37 15 20 39 15 20 39 7 12 32 15 20 40 16 22 38 94 97 106 169 160 163 178 158 157 200 167 160 212 166 140 221 163 100 223 162 97 193 137 100 228 180 157 215 178 149 181 143 107 193 141 104 218 156 117 212 149 108 202 139 96 212 153 109 226 161 121 211 130 100 195 109 76 202 124 78 213 137 87 218 144 97 202 125 81 225 146 105 221 137 100 215 129 96 199 110 80 143 52 23 191 100 73 237 147 120 229 144 115 221 137 109 219 140 110 212 135 107 176 101 72 132 56 30 95 21 0 118 42 16 170 93 67 200 123 97 209 129 104 207 125 101 220 134 111 194 106 82 125 33 10 119 27 2 176 84 59 201 110 83 208 119 89 210 125 94 207 127 92 219 141 103 218 144 105 204 135 96 216 148 111 242 173 140 223 155 120 229 162 120 209 145 107 219 163 138 170 140 142 124 139 178 103 142 201 103 141 203 107 143 203 110 143 197 110 142 193 111 142 196 112 143 198 110 142 199 109 144 202 110 145 203 109 144 202 109 144 202 108 143 201 109 144 202 110 145 203 111 146 204 110 145 203 109 144 202 107 142 200 106 141 199 106 141 199 106 141 199 106 141 199 106 140 201 105 139 200 105 139 200 105 139 200 106 140 201 107 141 202 107 141 202 106 140 201 107 141 202 107 141 202 108 142 205 108 142 205 109 143 206 109 143 206 110 144 207 110 144 207 26 17 34 29 21 44 40 30 65 60 52 89 29 22 53 8 4 27 19 18 32 18 20 35 10 10 36 20 20 56 26 25 69 29 27 74 27 26 70 19 18 62 16 17 63 17 16 60 22 14 61 20 13 55 14 13 45 11 15 40 15 20 39 16 19 34 13 15 28 17 16 32 9 11 26 28 30 45 138 142 153 176 177 182 162 152 151 192 171 166 205 168 160 211 164 136 221 161 99 221 160 93 195 140 101 228 178 153 215 176 147 193 154 121 187 134 100 206 146 110 230 166 128 222 159 118 235 173 132 241 175 140 235 158 130 199 118 88 199 122 78 217 141 92 224 147 101 209 130 87 214 131 91 221 133 97 197 104 71 157 62 32 172 74 47 227 131 106 233 139 113 225 135 109 232 144 120 221 135 110 230 146 120 223 139 113 207 123 97 187 106 79 194 113 86 216 135 108 207 126 99 215 134 107 209 128 101 201 117 91 220 134 109 185 97 73 116 24 0 134 42 17 169 78 51 178 91 61 193 110 78 205 127 91 216 141 102 218 146 106 208 141 99 212 144 107 233 162 132 238 169 138 209 146 105 223 169 133 203 161 145 151 134 144 121 138 181 106 141 199 105 141 203 108 144 204 111 144 198 111 143 194 112 142 196 113 144 199 110 142 199 109 144 202 109 144 202 109 144 202 108 143 201 108 143 201 109 144 202 109 144 202 109 144 202 108 143 201 107 142 200 106 141 199 106 141 199 106 141 199 106 141 199 106 141 199 106 141 199 105 140 198 105 139 200 105 139 200 106 140 201 107 141 202 106 140 201 106 140 201 106 140 201 106 140 201 107 141 202 107 141 202 108 142 205 108 142 205 109 143 206 110 144 207 74 63 67 45 33 45 133 120 146 83 72 104 30 21 50 24 19 42 11 8 25 11 10 26 31 29 53 11 10 41 20 18 55 22 21 61 19 18 58 22 21 61 15 16 60 13 12 56 20 14 58 22 17 57 18 17 48 13 13 37 20 19 35 21 17 31 16 8 21 22 11 25 38 30 43 154 148 160 175 174 182 172 170 173 184 173 171 181 161 154 204 167 158 207 160 130 221 161 98 217 156 89 196 141 100 227 180 152 215 174 146 197 156 126 166 115 84 178 122 87 231 169 132 244 180 142 235 171 133 248 184 149 228 158 133 195 121 94 206 131 89 217 143 94 222 148 103 212 135 91 206 124 84 203 118 79 163 73 38 133 40 7 216 121 91 228 134 106 231 139 114 231 144 117 236 150 125 227 143 117 231 147 121 236 152 126 238 152 127 228 140 116 240 152 128 223 137 112 216 132 106 217 133 107 223 142 115 215 134 107 225 141 115 214 128 101 151 61 35 112 21 0 152 62 35 170 83 53 203 120 86 210 130 95 202 127 88 207 135 95 201 134 92 216 151 113 244 172 147 226 156 130 218 160 120 205 162 128 165 140 135 137 132 152 120 139 182 108 140 197 107 141 204 110 144 207 112 145 199 112 143 197 112 143 197 113 144 199 110 142 199 109 144 202 109 144 202 109 144 202 108 143 201 108 143 201 108 143 201 109 144 202 108 143 201 107 142 200 107 142 200 106 141 199 106 141 199 106 141 199 106 141 199 106 141 199 107 142 200 106 141 199 106 140 201 106 140 201 107 141 202 107 141 202 107 141 202 106 140 201 106 140 201 106 140 201 106 140 201 106 140 201 107 141 204 108 142 205 108 142 205 109 143 206 177 163 152 165 151 150 145 131 148 37 23 49 25 12 40 20 10 35 19 12 30 13 9 24 15 13 34 22 22 46 20 19 50 21 20 52 19 20 51 12 12 48 16 15 55 19 18 60 16 15 57 16 16 54 18 19 49 16 14 35 22 14 29 23 10 20 36 14 26 70 46 59 146 124 137 168 150 162 182 171 179 180 171 172 183 170 164 192 172 163 201 169 156 212 167 136 223 165 101 214 155 87 195 144 101 228 185 153 218 177 149 195 151 124 145 96 66 149 94 63 212 152 116 236 172 136 233 169 134 237 174 143 169 104 82 184 118 92 210 141 100 202 131 85 226 158 111 204 133 89 212 138 93 174 95 54 131 48 8 161 76 39 212 126 93 225 140 109 230 146 118 240 160 133 232 155 129 239 162 136 235 155 130 246 165 138 255 180 154 255 170 143 255 170 145 249 157 132 247 157 131 224 138 111 228 144 116 230 149 120 228 144 116 220 134 107 212 122 96 151 61 34 140 49 22 168 79 49 193 109 75 206 123 89 212 134 96 221 149 109 202 137 97 196 132 96 244 173 151 233 167 143 197 145 106 181 147 120 154 144 152 129 135 167 117 138 183 109 138 194 106 140 203 108 144 206 110 145 201 110 143 197 110 142 199 111 143 200 108 143 201 109 144 202 109 144 202 109 144 202 108 143 201 108 143 201 108 143 201 109 144 202 107 142 200 107 142 200 106 141 199 106 141 199 106 141 199 106 141 199 107 142 200 107 142 200 109 141 200 108 140 199 108 140 199 108 140 199 109 141 202 109 141 202 108 140 201 108 140 201 107 139 200 107 139 200 107 139 200 108 140 201 108 140 201 109 141 202 110 141 205 110 141 205 217 201 176 177 161 148 114 97 107 38 20 44 25 9 36 32 20 44 15 6 23 17 13 28 43 40 57 75 73 94 34 32 54 23 23 49 30 30 56 7 8 38 17 17 55 18 20 61 14 17 58 10 14 49 19 20 48 22 17 37 29 12 28 33 7 18 67 31 43 139 98 112 182 146 160 181 151 163 187 168 174 194 180 180 180 165 158 182 164 152 207 179 165 214 173 141 222 167 102 214 157 88 193 146 100 227 186 154 223 182 154 192 148 123 134 89 60 126 75 44 153 97 62 203 140 105 218 153 121 168 107 79 76 18 0 137 79 55 191 126 86 221 153 106 222 154 109 215 144 100 211 137 92 167 88 45 139 56 16 199 114 77 202 116 81 233 148 117 228 147 118 238 158 131 227 150 124 245 168 142 236 154 130 245 161 135 255 179 155 255 171 146 255 169 144 255 164 139 252 158 133 246 156 130 245 159 132 234 150 122 229 145 117 221 135 108 218 131 103 198 108 81 145 54 25 201 110 81 214 128 95 223 141 104 225 145 108 206 134 94 201 136 96 148 83 51 170 99 81 200 135 115 173 127 91 181 157 133 150 153 170 117 136 178 116 137 184 111 136 192 107 138 202 106 141 205 107 143 201 106 141 197 106 141 199 108 142 203 108 143 201 108 143 201 109 144 202 109 144 202 108 143 201 108 143 201 108 143 201 109 144 202 108 143 201 108 143 201 107 142 200 107 142 200 107 142 200 107 142 200 108 143 201 108 143 201 108 140 199 107 139 198 107 139 198 107 139 198 108 140 201 108 140 201 107 139 200 106 138 199 107 139 200 107 139 200 107 139 200 107 139 200 108 140 201 109 141 202 109 140 204 110 141 205 201 185 151 187 169 147 64 44 46 35 16 35 37 19 45 20 6 31 18 7 24 64 58 72 127 123 138 88 87 101 27 26 42 10 11 29 23 24 45 18 18 44 14 13 47 7 9 48 10 18 55 9 18 51 20 21 49 22 14 35 36 14 27 50 14 26 82 34 48 154 100 114 171 120 135 201 159 171 192 165 172 191 171 172 183 166 159 184 166 154 209 186 170 200 164 130 215 164 98 214 160 90 191 149 101 221 182 149 225 184 156 193 149 124 140 96 71 117 70 40 141 87 53 162 102 66 164 101 70 105 45 19 63 11 0 124 72 48 181 119 80 210 142 97 215 142 99 232 155 113 223 142 99 189 104 63 176 86 49 211 118 84 213 120 87 224 133 104 213 126 99 199 113 88 189 105 81 197 110 90 194 103 82 206 111 89 238 139 118 248 146 124 232 127 105 217 115 92 201 103 78 208 117 90 208 121 93 201 118 88 207 124 94 223 138 109 210 123 95 220 130 103 174 83 54 215 124 95 233 144 112 232 148 112 230 148 111 209 135 96 184 120 82 124 61 30 128 59 43 154 91 74 214 171 137 177 160 142 128 144 169 109 137 185 117 139 188 114 137 191 107 138 202 104 142 207 104 143 202 105 141 199 105 141 203 107 143 205 107 141 202 108 143 201 109 144 202 108 143 201 108 143 201 107 142 200 108 143 201 109 144 202 109 144 202 109 144 202 108 143 201 108 143 201 108 143 201 108 143 201 109 144 202 109 144 202 108 140 199 107 139 198 107 139 198 107 139 198 107 139 198 107 139 198 107 139 200 106 138 199 107 139 200 107 139 200 107 139 200 107 139 200 108 140 201 109 141 202 109 141 202 110 142 203 214 193 164 190 167 149 82 60 63 39 16 34 26 7 29 29 14 35 19 8 22 78 72 82 114 111 122 25 23 37 27 26 42 27 25 46 12 13 34 20 22 47 8 9 40 18 21 56 7 13 49 13 19 51 21 22 50 14 5 26 35 11 25 61 19 31 84 20 34 130 59 73 169 106 117 198 149 155 197 166 171 192 172 171 189 170 163 184 165 151 197 174 156 211 175 141 214 158 99 218 158 95 194 148 98 216 177 138 227 184 152 197 151 125 151 104 78 119 69 42 125 72 40 145 92 61 184 132 108 142 95 75 76 34 18 79 34 13 182 124 86 212 144 99 218 143 103 229 150 109 251 168 128 208 120 82 201 109 72 206 113 79 217 122 90 201 107 79 160 68 43 134 44 20 143 52 31 145 52 34 147 52 34 149 50 31 168 65 48 178 73 54 157 50 30 154 49 28 152 53 30 146 52 26 133 44 14 140 53 23 137 52 21 163 78 47 182 95 65 206 119 89 224 134 100 234 144 109 255 168 130 228 146 108 208 133 94 207 139 102 195 135 101 114 54 26 138 72 56 185 129 112 182 146 120 149 139 127 132 151 181 108 140 189 116 142 193 114 139 196 109 140 205 107 142 208 107 143 203 106 142 200 105 144 203 107 146 205 106 142 200 108 143 201 109 144 202 108 143 201 108 143 201 107 142 200 108 143 201 109 144 202 110 145 203 110 145 203 109 144 202 108 143 201 108 143 201 109 144 202 109 144 202 109 144 202 109 141 200 108 140 199 108 140 199 108 140 199 108 140 199 108 140 199 108 140 201 107 139 200 107 139 200 107 139 200 107 139 200 107 139 200 108 140 201 109 141 202 109 141 202 110 142 203 245 215 207 221 191 189 153 126 135 42 19 35 32 13 32 24 12 26 13 6 14 76 71 78 54 51 60 33 31 45 23 21 43 19 19 47 24 25 55 8 11 42 9 14 43 15 20 50 16 15 49 22 18 51 19 19 47 17 9 32 30 7 23 67 21 32 105 25 38 108 18 27 173 97 101 190 134 133 197 169 166 191 174 167 197 174 168 190 163 152 203 176 155 212 171 139 223 155 110 225 152 101 200 144 93 223 176 130 221 173 135 175 124 93 155 98 71 126 68 44 108 54 28 93 51 29 77 47 36 77 54 46 63 38 33 68 31 15 160 104 69 200 131 89 216 142 103 228 153 114 243 163 126 243 161 123 195 110 73 192 103 69 167 76 45 149 55 27 136 42 16 160 66 41 170 75 55 175 80 62 188 91 75 182 85 69 165 64 52 160 58 44 173 70 55 204 103 85 232 135 116 224 130 105 214 121 90 225 132 98 220 130 95 206 121 84 192 110 73 209 127 89 217 130 87 252 164 118 242 158 111 231 157 110 206 144 105 199 144 113 175 117 93 124 66 46 138 83 63 172 127 108 187 160 143 171 166 163 124 141 167 114 147 192 109 141 198 107 141 205 110 140 210 111 142 209 112 142 204 109 144 200 106 145 202 104 145 201 108 145 200 109 144 200 109 144 200 109 144 200 109 144 200 109 144 200 109 144 200 109 144 200 113 148 204 111 146 202 109 144 200 108 143 199 109 144 200 109 144 200 108 143 199 107 142 198 108 143 201 108 143 201 108 143 201 108 143 201 107 141 202 106 140 201 106 140 201 105 139 200 104 138 199 105 139 200 106 140 201 107 141 202 107 141 204 107 141 204 109 143 206 110 144 207 170 141 146 186 159 168 188 164 178 77 56 73 22 5 21 30 19 33 7 0 7 102 97 103 62 59 68 17 15 29 26 22 47 20 17 48 17 16 50 15 18 49 11 16 45 16 20 47 20 15 47 21 16 48 18 18 46 18 13 35 33 10 26 69 19 30 107 20 29 115 14 20 157 68 70 200 135 131 198 167 162 191 172 165 196 171 166 193 165 154 205 174 154 214 169 138 227 154 111 226 148 99 201 145 94 225 179 130 207 164 122 156 106 71 160 95 63 162 93 60 110 47 12 68 19 0 37 8 0 48 28 17 61 36 29 72 36 22 149 92 62 198 129 88 209 136 95 210 135 93 235 158 116 242 163 122 219 137 97 200 115 76 207 119 83 204 114 79 214 121 88 216 122 94 220 126 100 234 139 117 246 151 131 240 144 128 237 141 127 247 151 135 250 150 134 235 138 119 239 147 126 245 153 128 242 147 115 231 137 99 217 128 88 215 130 91 221 142 103 198 119 78 238 152 105 247 159 109 239 156 104 215 141 94 211 155 118 191 142 112 158 107 80 121 69 47 142 96 73 169 133 117 188 169 165 162 162 174 126 145 177 110 142 189 106 144 206 105 144 211 109 142 209 112 142 206 112 142 202 111 143 200 106 145 200 106 145 200 109 146 201 110 145 201 109 144 200 109 144 200 109 144 200 109 144 200 109 144 200 109 144 200 110 145 201 109 144 200 109 144 200 108 143 199 107 142 198 107 142 198 108 143 199 109 144 200 108 143 201 108 143 201 108 143 201 108 143 201 107 141 202 106 140 201 106 140 201 106 140 201 105 139 200 106 140 201 107 141 202 108 142 203 108 142 205 108 142 205 109 143 206 110 144 207 92 72 83 24 6 18 101 84 102 124 109 128 33 20 38 16 8 23 28 21 29 153 146 154 99 93 103 15 8 24 26 17 44 21 14 47 15 9 43 21 20 51 11 12 40 17 19 44 20 17 48 18 15 46 13 17 42 17 14 33 34 12 25 69 18 27 107 17 26 116 11 16 131 35 37 200 125 122 206 165 161 195 172 164 193 170 162 194 167 156 206 171 152 215 164 133 226 153 100 223 151 92 196 149 97 213 179 133 193 158 120 145 100 61 169 100 58 192 110 62 180 98 42 120 49 0 72 20 0 64 25 0 70 33 14 71 28 9 123 63 35 185 115 79 199 127 79 214 138 86 239 163 111 229 152 100 220 140 89 199 116 66 228 142 95 216 127 83 212 123 81 220 130 93 220 130 95 219 128 97 231 141 114 247 157 131 243 155 131 231 141 117 237 142 120 229 134 112 228 138 114 218 131 103 207 117 82 207 118 76 217 130 87 232 149 107 226 147 108 198 119 78 233 146 101 251 163 115 223 137 88 216 139 95 199 140 108 181 132 102 131 85 49 122 79 45 149 113 89 165 138 129 171 159 169 136 140 169 122 143 188 113 144 201 108 146 209 106 146 208 108 144 206 108 143 201 110 143 197 111 144 198 109 146 201 109 145 203 111 146 202 110 145 201 110 145 201 109 144 200 109 144 200 109 144 200 109 144 200 109 144 200 107 142 198 108 143 199 109 144 200 108 143 199 106 141 197 105 140 196 107 142 198 109 144 200 108 143 201 108 143 201 108 143 201 108 143 201 107 141 202 107 141 202 106 140 201 106 140 201 107 141 202 107 141 202 108 142 203 108 142 203 108 142 205 108 142 205 109 143 206 110 144 207 32 24 39 27 18 35 22 13 34 32 23 44 22 14 35 22 15 31 19 11 22 118 111 119 136 128 139 34 25 42 26 16 43 24 15 46 21 14 47 21 16 48 8 8 34 21 21 45 17 17 45 17 17 43 14 16 37 17 10 26 36 8 20 74 17 24 110 18 23 117 8 11 118 14 15 181 95 94 216 163 159 204 171 164 196 169 160 196 168 156 208 169 152 212 162 129 222 153 94 220 155 89 193 148 93 208 174 128 194 159 119 158 110 70 180 108 58 192 106 47 219 126 57 211 123 52 179 105 44 111 49 0 70 14 0 68 12 0 104 39 17 172 101 73 201 127 82 205 130 75 221 144 90 238 158 105 227 146 93 193 112 59 221 138 88 227 141 92 213 126 81 205 118 75 202 114 76 199 114 77 192 106 73 184 99 70 177 93 65 171 85 58 165 75 49 170 80 53 180 95 66 185 101 67 203 115 75 228 141 98 231 147 103 222 141 98 215 137 98 200 121 82 227 140 95 224 136 90 226 137 93 202 123 84 191 130 102 165 115 88 120 81 42 128 95 60 142 117 97 151 135 136 146 142 165 119 128 169 120 143 197 114 146 207 111 147 209 107 147 206 108 147 204 109 146 199 110 145 199 110 145 199 110 145 203 110 145 203 112 147 203 111 146 202 111 146 202 110 145 201 110 145 201 109 144 200 109 144 200 109 144 200 108 143 199 108 143 199 108 143 199 108 143 199 106 141 197 106 141 197 107 142 198 108 143 199 108 143 201 108 143 201 108 143 201 108 143 201 108 142 203 107 141 202 107 141 202 106 140 201 107 141 202 107 141 202 108 142 203 108 142 203 107 141 204 107 141 204 108 142 205 109 143 206 17 18 38 24 25 46 17 15 39 23 21 45 18 15 36 16 12 29 13 7 17 28 21 29 115 105 116 48 39 56 29 19 46 24 15 46 29 22 55 19 14 44 13 11 35 23 24 45 14 19 41 17 19 40 18 17 35 23 7 20 46 4 14 85 19 23 115 21 22 117 9 9 121 11 12 151 55 56 216 145 143 214 165 160 200 167 158 197 168 154 210 168 152 208 159 126 215 156 96 212 155 84 192 143 84 215 169 119 206 159 115 169 115 69 180 110 59 186 102 42 213 119 49 209 109 33 224 127 48 220 129 58 180 98 42 111 36 0 80 7 0 150 77 62 188 113 74 204 126 77 204 124 75 228 148 99 210 128 80 204 122 74 218 134 87 220 136 90 230 146 102 224 139 98 216 132 95 200 118 81 178 95 63 162 81 51 160 81 51 163 82 53 170 83 55 160 73 43 165 82 50 176 96 59 197 114 70 214 132 85 210 129 82 201 122 79 216 141 101 214 136 97 216 131 90 217 128 86 214 125 85 196 116 81 191 126 104 142 94 72 131 96 64 136 115 86 124 111 102 135 133 146 130 138 174 124 142 192 120 146 205 110 142 203 111 147 205 108 149 203 108 149 201 108 149 201 111 148 201 111 146 202 114 144 206 113 143 205 114 146 205 112 147 203 111 146 202 111 146 202 110 145 201 110 145 201 110 145 201 110 145 201 112 147 203 110 145 201 108 143 199 108 143 199 108 143 199 108 143 199 108 143 199 107 142 198 108 143 201 108 143 201 108 143 201 108 143 201 108 142 203 107 141 202 107 141 202 106 140 201 106 140 201 106 140 201 107 141 202 107 141 202 106 140 203 106 140 203 106 140 203 107 141 204 15 23 46 10 16 42 17 21 50 15 15 43 10 8 30 19 15 32 22 16 28 23 15 26 45 37 50 38 29 48 28 19 46 18 11 44 25 20 52 16 13 42 17 18 39 17 20 39 12 19 38 17 18 36 27 14 31 39 7 20 66 6 16 100 19 25 118 23 21 115 10 7 127 15 14 131 25 25 196 106 108 218 150 147 204 160 151 200 164 150 209 168 150 203 157 123 214 161 95 210 154 80 193 139 79 221 168 118 211 157 113 168 107 62 178 105 54 190 106 46 218 120 49 214 108 30 219 110 25 217 112 29 206 109 41 169 78 34 118 32 19 145 65 54 180 101 68 209 130 87 198 119 76 204 123 78 189 108 63 221 138 94 225 141 97 208 124 80 202 117 76 211 126 87 209 125 88 203 120 86 211 131 98 229 148 118 233 154 124 226 147 117 225 140 109 215 131 97 213 133 98 203 125 86 195 114 69 197 117 68 204 126 78 215 141 96 217 145 105 217 143 104 210 127 87 230 142 102 199 111 75 198 119 89 189 123 107 118 70 56 131 103 82 141 127 114 121 120 126 129 139 164 119 138 181 121 148 201 114 145 202 109 144 200 111 148 200 108 150 200 108 152 201 109 152 203 111 150 207 113 147 208 116 144 209 117 142 206 115 147 206 112 147 203 112 147 203 111 146 202 111 146 202 111 146 202 111 146 202 111 146 202 114 149 205 111 146 202 109 144 200 108 143 199 110 145 201 110 145 201 109 144 200 107 142 198 109 144 202 109 144 202 109 144 202 108 143 201 108 142 203 107 141 202 106 140 201 106 140 201 105 139 200 106 140 201 106 140 201 106 140 201 105 139 202 105 139 202 106 140 203 107 141 204 17 27 54 4 11 39 14 19 49 26 27 55 22 20 42 12 8 25 4 0 10 17 11 21 10 4 16 20 16 33 23 19 46 13 9 42 17 16 48 12 13 43 14 19 41 10 15 34 12 18 34 18 12 26 41 10 26 69 12 27 98 12 25 117 18 23 119 19 17 116 13 8 127 15 13 129 16 18 163 54 59 219 129 131 208 149 143 203 159 146 207 166 148 201 157 120 216 159 88 217 155 78 201 140 85 225 164 120 212 150 111 171 104 62 186 106 55 197 107 47 207 106 38 209 103 27 213 107 23 212 107 26 201 98 31 172 71 25 130 29 11 153 59 47 199 115 87 189 111 73 188 110 72 204 125 86 213 131 91 218 136 96 224 141 99 231 148 108 231 146 107 223 138 101 218 134 98 233 150 116 254 174 141 255 174 144 247 168 137 251 170 140 254 170 136 248 164 128 249 171 133 246 168 129 242 164 118 243 165 116 239 163 114 236 163 118 211 142 103 199 127 89 212 133 94 201 117 80 207 123 89 185 109 83 192 130 117 119 75 72 124 102 104 138 132 142 129 136 162 125 145 182 110 141 188 111 147 199 108 144 194 113 151 198 110 151 195 109 152 197 106 152 202 106 151 206 109 149 210 113 147 211 119 144 210 120 144 208 115 145 205 112 147 203 112 147 203 112 147 203 111 146 202 112 147 203 112 147 203 112 147 203 113 148 204 112 147 203 110 145 201 110 145 201 110 145 201 110 145 201 110 145 201 110 145 201 110 145 203 110 145 203 109 144 202 109 144 202 108 142 203 107 141 202 106 140 201 105 139 200 105 139 200 106 140 201 107 141 202 107 141 202 106 140 203 106 140 203 107 141 204 108 142 205 8 17 46 18 25 54 14 17 48 19 19 47 9 5 28 13 9 26 18 15 24 16 13 22 20 18 31 15 14 32 20 20 48 11 14 47 14 17 50 10 15 44 13 20 39 11 17 31 18 16 30 24 4 16 55 4 19 95 17 31 124 18 32 130 15 22 120 16 13 118 15 8 125 11 10 136 17 19 139 15 23 219 113 117 213 140 134 206 157 142 206 165 145 201 156 115 214 155 77 227 161 77 212 146 88 226 159 117 214 144 108 182 109 68 194 111 59 194 102 39 203 102 32 215 109 33 215 111 26 211 109 27 211 108 39 197 95 46 145 43 21 139 43 29 205 124 95 179 105 68 191 115 79 196 118 80 219 140 101 207 125 85 213 132 89 221 138 96 210 125 84 226 141 102 225 142 102 228 144 107 248 166 129 255 177 140 255 176 141 255 180 145 255 174 140 243 159 125 243 165 129 249 174 134 252 174 128 245 169 120 233 159 112 232 161 117 203 135 98 196 128 93 192 116 80 174 94 59 196 117 86 189 117 93 184 130 118 150 114 116 127 110 126 134 133 164 130 143 185 116 142 191 112 147 201 111 150 205 110 148 197 114 152 197 111 153 195 109 152 195 106 152 202 105 152 208 108 149 211 113 148 212 121 146 212 122 146 210 115 145 205 112 147 203 112 147 203 112 147 203 112 147 203 112 147 203 112 147 203 113 148 204 110 145 201 111 146 202 112 147 203 111 146 202 109 144 200 109 144 200 110 145 201 112 147 203 111 146 204 110 145 203 110 145 203 109 144 202 108 142 203 106 140 201 105 139 200 105 139 200 106 140 201 107 141 202 107 141 202 108 142 203 107 141 204 107 141 204 108 142 205 109 143 206 12 17 46 15 19 48 18 19 49 19 16 43 17 12 34 14 10 25 13 10 19 13 12 20 18 20 32 13 18 37 11 16 45 11 17 49 11 17 49 8 15 43 9 16 35 18 17 31 24 8 21 53 12 26 91 19 33 118 20 35 135 13 26 135 8 15 123 11 9 121 12 7 127 11 11 138 13 17 148 17 25 174 57 63 216 136 129 203 145 131 199 154 133 187 140 98 209 147 64 247 178 87 206 132 71 212 138 93 208 133 94 182 103 60 206 121 66 196 104 39 205 104 32 212 110 28 210 109 21 216 116 31 203 106 35 205 111 59 128 36 13 102 14 0 191 116 85 199 130 91 176 104 64 187 114 73 197 122 80 205 128 84 195 114 69 213 132 85 220 138 91 224 142 95 221 139 92 217 135 88 231 150 105 232 151 106 247 166 123 250 168 128 235 151 117 236 153 121 243 164 131 252 176 140 253 174 133 237 160 116 220 146 101 214 143 101 184 118 83 171 105 71 164 91 56 183 109 74 181 108 76 169 104 82 172 125 115 148 119 124 137 124 150 131 134 175 125 141 193 121 147 206 113 149 211 109 149 210 113 152 207 111 149 198 115 153 198 108 151 194 103 149 199 105 150 205 107 149 209 111 147 209 119 144 208 123 147 209 116 147 204 113 148 204 113 148 204 113 148 204 113 148 204 113 148 204 113 148 204 113 148 204 111 146 202 111 146 202 111 146 202 111 146 202 111 146 202 111 146 202 111 146 202 111 146 202 112 147 205 111 146 204 111 146 204 110 145 203 110 144 205 109 143 204 109 143 204 108 142 203 108 142 203 108 142 203 108 142 203 108 142 203 108 142 205 108 142 205 108 142 205 108 142 205 15 16 46 18 18 46 21 18 47 20 16 41 17 12 32 14 10 24 13 12 18 13 14 19 10 14 26 18 25 43 17 24 52 8 14 46 7 12 42 13 15 40 16 18 33 27 15 27 49 13 27 77 15 30 109 18 33 130 18 30 143 11 22 141 7 14 128 10 10 123 9 8 129 9 11 139 12 19 151 17 26 146 25 30 196 109 100 208 142 126 209 157 136 179 126 82 207 143 55 255 186 88 210 133 63 199 119 68 193 112 67 181 99 52 206 120 63 193 101 34 217 121 44 194 94 8 209 108 16 221 125 38 201 113 41 191 111 60 117 45 23 127 59 46 218 151 122 195 127 90 163 94 55 169 97 57 185 112 71 196 121 79 181 104 60 199 121 75 218 137 90 217 136 89 209 128 81 204 126 78 219 141 95 218 140 94 226 147 104 221 142 103 211 130 100 222 142 115 226 149 121 222 147 115 224 146 108 223 146 104 208 135 94 188 119 80 168 103 71 133 68 38 147 78 45 132 62 28 145 79 47 188 132 109 163 125 116 65 42 48 145 139 165 122 127 169 117 134 188 114 139 203 113 148 216 114 151 221 107 142 206 111 148 203 109 147 196 106 147 193 105 149 198 107 150 201 109 150 206 111 147 205 118 147 207 123 149 208 115 147 204 113 148 204 113 148 204 113 148 204 113 148 204 113 148 204 113 148 204 113 148 204 112 147 203 112 147 203 111 146 202 111 146 202 111 146 202 111 146 202 111 146 202 112 147 203 112 147 205 111 146 204 111 146 204 110 145 203 109 143 204 109 143 204 108 142 203 108 142 203 108 142 203 108 142 203 108 142 203 108 142 203 108 142 205 108 142 205 108 142 205 108 142 205 18 15 44 21 17 44 23 17 45 21 16 39 19 11 32 15 11 25 13 14 19 12 15 20 12 18 30 22 29 47 17 22 51 11 12 43 20 15 45 27 17 41 29 15 30 43 11 22 82 20 35 104 17 33 124 20 31 138 18 27 144 13 19 142 9 12 132 8 10 129 6 9 133 8 16 142 15 24 149 19 27 126 10 11 161 71 62 211 138 121 214 151 133 187 126 82 203 138 46 255 188 84 208 131 51 189 108 45 181 98 46 175 92 40 201 117 57 191 104 33 208 116 33 210 112 21 210 112 15 230 136 46 184 106 34 140 78 31 60 17 1 206 163 156 216 158 136 203 137 105 174 108 76 141 72 39 133 63 29 149 76 41 150 76 39 167 92 53 199 121 82 207 129 90 204 129 90 201 126 87 204 128 92 191 117 80 190 116 81 183 108 77 188 112 88 201 126 105 203 131 107 195 124 96 195 120 88 197 121 85 181 107 70 156 86 52 128 63 33 114 50 22 103 37 5 118 52 18 175 112 81 203 153 128 149 117 106 28 12 13 57 55 69 114 120 152 126 140 187 119 141 201 116 144 217 114 146 223 119 153 227 109 144 212 109 145 203 108 148 199 109 149 198 109 151 199 109 149 200 111 146 200 115 146 201 118 149 206 115 147 204 113 148 204 113 148 204 113 148 204 113 148 204 113 148 204 113 148 204 113 148 204 114 149 205 113 148 204 112 147 203 111 146 202 111 146 202 111 146 202 112 147 203 112 147 203 112 147 205 112 147 205 111 146 204 110 145 203 109 143 204 108 142 203 108 142 203 107 141 202 108 142 203 108 142 203 108 142 203 108 142 203 108 142 205 108 142 205 108 142 205 108 142 205 20 15 45 21 17 44 23 17 45 23 15 39 19 11 32 15 11 25 14 14 22 12 17 23 11 17 29 17 20 39 14 14 42 18 9 40 30 11 39 35 7 29 42 9 20 70 17 25 106 22 38 123 18 33 134 18 27 141 18 21 144 14 16 141 11 13 134 8 12 130 5 13 134 8 19 142 16 27 140 17 22 131 17 16 134 38 26 206 123 107 210 137 118 203 135 90 206 137 42 253 182 74 206 130 44 188 109 42 180 99 44 168 87 34 193 111 51 197 113 41 215 126 42 192 103 13 208 120 31 206 127 50 159 98 41 55 12 0 53 29 17 250 223 216 186 134 113 208 142 116 194 127 100 146 79 52 105 36 7 93 22 0 107 36 6 124 51 19 154 81 49 174 100 71 178 107 77 170 101 72 156 89 62 140 73 47 143 77 51 148 82 60 158 91 74 157 90 74 152 87 69 150 84 62 153 82 54 153 78 46 143 70 37 131 60 30 105 39 13 87 23 0 103 36 7 171 105 73 194 133 102 197 149 126 146 118 106 19 8 6 22 21 29 29 36 55 94 107 142 125 142 194 114 137 205 115 143 217 112 144 219 117 151 223 112 147 211 112 149 204 112 150 199 113 151 198 113 151 198 113 149 199 113 148 202 115 147 204 113 148 204 113 148 204 113 148 204 113 148 204 113 148 204 113 148 204 113 148 204 113 148 204 115 150 206 114 149 205 112 147 203 111 146 202 110 145 201 111 146 202 111 146 202 112 147 203 112 147 205 112 147 205 111 146 204 110 145 203 109 143 204 108 142 203 108 142 203 107 141 202 109 143 204 109 143 204 109 143 204 109 143 204 109 143 206 109 143 206 109 143 206 109 143 206 19 16 47 22 17 47 23 16 47 20 14 40 17 12 32 14 12 25 12 15 22 13 18 24 12 16 28 21 20 38 24 14 41 30 7 36 42 3 30 55 4 23 77 16 23 111 32 37 122 20 34 133 15 29 140 17 22 142 16 17 141 16 12 138 13 11 133 8 14 128 6 17 127 7 19 132 15 24 131 15 18 130 18 14 126 19 9 196 99 83 212 129 111 201 127 80 217 141 43 255 182 69 209 139 53 180 111 44 173 101 51 161 84 38 197 112 55 199 112 43 208 121 41 182 101 22 196 127 60 167 114 62 50 11 0 29 3 0 128 114 103 214 192 181 158 105 87 202 136 112 194 126 103 180 112 89 138 70 47 85 17 0 90 22 0 96 28 5 110 44 22 121 56 36 112 49 32 102 40 25 88 28 17 83 25 14 93 36 27 104 47 38 107 50 41 96 38 27 84 26 14 86 24 9 99 33 9 113 42 14 124 50 21 127 56 28 111 45 21 107 41 17 167 98 69 197 131 99 198 137 106 197 151 127 132 106 93 21 10 6 19 19 21 8 15 25 12 20 43 79 92 127 131 148 200 124 148 210 117 146 214 105 138 207 114 149 213 113 149 209 115 148 201 116 150 198 118 152 200 117 153 203 115 152 205 113 150 205 114 149 205 114 149 205 114 149 205 114 149 205 114 149 205 114 149 205 114 149 205 114 149 205 115 150 206 114 149 205 113 148 204 111 146 202 111 146 202 111 146 202 111 146 202 111 146 202 112 147 205 112 147 205 111 146 204 111 146 204 110 144 205 109 143 204 108 142 203 108 142 203 109 143 204 109 143 204 109 143 204 109 143 204 109 143 206 109 143 206 109 143 206 109 143 206 18 17 49 21 18 49 22 17 49 19 15 42 14 12 33 12 11 25 11 14 23 13 18 24 19 18 32 25 17 38 31 11 38 38 2 30 58 2 27 89 16 33 114 29 34 127 27 29 130 14 25 138 12 24 143 14 18 144 16 13 140 15 9 135 13 10 130 9 16 124 6 18 121 9 23 124 14 23 129 19 20 123 10 6 137 18 10 181 71 58 221 132 114 184 106 60 226 147 52 255 189 78 222 152 64 169 100 33 162 89 44 158 80 41 198 116 68 179 97 41 190 112 46 177 111 51 141 92 49 54 18 0 31 6 0 21 5 5 171 160 154 193 170 156 128 76 54 207 140 114 193 126 100 192 125 99 170 103 77 120 54 30 116 51 29 109 47 26 105 44 26 100 41 27 73 16 5 63 10 2 56 7 2 57 9 7 56 10 10 56 11 8 59 11 7 58 9 4 54 4 0 61 7 0 90 27 9 122 55 29 140 68 43 140 68 44 125 57 36 156 90 68 199 127 102 191 122 93 205 144 115 195 149 125 137 111 98 26 15 11 11 9 10 13 16 23 11 15 27 12 18 40 71 84 118 125 146 191 122 149 204 127 159 220 116 150 213 117 151 212 120 151 208 119 150 204 119 150 204 116 152 204 111 150 207 107 148 204 113 150 205 114 149 205 114 149 205 114 149 205 114 149 205 114 149 205 114 149 205 114 149 205 115 150 206 115 150 206 114 149 205 113 148 204 112 147 203 111 146 202 111 146 202 111 146 202 112 147 205 112 147 205 112 147 205 111 146 204 111 145 206 110 144 205 110 144 205 109 143 204 110 144 205 110 144 205 110 144 205 110 144 205 110 144 207 110 144 207 110 144 207 110 144 207 17 17 51 18 18 52 18 17 49 15 15 43 11 12 33 9 11 26 10 14 23 13 16 25 18 16 29 24 11 31 43 14 42 63 14 43 82 10 34 112 20 35 132 23 26 127 9 9 131 10 19 139 12 21 148 14 15 148 16 12 141 17 9 131 13 9 124 9 16 118 8 19 112 12 24 119 19 27 128 19 22 130 12 10 148 16 12 164 41 33 225 132 114 170 93 49 227 153 64 255 189 86 234 160 73 165 88 20 159 78 31 153 73 36 191 112 79 146 76 40 165 107 67 85 40 7 36 4 0 34 13 12 25 7 21 22 8 21 200 186 185 200 174 159 104 51 20 215 149 114 200 134 99 185 119 85 174 110 75 150 87 56 139 78 49 136 79 52 127 72 51 117 66 49 84 36 22 71 28 19 58 19 14 54 16 15 43 9 8 39 3 3 42 4 3 54 13 9 65 22 16 81 33 23 115 56 40 150 84 62 159 88 66 149 77 55 144 76 57 168 100 79 188 114 89 200 129 101 193 129 101 202 154 131 160 132 120 16 5 1 24 19 25 10 8 19 14 13 19 13 16 23 0 7 19 37 55 77 107 135 172 117 151 199 110 145 203 116 150 213 124 152 215 124 150 211 120 149 207 116 148 207 108 148 207 105 147 205 113 149 207 114 149 205 114 149 205 114 149 205 114 149 205 114 149 205 114 149 205 114 149 205 116 151 207 116 151 207 116 151 207 115 150 206 114 149 205 113 148 204 111 146 202 111 146 202 112 147 205 112 147 205 112 147 205 112 147 205 111 145 206 111 145 206 111 145 206 111 145 206 110 144 205 110 144 205 110 144 205 110 144 205 110 144 207 110 144 207 110 144 207 110 144 207 18 19 50 18 19 50 18 17 49 14 14 42 10 10 34 8 9 27 10 13 22 15 16 21 23 17 27 38 22 35 81 46 68 112 54 78 114 29 50 124 18 30 145 21 23 145 15 15 134 9 15 139 12 19 153 14 17 152 17 14 143 16 10 128 13 8 116 10 12 109 10 15 104 12 17 119 23 27 122 12 13 145 21 21 144 8 8 145 21 13 216 123 106 165 92 51 223 154 77 250 183 92 231 162 84 157 88 23 150 79 35 135 68 39 171 110 89 113 64 47 46 9 0 35 8 0 23 7 8 16 6 17 23 12 29 13 2 16 209 199 198 227 204 188 92 43 11 210 146 108 200 136 98 187 122 84 185 117 82 164 98 64 139 74 42 153 92 64 145 89 64 142 90 69 110 61 46 92 44 32 66 21 15 55 16 11 47 16 13 52 21 16 54 15 10 66 23 16 80 33 25 101 47 35 133 70 52 156 88 67 157 86 64 145 73 51 158 87 65 193 122 100 189 117 92 197 130 103 192 135 108 240 199 179 139 119 110 20 11 12 14 11 20 19 16 27 17 15 18 13 13 13 12 17 20 2 15 23 9 31 52 49 75 108 103 132 176 114 142 192 127 150 204 128 150 207 122 148 205 118 149 206 113 152 209 113 153 212 113 149 207 114 149 205 114 149 205 114 149 205 114 149 207 113 149 207 114 149 207 113 149 207 117 152 210 117 152 208 117 152 208 117 152 208 116 151 207 114 149 205 112 147 203 111 146 202 112 147 203 112 147 203 112 147 205 112 147 205 112 146 207 112 146 207 112 146 207 112 146 207 110 145 203 110 145 203 110 145 203 110 145 203 110 144 205 110 144 207 110 144 207 110 144 208 18 19 40 23 21 45 26 21 51 11 4 35 18 12 38 12 9 28 13 12 20 14 12 15 35 27 25 124 104 105 197 157 165 183 120 129 117 25 36 139 26 32 150 17 18 144 9 6 139 13 16 144 15 20 155 14 22 155 14 20 145 12 15 128 13 10 109 14 8 102 15 8 106 19 12 118 20 17 129 9 10 138 8 10 150 16 17 140 21 17 202 114 100 164 95 62 210 148 87 238 181 110 208 157 94 141 93 44 100 56 21 68 32 10 38 10 0 29 10 6 21 9 9 18 12 14 12 11 17 9 9 17 13 14 19 16 16 16 210 210 202 233 220 201 98 59 28 183 127 90 200 140 104 188 122 88 189 113 81 171 92 61 161 84 54 160 86 59 156 92 65 149 87 64 133 68 50 115 49 35 105 41 31 91 37 27 68 32 18 60 27 12 72 24 12 84 28 13 100 39 20 118 52 30 154 82 58 167 93 68 147 75 50 149 78 50 171 100 72 197 126 96 182 113 82 199 139 111 215 170 149 245 221 209 121 117 118 11 15 24 13 11 22 15 12 21 16 14 19 16 14 17 14 15 17 10 15 19 8 17 26 5 17 33 0 12 33 25 42 70 77 96 129 122 144 185 134 158 204 120 148 196 114 145 199 122 155 209 116 151 207 113 148 206 110 146 204 114 150 208 116 152 212 113 152 211 112 148 208 108 147 206 114 150 210 116 152 210 116 152 210 114 151 206 113 148 204 113 148 202 115 148 202 115 148 202 114 149 203 113 148 202 113 148 204 113 147 208 113 147 210 113 147 210 113 147 208 113 148 206 110 145 201 109 144 198 110 143 196 110 143 197 111 143 202 112 144 205 112 143 208 112 143 210 21 18 37 18 15 36 23 17 45 17 11 39 23 17 43 15 11 28 11 8 15 43 38 35 143 132 126 192 172 165 197 157 155 179 117 118 152 63 67 136 23 27 150 17 18 146 10 10 128 5 7 133 10 13 149 12 22 155 14 23 149 15 22 133 14 16 113 16 10 102 15 6 101 10 5 123 19 18 139 14 18 139 8 14 132 7 11 125 17 17 187 109 99 170 112 88 162 113 70 151 109 59 100 63 21 46 13 0 29 4 0 25 7 0 15 5 3 15 10 16 11 11 19 10 13 22 10 13 22 10 13 18 17 19 18 16 17 12 210 210 200 236 223 206 95 60 32 160 107 75 209 148 117 187 118 87 183 102 72 184 99 70 174 93 63 155 80 49 160 91 62 150 83 57 136 63 44 129 56 41 119 47 35 104 42 29 84 41 24 89 48 28 109 54 34 115 50 30 128 57 35 147 73 48 166 90 64 160 85 56 145 71 42 162 89 57 187 114 81 183 114 81 196 133 102 193 143 116 255 222 205 242 227 220 97 98 103 7 15 26 11 11 21 13 12 20 15 12 19 14 13 18 13 12 17 13 12 17 13 14 18 11 14 21 10 17 27 13 22 37 7 19 41 14 29 58 60 80 115 118 139 182 134 158 204 115 141 190 119 149 203 117 150 204 117 149 206 114 149 205 113 148 204 113 149 207 117 153 211 122 158 218 115 154 213 115 154 211 117 153 211 116 152 210 114 151 206 113 148 202 113 148 202 113 148 202 113 149 201 113 148 202 114 149 207 115 149 210 114 148 212 114 148 212 113 147 210 113 148 206 112 147 201 111 147 199 112 145 198 111 144 197 112 144 201 112 144 205 113 142 210 113 142 212 21 16 38 16 12 35 22 20 44 16 16 40 14 12 33 10 8 21 25 19 21 118 107 103 183 169 160 207 185 174 188 153 147 176 125 121 196 120 120 146 48 49 141 19 18 142 17 15 126 16 15 129 19 20 143 16 25 148 14 25 144 10 21 132 7 15 115 6 11 107 4 7 118 13 18 126 12 20 131 5 19 137 11 25 135 24 33 120 29 34 119 58 53 80 38 24 39 7 0 37 11 0 27 4 0 21 2 0 25 10 3 26 16 15 18 13 17 14 13 19 13 13 23 13 13 23 13 12 20 15 13 18 22 16 18 17 9 7 212 201 197 244 224 213 72 34 11 137 83 55 199 134 106 212 137 108 194 113 83 178 98 63 162 86 50 169 99 63 161 92 59 147 80 53 133 61 39 136 65 47 123 54 39 111 49 34 102 49 31 121 69 48 133 68 48 131 60 38 138 66 42 156 82 57 169 93 67 159 84 53 153 77 45 174 100 65 179 109 75 189 124 92 192 138 110 223 182 162 255 232 221 239 225 222 84 83 88 9 12 21 10 10 18 11 11 19 13 12 18 13 12 17 12 11 16 12 11 16 13 12 17 12 13 18 13 16 25 3 9 21 9 16 34 18 29 51 8 19 49 1 15 50 46 61 100 106 125 167 128 150 197 121 148 195 120 146 195 124 152 202 124 156 207 121 154 207 116 149 203 112 147 203 114 151 206 112 148 206 110 149 206 113 152 209 113 152 209 113 150 205 114 151 206 117 154 209 112 147 201 113 148 202 114 150 208 115 151 211 115 150 214 114 149 213 112 148 210 111 147 207 114 149 205 113 149 201 111 147 199 110 145 199 112 144 201 113 145 206 113 142 208 112 141 209 26 18 42 18 13 36 17 19 42 12 17 37 6 9 24 13 12 20 39 29 28 178 161 153 191 172 158 195 172 158 185 155 144 169 129 121 213 152 147 178 94 92 147 39 37 144 25 27 124 14 17 127 16 22 137 16 25 142 16 28 137 15 26 127 13 23 110 13 20 102 11 18 95 5 14 112 19 30 124 23 37 111 15 29 82 1 10 57 0 0 43 8 6 30 9 4 27 9 5 24 10 9 23 11 11 18 9 10 11 6 10 10 8 13 14 13 19 15 15 23 15 15 23 13 12 20 15 10 17 18 11 18 24 13 17 20 5 8 204 188 189 254 229 224 91 54 36 113 61 39 205 138 112 211 134 106 190 110 77 190 112 74 173 102 60 171 104 62 165 97 62 154 85 56 137 66 44 141 70 52 127 60 43 121 56 38 120 57 39 147 81 59 153 78 55 151 73 50 149 74 51 161 87 62 173 98 69 172 96 64 172 94 58 182 108 71 183 115 80 183 124 94 199 154 133 255 226 213 237 218 212 235 225 224 60 55 59 14 13 19 10 10 18 9 12 19 11 12 17 11 12 17 11 10 15 11 10 15 12 11 16 13 12 18 17 16 24 19 19 29 17 19 34 13 16 35 11 16 38 13 19 45 15 22 51 12 23 55 32 48 84 84 103 143 126 145 187 123 146 188 115 139 185 121 149 196 125 156 203 118 150 201 124 157 210 118 153 207 116 153 208 118 155 210 114 153 208 108 147 204 107 146 203 110 149 206 113 148 204 113 148 204 113 149 209 114 150 212 114 149 213 113 148 214 112 147 211 111 147 207 114 149 205 112 147 201 111 146 200 110 145 199 112 144 201 112 144 205 113 142 208 113 142 208 29 19 46 17 13 38 10 15 37 8 17 34 10 16 28 23 21 26 41 26 21 183 161 148 202 176 159 203 178 158 186 163 147 173 144 130 213 166 158 207 142 138 171 81 80 127 18 21 134 12 23 139 13 27 141 16 32 135 19 32 120 18 29 99 17 23 75 13 14 61 11 12 60 16 17 55 13 15 50 5 10 44 1 8 36 4 9 32 12 13 14 10 7 6 8 7 9 8 16 10 8 21 15 13 26 16 16 26 12 15 24 15 18 25 15 18 25 8 11 16 12 13 17 11 10 15 15 10 14 22 13 18 26 13 20 22 7 12 181 164 172 252 227 230 211 177 167 84 35 18 177 109 90 214 134 109 199 119 84 180 105 63 174 108 60 177 113 69 173 105 68 164 95 64 148 78 53 144 76 55 135 68 49 134 66 45 144 69 50 168 87 66 170 86 62 164 80 54 161 81 58 169 93 67 175 98 68 169 93 59 175 97 59 184 110 73 192 128 93 163 112 85 230 197 182 252 232 225 239 229 230 228 222 226 25 16 19 21 16 20 11 12 17 9 14 20 10 13 18 11 12 17 11 10 16 11 10 16 13 11 16 16 11 17 19 14 21 13 10 19 15 12 23 22 20 33 26 23 40 20 19 37 16 14 35 14 16 39 16 23 51 0 9 39 16 29 61 79 94 127 128 146 182 135 157 196 127 150 192 123 150 195 119 147 195 116 148 197 118 151 202 120 156 208 118 155 208 113 150 205 110 149 206 113 152 209 114 149 205 114 149 205 114 148 209 113 147 210 112 147 211 112 147 213 112 147 211 112 148 210 111 147 205 110 147 202 109 144 200 109 144 200 112 144 203 112 144 205 113 143 207 113 143 207 23 14 43 19 15 40 12 18 40 8 17 34 10 17 27 23 19 20 43 26 18 184 158 143 191 164 143 209 184 162 185 166 149 186 164 150 208 175 166 224 175 170 221 150 148 136 47 51 124 22 33 122 17 31 110 12 25 92 9 17 73 7 11 54 6 6 35 5 3 23 5 1 19 8 6 17 7 6 20 8 10 18 7 11 15 9 13 15 15 17 6 14 16 5 16 20 11 15 27 11 14 29 12 14 27 7 11 22 5 9 18 10 15 19 13 17 20 6 10 11 10 11 13 13 11 12 16 12 13 21 15 17 22 13 18 16 5 13 136 123 132 230 211 217 255 232 228 157 113 102 135 69 53 197 121 97 194 116 80 182 108 63 182 116 66 169 105 57 179 110 71 169 98 66 155 85 60 144 76 53 143 77 55 144 73 51 159 79 56 177 91 68 170 80 54 164 74 48 164 80 54 181 101 74 177 101 69 160 84 48 171 96 57 186 118 81 161 104 74 193 151 129 249 225 215 236 224 224 242 235 242 191 186 192 16 5 9 23 14 17 12 13 17 9 14 18 10 13 18 9 12 17 11 10 16 11 10 16 15 10 16 16 11 17 18 11 19 21 14 22 24 18 28 24 18 28 21 15 27 20 14 26 23 17 31 25 23 37 17 18 38 18 23 45 16 22 46 10 17 43 16 27 55 47 62 93 92 108 142 122 142 179 129 152 194 127 154 197 127 155 202 122 153 200 117 149 198 114 147 198 115 151 203 118 153 207 117 150 204 117 149 206 116 148 209 113 147 210 112 146 210 111 146 210 111 146 210 111 147 209 110 146 206 109 145 203 109 144 202 108 143 201 111 143 202 112 144 205 112 142 204 112 142 206 17 12 42 18 18 44 14 20 44 8 15 33 10 12 24 16 10 10 50 32 22 192 166 149 197 171 148 207 185 162 189 173 157 187 171 158 202 179 173 227 192 190 241 190 189 141 82 84 68 16 18 58 14 13 46 8 7 34 6 3 25 7 3 19 12 6 14 15 9 12 17 11 15 20 16 9 13 12 12 12 14 10 8 13 7 4 11 7 6 12 13 13 21 11 14 21 3 3 11 8 11 18 16 17 22 16 17 21 15 16 18 14 16 15 14 16 13 14 16 13 13 13 11 14 14 12 13 11 12 17 15 18 12 10 15 11 8 15 97 94 103 214 204 212 252 232 233 238 201 195 112 56 43 171 103 80 200 126 91 178 104 59 173 101 53 182 111 65 183 111 73 168 95 63 155 85 59 141 74 48 151 83 60 146 74 49 164 83 56 179 92 65 172 81 54 170 79 52 171 85 58 189 108 78 182 103 70 162 88 51 170 100 64 176 116 82 159 113 87 242 211 193 243 228 223 234 228 232 232 229 236 123 118 125 24 13 17 20 11 14 12 13 17 9 14 17 10 14 17 9 13 16 11 10 16 11 10 16 15 10 17 16 11 18 17 10 18 18 11 19 22 15 23 27 20 28 27 20 28 24 17 25 23 16 24 24 18 28 18 16 29 20 19 35 19 20 38 16 19 38 12 17 39 11 19 42 14 24 51 15 29 58 34 50 84 59 79 114 93 115 154 116 139 181 127 151 195 128 155 200 124 152 199 118 146 194 120 150 202 118 149 204 118 149 206 116 148 207 113 147 208 112 146 209 110 146 208 109 145 207 111 147 209 110 146 206 109 143 204 108 142 203 111 143 204 111 143 204 111 141 203 111 141 203 16 16 44 15 16 44 11 15 42 10 12 33 17 15 28 18 9 10 51 33 21 181 158 140 204 182 159 195 174 153 198 185 169 189 176 167 206 191 186 219 195 195 192 158 159 75 41 42 30 9 8 23 12 8 18 13 7 15 16 10 12 19 12 9 19 11 6 17 11 3 14 10 10 19 18 5 11 11 11 15 18 14 17 22 17 18 23 11 12 17 20 19 27 9 8 14 16 16 18 15 15 15 11 11 9 11 11 9 16 15 11 13 12 8 11 10 6 15 14 10 14 14 12 14 14 12 11 11 11 13 14 16 11 12 16 19 20 25 87 90 97 220 218 223 243 228 231 255 237 234 153 109 98 113 56 36 187 118 85 198 125 84 183 106 62 179 102 58 189 113 77 166 93 60 155 86 57 141 74 48 159 89 64 148 74 47 165 86 56 179 94 65 176 86 60 178 88 62 175 88 60 183 100 68 174 96 60 157 84 49 154 91 58 138 89 59 211 176 156 248 229 215 241 231 230 233 231 236 235 232 239 70 65 72 19 8 14 20 11 16 13 13 15 10 14 17 9 13 16 10 11 15 10 9 15 10 9 15 12 9 16 15 10 17 17 12 19 24 18 28 25 19 29 21 15 25 22 17 24 28 23 30 27 22 29 20 15 22 25 22 31 23 20 31 19 17 30 18 17 31 20 22 37 22 25 44 18 23 43 12 18 42 13 23 50 16 27 55 13 26 58 10 25 58 26 42 78 65 83 119 108 128 165 132 153 196 124 148 196 122 149 202 122 149 204 120 149 205 118 149 206 115 147 206 111 145 206 109 143 204 112 148 210 111 147 209 110 144 207 109 143 204 111 143 204 110 142 203 111 141 203 110 140 202 18 19 49 13 14 42 16 16 44 14 12 34 19 13 27 19 8 12 49 32 22 173 156 138 198 182 159 198 183 162 196 184 172 187 176 170 173 161 161 142 127 130 44 25 29 29 13 14 21 11 12 17 13 12 14 14 12 13 15 14 11 15 14 12 14 13 13 13 13 14 12 15 17 12 16 15 13 16 14 14 16 11 15 18 10 15 18 7 15 17 9 14 17 10 14 13 16 17 12 15 15 7 14 14 6 14 13 8 16 12 9 16 12 9 15 11 10 13 9 10 19 17 20 13 13 15 14 13 18 10 11 15 14 15 20 9 12 17 74 79 83 222 223 227 229 220 225 255 243 241 244 216 205 98 55 36 152 93 63 189 116 81 198 116 78 181 97 60 185 107 71 182 107 75 155 84 56 148 78 52 148 76 51 127 53 24 169 94 62 162 86 54 164 82 58 159 75 49 176 91 60 185 102 68 164 86 50 150 84 50 116 62 34 179 143 121 244 222 209 252 241 235 238 232 232 232 230 233 228 223 229 27 20 28 21 11 20 15 8 15 11 11 13 11 12 14 12 13 15 12 12 14 11 10 15 11 10 16 12 11 17 15 12 21 14 11 20 15 12 23 18 15 26 21 18 29 22 20 31 23 21 32 23 22 30 23 22 30 24 21 30 26 20 30 25 22 31 24 21 32 22 20 33 21 19 33 21 20 36 19 20 38 20 23 42 19 24 44 21 26 48 18 24 48 12 17 46 8 15 43 17 26 55 28 41 75 86 105 147 127 149 196 125 149 197 119 145 194 119 146 199 121 151 205 111 142 197 116 148 207 111 145 206 111 145 208 111 145 208 111 145 208 111 142 206 111 143 204 112 142 204 112 142 202 16 17 45 16 17 45 18 15 44 20 15 38 24 13 30 18 5 12 38 23 16 173 160 143 187 174 155 205 192 176 172 159 151 38 26 26 26 15 21 26 16 24 7 0 3 25 19 23 18 12 16 17 12 18 16 14 19 15 15 17 13 14 18 14 14 16 17 12 16 17 11 15 18 12 16 17 12 16 14 14 16 13 15 14 11 15 14 10 14 13 12 14 13 13 13 11 14 13 8 13 13 5 13 12 7 13 12 8 17 13 14 17 12 16 18 11 18 16 11 17 14 9 16 12 9 16 16 15 23 17 16 22 15 16 21 14 15 19 53 57 60 229 230 232 229 224 228 246 236 235 255 243 234 232 205 186 129 79 54 175 108 79 188 107 77 195 111 77 186 107 74 188 115 82 159 88 60 143 72 44 155 81 54 124 50 21 138 67 35 143 72 40 141 67 42 153 75 52 158 77 47 188 109 76 161 88 55 114 55 25 152 110 88 248 222 209 250 237 231 243 237 237 249 245 246 234 229 233 152 146 150 20 13 20 14 6 17 16 11 18 11 11 13 12 12 12 13 13 15 12 12 14 11 10 15 11 10 15 13 12 20 14 13 21 16 14 25 16 16 26 17 17 29 19 19 31 20 19 33 19 21 34 19 21 33 21 21 31 24 21 30 27 22 29 27 22 29 27 21 31 24 21 30 24 21 32 24 21 32 25 21 35 27 25 38 23 21 35 22 19 36 24 23 41 24 22 43 19 20 40 19 20 41 19 23 50 11 24 59 20 35 76 88 105 148 130 151 194 122 146 192 118 144 193 118 148 200 111 142 197 113 145 204 111 145 208 111 145 209 110 144 208 111 142 207 110 141 205 111 141 203 112 142 202 15 15 39 20 18 42 16 10 36 23 13 38 27 14 32 21 8 17 31 18 12 177 165 153 206 194 180 184 171 162 38 27 25 29 18 22 17 7 16 18 11 19 20 18 23 17 12 18 23 10 20 25 9 20 22 12 21 19 14 20 16 13 20 15 14 19 15 15 17 14 14 16 13 13 13 14 14 14 14 14 14 14 14 12 17 13 12 19 10 11 21 9 9 19 9 8 13 11 12 11 13 12 12 12 14 12 11 16 15 12 21 15 12 23 17 11 25 17 11 25 18 12 26 18 12 26 19 13 25 21 15 25 14 9 16 20 15 21 35 33 34 226 222 223 239 234 240 242 236 238 255 255 246 254 238 222 249 211 192 148 90 68 191 115 91 201 120 93 192 117 86 185 114 82 164 95 64 150 81 50 156 82 53 123 49 20 135 69 37 148 83 53 135 67 44 128 57 35 173 99 72 170 99 69 137 76 47 137 89 66 251 222 208 248 233 226 255 250 252 240 239 244 245 243 246 231 227 228 67 58 61 15 6 11 13 7 17 15 12 21 14 12 15 13 13 13 13 13 13 13 13 15 12 11 16 12 11 16 13 13 21 14 14 22 16 16 26 15 18 27 15 17 29 15 19 31 16 19 34 17 20 35 16 22 36 18 22 34 22 20 31 24 21 30 25 22 31 25 22 31 26 20 30 26 20 30 26 20 30 27 21 31 32 24 35 26 18 31 25 17 30 28 22 36 30 24 38 25 21 35 21 17 32 17 15 36 13 17 46 12 21 54 20 31 63 50 64 99 117 135 173 127 150 192 119 146 193 118 145 198 113 144 201 113 145 206 111 145 209 110 144 208 108 142 206 107 141 204 110 142 203 110 142 201 20 17 36 23 18 38 15 7 30 20 11 32 23 12 28 23 12 20 25 14 12 173 163 154 193 183 173 87 76 70 20 10 11 30 20 28 12 4 15 15 12 21 13 12 17 13 11 16 23 11 21 24 11 21 23 11 21 20 13 21 17 14 21 16 15 20 14 15 17 12 16 17 10 14 13 10 14 13 14 14 12 15 14 12 17 11 11 20 10 9 23 9 9 20 8 10 14 12 17 10 13 18 12 12 20 12 12 22 13 11 24 13 11 25 14 10 25 16 9 25 19 12 28 20 11 28 20 12 25 20 12 23 14 7 15 20 14 18 24 18 20 171 165 167 229 222 229 252 247 251 246 247 241 255 255 243 255 249 234 232 186 170 147 82 64 200 125 102 215 144 116 191 122 91 174 108 76 164 98 66 148 77 47 118 49 18 149 84 54 141 77 50 130 68 45 136 74 53 177 113 88 160 103 76 121 73 51 253 217 201 255 237 230 255 249 250 253 252 255 247 248 253 238 236 239 202 198 199 25 16 19 14 8 12 14 11 18 13 12 18 15 13 18 15 13 16 14 14 16 13 13 15 13 13 15 14 13 18 14 15 20 15 16 21 12 15 22 13 16 25 14 18 29 15 19 31 17 20 35 15 21 37 16 22 38 17 20 35 20 20 32 23 20 31 23 20 31 23 20 31 25 19 29 25 19 29 27 19 30 27 20 28 32 22 31 30 20 29 30 20 31 28 20 31 27 19 30 25 17 28 26 18 31 27 23 38 27 25 46 16 18 43 13 17 42 13 23 50 8 22 51 33 51 87 105 128 170 121 147 196 114 143 199 113 143 205 112 143 208 109 142 209 108 142 206 107 141 204 109 141 202 109 141 200 29 18 32 24 16 31 19 12 28 20 13 29 16 10 24 19 12 20 23 11 11 168 155 149 182 169 163 23 12 10 36 27 30 8 3 10 10 7 16 25 24 30 15 15 17 16 16 18 16 15 21 17 14 21 20 15 22 20 15 21 19 14 20 17 15 20 15 16 18 14 15 17 10 14 13 10 14 13 13 13 13 13 13 11 16 12 11 16 12 11 16 10 10 15 11 12 12 13 18 10 13 22 10 13 22 10 12 24 12 12 24 12 12 24 13 11 24 13 11 24 11 7 21 15 9 21 19 13 25 21 13 24 21 14 22 21 11 19 20 11 16 85 76 81 225 216 221 231 225 229 255 255 253 254 253 248 255 249 241 255 247 236 203 155 141 151 93 73 201 137 110 199 134 104 193 129 94 181 117 82 158 93 61 136 71 41 172 106 80 140 76 51 130 69 48 179 122 102 161 110 89 116 73 56 252 220 207 255 249 243 255 245 245 255 253 255 249 250 255 254 255 255 244 243 248 130 125 129 20 14 18 19 13 17 16 14 19 16 13 20 16 15 20 15 14 19 14 13 18 14 14 16 13 14 16 14 15 17 15 16 20 15 16 20 12 15 20 14 17 22 16 19 28 18 20 32 19 21 34 18 21 36 17 20 37 16 19 34 20 19 33 21 19 32 22 20 33 22 20 33 23 20 31 23 20 29 25 19 29 26 20 30 27 19 30 28 20 31 28 20 31 26 20 30 24 18 30 23 17 29 26 20 32 30 24 36 28 22 36 32 28 43 18 17 33 15 18 37 11 19 42 8 22 51 43 61 99 127 149 196 117 142 198 114 143 203 112 143 208 111 142 209 108 142 206 106 140 203 106 140 201 107 142 200 53 36 46 25 12 22 21 15 27 21 19 32 12 10 21 17 12 19 26 14 16 163 148 145 104 89 86 22 10 10 10 4 8 25 24 30 16 16 24 9 10 15 17 15 16 21 19 20 13 17 18 13 17 20 16 15 20 19 14 20 20 13 20 19 14 20 16 14 17 14 15 17 12 14 13 12 14 13 13 13 13 14 12 13 14 12 13 13 13 13 12 12 12 11 12 14 10 11 16 11 11 19 12 12 20 12 12 20 12 13 18 12 13 18 13 14 19 14 15 19 14 13 19 15 14 20 17 14 21 16 13 20 22 17 24 19 12 20 24 17 25 31 21 30 194 183 189 229 220 225 242 240 243 251 251 251 255 255 251 255 251 243 255 247 236 183 137 121 166 110 85 202 141 110 215 155 119 198 138 102 183 123 89 166 102 74 191 123 102 167 99 80 172 112 88 171 121 98 135 93 77 253 223 213 255 250 246 253 243 244 255 253 255 254 253 255 251 252 255 253 254 255 236 235 240 49 47 50 23 18 24 21 16 20 18 13 17 18 16 21 17 16 22 15 16 21 14 13 19 13 14 18 14 15 17 15 16 18 16 17 19 16 17 19 17 21 22 18 22 25 19 22 27 22 22 32 22 22 34 21 20 34 18 20 35 17 19 34 21 20 36 22 21 35 23 21 35 23 21 35 23 19 33 23 20 31 24 21 32 27 21 31 26 20 32 24 18 30 24 18 30 23 20 31 24 20 34 23 19 33 20 18 31 20 17 28 22 12 21 21 11 20 34 28 38 22 22 34 11 17 33 8 19 41 2 18 51 102 123 166 119 142 196 115 144 204 114 143 209 111 142 209 108 141 208 106 140 203 106 140 201 107 142 200 120 95 101 42 23 29 20 15 22 17 20 29 11 14 21 14 13 19 26 14 16 148 130 130 57 37 38 28 14 14 19 14 18 6 9 14 14 19 23 17 18 22 23 17 17 13 8 5 11 17 15 11 17 17 16 14 17 19 13 17 22 11 17 22 11 17 17 12 16 15 13 16 13 13 15 13 13 15 14 12 15 14 12 15 14 12 15 12 12 14 9 13 14 9 13 14 13 11 14 16 12 13 17 13 14 14 13 11 13 14 9 11 14 7 12 15 8 11 16 9 15 20 14 14 19 15 12 16 15 10 11 15 15 16 21 14 13 21 24 22 33 21 15 25 130 117 126 234 223 229 243 238 244 254 255 255 247 253 253 254 255 250 255 248 239 255 241 226 181 131 108 177 118 88 200 142 105 194 136 98 190 134 99 180 119 91 191 118 101 183 110 93 178 118 94 184 138 114 253 221 208 255 245 241 251 245 249 255 254 255 255 254 255 250 249 255 255 254 255 250 248 253 170 169 174 15 14 19 20 19 25 18 16 21 21 17 18 21 16 20 19 18 26 14 17 26 14 14 22 13 14 19 15 16 20 16 17 19 17 19 18 17 19 18 21 23 22 21 23 22 20 21 23 21 20 26 21 20 28 21 19 30 21 19 32 20 18 32 21 20 36 22 21 37 22 21 37 22 21 35 22 20 34 22 20 33 22 20 33 24 21 32 22 18 32 20 18 31 20 18 31 20 18 32 21 20 36 20 19 35 15 17 32 15 13 26 35 24 30 26 11 14 35 26 29 17 15 20 11 13 25 16 24 43 6 21 50 52 71 111 120 143 193 117 143 202 114 143 209 112 143 210 108 141 208 106 141 205 105 141 203 106 142 202 190 162 161 66 44 46 23 12 16 18 16 21 15 14 19 14 12 17 20 8 12 123 107 110 27 8 10 16 4 6 20 18 21 16 20 23 12 16 19 14 15 17 23 14 15 22 17 14 12 16 15 11 17 15 16 14 15 19 13 15 22 11 17 20 11 16 17 12 16 15 13 16 13 13 15 13 13 15 14 12 17 14 12 17 14 12 17 12 11 16 9 13 16 9 13 14 17 13 14 19 13 13 18 14 11 17 13 10 13 12 7 11 12 6 10 13 4 9 15 5 6 11 4 10 15 9 10 14 13 10 14 15 13 16 21 13 13 21 16 16 26 24 21 32 88 77 85 238 225 232 233 226 234 255 254 255 251 255 255 247 251 250 255 254 248 255 250 240 255 230 214 174 129 108 194 150 123 219 175 148 236 194 169 244 197 177 245 187 176 237 179 168 223 176 158 182 147 128 255 232 224 255 252 251 255 253 255 249 252 255 251 251 255 255 254 255 255 254 255 248 246 251 91 90 95 19 20 25 18 19 24 15 14 19 26 22 23 20 15 19 19 18 26 14 17 26 14 14 22 14 15 20 15 16 20 17 18 20 17 18 20 17 19 18 20 21 23 19 20 22 18 17 22 18 17 23 19 16 25 20 17 28 22 19 30 22 20 33 22 19 36 21 20 36 22 21 37 21 20 34 21 19 33 20 18 32 21 19 32 21 19 32 19 17 30 21 19 32 20 19 33 19 18 32 16 15 31 15 17 32 16 18 33 21 19 32 24 15 20 29 19 20 24 15 18 21 16 22 30 29 37 7 13 25 11 22 44 15 31 65 122 142 192 118 142 202 114 143 209 110 143 210 108 142 206 106 142 204 105 141 201 106 142 202 208 179 171 160 135 128 35 14 11 29 13 13 25 10 13 22 10 14 29 17 21 61 49 53 22 11 15 19 13 15 18 16 19 17 17 19 17 17 19 18 16 19 18 13 17 18 13 17 17 17 19 15 16 18 15 15 17 16 14 17 17 12 16 15 13 16 15 13 16 14 14 16 12 12 14 12 12 14 13 13 15 13 13 15 13 13 15 13 13 15 11 12 14 10 11 13 14 12 15 15 13 14 16 14 15 16 14 15 14 14 14 13 13 13 12 12 12 11 13 12 11 13 12 12 13 15 12 13 15 13 14 18 13 14 19 16 15 21 18 17 25 21 18 25 44 34 42 221 210 218 239 229 237 248 243 249 252 250 255 252 252 254 255 254 255 255 251 252 255 247 246 255 240 236 251 234 227 242 225 218 246 227 223 236 217 213 203 177 178 177 153 153 65 44 41 35 20 15 68 58 57 228 222 224 253 251 255 255 254 255 255 254 255 252 251 255 247 246 251 214 213 218 24 23 28 23 22 27 24 23 28 21 19 22 15 13 14 22 20 23 18 17 22 17 18 23 19 18 24 19 18 24 19 18 24 19 18 24 20 19 25 20 19 25 22 21 29 22 21 29 22 21 29 21 20 28 21 19 30 20 18 29 20 18 29 20 18 29 21 19 32 21 19 33 20 18 32 21 19 32 22 20 33 22 20 33 20 18 31 18 16 29 19 17 30 18 16 29 18 16 29 18 16 29 19 17 31 18 17 31 18 17 31 18 16 27 16 15 21 19 17 22 23 17 27 21 18 27 19 17 22 15 16 21 8 14 26 4 14 41 111 128 174 116 138 198 112 140 205 113 147 211 106 141 199 110 147 202 104 140 198 109 145 203 206 176 165 188 160 148 91 64 57 29 5 1 30 10 9 25 9 10 27 15 19 36 27 32 18 12 16 18 13 17 17 15 16 18 16 17 18 16 19 17 15 18 18 13 20 15 13 18 16 15 20 15 15 17 15 15 17 14 14 16 14 14 16 14 14 16 14 14 16 14 14 16 13 13 15 13 13 15 13 13 15 13 13 15 13 13 15 13 13 15 12 12 14 12 12 14 12 12 14 13 13 15 14 14 16 15 15 17 14 13 18 13 12 17 13 12 17 13 12 17 14 13 18 14 13 18 15 14 19 14 13 18 14 13 19 14 13 19 16 15 21 18 15 22 30 23 30 177 167 175 244 234 242 247 240 247 248 243 249 255 253 255 250 248 253 255 253 255 250 248 253 137 135 140 82 77 83 76 71 77 55 48 55 39 32 39 36 26 34 30 21 26 28 22 26 29 23 25 19 14 18 42 37 41 206 204 209 250 248 253 255 254 255 252 251 255 255 254 255 117 116 121 23 22 27 16 15 20 19 17 20 21 19 22 19 17 18 22 20 21 20 19 24 20 19 24 20 19 24 20 19 24 20 19 27 21 20 28 21 19 30 21 19 30 21 19 30 21 19 30 21 19 30 22 20 31 22 20 31 22 20 31 22 21 29 22 21 29 22 20 33 21 19 32 21 19 32 22 20 33 22 20 33 22 20 33 20 18 31 19 17 30 23 21 34 22 20 33 21 19 32 20 18 31 19 17 30 18 16 29 17 15 28 15 15 25 15 15 23 16 16 24 19 17 30 20 17 28 21 16 22 17 15 18 12 15 22 8 14 36 70 83 128 115 135 194 119 147 210 107 139 200 110 145 199 108 145 197 105 142 197 112 148 206 201 169 156 200 171 157 153 126 117 66 41 36 29 8 7 32 13 15 32 20 24 22 13 16 18 12 16 17 12 16 16 14 15 17 15 16 17 15 18 16 14 17 15 12 19 15 13 18 15 14 19 15 15 17 14 14 16 14 14 16 14 14 16 13 13 15 13 13 15 13 13 15 15 15 17 15 15 17 14 14 16 13 13 15 13 13 15 13 13 15 12 12 14 12 12 14 11 11 13 12 12 14 14 14 16 14 14 16 14 13 18 13 12 17 14 13 18 14 13 18 13 12 17 14 13 18 15 14 19 14 13 18 14 13 19 14 13 19 14 13 19 16 13 20 27 20 27 123 116 123 230 223 230 248 241 248 255 253 255 250 245 251 255 254 255 250 248 253 112 110 115 24 22 27 8 6 11 30 28 33 21 16 22 20 15 21 29 22 29 22 16 20 20 14 18 24 18 20 35 30 34 22 17 21 44 42 47 217 215 220 254 253 255 245 244 249 226 225 230 40 39 44 25 24 29 19 18 23 19 17 20 24 22 25 22 20 21 22 20 21 21 20 25 21 20 25 21 20 25 21 20 25 21 20 28 21 20 28 21 19 30 21 19 30 22 20 31 22 20 31 23 21 32 23 21 32 23 21 32 23 21 32 23 22 30 22 21 29 24 22 35 23 21 34 23 21 34 24 22 35 24 22 35 24 22 35 23 21 34 22 20 33 25 23 36 24 22 35 22 20 33 20 18 31 19 17 30 17 15 28 15 13 26 13 13 25 14 14 24 16 16 26 18 16 29 19 16 27 20 15 21 17 15 18 13 16 23 9 16 35 29 42 84 127 146 202 121 147 208 109 139 199 111 146 200 105 142 195 110 146 204 109 145 205 201 168 151 193 161 146 195 165 154 139 112 105 36 12 10 35 17 17 33 18 21 22 13 16 18 12 16 17 12 16 16 14 15 17 15 16 17 15 18 16 14 19 15 12 19 15 13 18 15 14 19 15 15 17 15 15 17 15 15 17 14 14 16 14 14 16 14 14 16 13 13 15 16 16 18 16 16 18 15 15 17 13 13 15 13 13 15 13 13 15 13 13 15 13 13 15 12 12 14 13 13 15 14 14 16 14 14 16 13 12 17 13 12 17 13 12 17 14 13 18 11 10 15 12 11 16 14 13 18 14 13 18 14 13 19 14 13 19 15 14 20 16 13 20 21 16 22 87 80 87 229 222 229 254 249 255 255 252 255 251 249 254 249 247 252 105 103 108 20 18 23 16 14 19 27 25 30 28 26 31 26 21 27 30 25 31 25 18 25 19 13 17 31 25 29 18 12 14 14 9 13 15 10 14 31 29 34 49 47 52 228 227 232 250 249 254 137 136 141 25 24 29 22 21 26 25 24 29 22 20 23 23 21 24 22 20 21 21 19 22 21 20 25 21 20 25 21 20 25 21 20 25 21 20 28 20 19 27 20 18 29 20 18 29 25 23 34 25 23 34 25 23 34 24 22 33 23 21 32 22 20 31 21 20 28 21 20 28 23 21 34 23 21 34 23 21 34 24 22 35 24 22 35 24 22 35 23 21 34 22 20 33 22 20 33 21 19 32 20 18 31 19 17 30 18 16 29 17 15 28 16 14 27 14 14 26 15 15 27 16 16 28 17 15 29 18 15 26 19 14 20 16 14 17 13 16 21 9 16 34 10 22 60 122 140 190 112 137 193 115 146 203 110 143 197 105 142 197 115 151 211 104 140 202 208 173 153 189 156 137 208 176 163 180 152 141 63 38 34 35 15 14 24 10 10 24 14 15 19 13 15 18 14 15 16 14 15 17 15 16 17 15 18 16 14 19 16 13 20 16 14 19 15 14 19 15 15 17 15 15 17 15 15 17 15 15 17 15 15 17 14 14 16 14 14 16 17 17 19 16 16 18 15 15 17 14 14 16 13 13 15 13 13 15 13 13 15 13 13 15 13 13 15 13 13 15 14 14 16 14 14 16 13 12 17 12 11 16 12 11 16 13 12 17 11 10 15 12 11 16 13 12 17 14 13 18 14 13 19 14 13 19 15 14 20 16 13 20 23 18 25 39 34 41 204 199 206 239 236 243 249 247 252 255 254 255 100 98 103 14 13 18 17 16 21 24 23 28 22 20 25 12 10 15 18 16 19 23 21 24 20 15 19 31 26 30 24 18 22 24 18 22 27 22 26 25 20 24 20 18 23 16 14 19 84 83 89 230 229 235 49 48 54 22 21 27 19 18 23 22 21 26 21 19 22 19 17 20 23 21 24 19 17 20 22 21 26 22 21 26 22 21 26 21 20 25 21 20 28 21 20 28 21 19 30 21 19 30 26 24 35 26 24 35 25 23 34 25 23 34 24 22 33 22 20 31 21 20 28 20 19 27 20 18 31 21 19 32 21 19 32 21 19 32 21 19 32 21 19 32 21 19 32 21 19 32 21 19 32 20 18 31 19 17 30 18 16 29 19 17 30 18 16 29 17 15 28 15 15 27 16 16 28 16 15 29 17 15 29 17 14 25 18 13 19 15 13 16 13 14 19 9 15 29 3 14 44 74 91 134 117 140 190 116 146 200 109 140 194 110 145 201 113 149 211 108 143 207 209 171 148 195 158 139 200 167 150 173 143 132 106 78 74 38 17 16 20 4 5 23 13 14 19 13 15 18 14 15 16 14 15 16 14 17 16 14 19 16 14 19 16 13 20 16 14 19 14 13 18 15 15 17 15 15 17 16 16 18 16 16 18 15 15 17 15 15 17 14 14 16 16 16 18 15 15 17 15 15 17 14 14 16 13 13 15 13 13 15 13 13 15 13 13 15 13 13 15 14 14 16 14 14 16 13 13 15 12 11 16 11 10 15 12 11 16 12 11 16 12 11 16 13 12 17 14 13 18 14 13 18 13 12 18 13 12 18 14 13 19 14 13 19 16 13 20 29 26 33 127 124 131 242 239 246 255 254 255 98 96 101 21 20 25 23 22 27 20 19 24 12 11 16 16 14 19 16 14 19 16 14 17 19 17 20 19 14 18 23 18 22 20 14 18 21 15 19 18 13 17 20 15 19 11 9 14 34 32 37 14 13 19 68 67 73 24 23 29 14 13 19 28 27 32 20 19 24 22 20 23 20 18 21 25 23 26 20 18 21 23 22 27 23 22 27 22 21 26 22 21 26 22 21 29 22 21 29 22 20 31 22 20 31 24 22 33 24 22 33 24 22 33 25 23 34 24 22 33 23 21 32 21 20 28 21 20 28 20 18 31 21 19 32 22 20 33 22 20 33 21 19 32 21 19 32 22 20 33 22 20 33 22 20 33 21 19 32 20 18 31 20 18 31 19 17 30 19 17 30 18 16 29 17 15 28 16 15 29 16 15 29 17 15 29 17 14 25 18 13 19 15 13 16 13 14 18 10 14 26 6 16 41 22 36 73 127 148 193 117 143 194 114 145 199 115 147 206 106 140 204 116 151 217 207 167 142 197 159 136 194 159 140 170 138 125 135 108 101 38 17 14 27 11 11 20 8 10 19 13 15 18 14 15 16 14 17 15 15 17 15 14 19 15 14 19 16 13 20 16 14 19 14 13 18 14 14 16 15 15 17 15 15 17 16 16 18 15 15 17 14 14 16 14 14 16 14 14 16 14 14 16 14 14 16 14 14 16 14 14 16 13 13 15 13 13 15 13 13 15 12 12 14 13 13 15 13 13 15 13 13 15 12 11 16 12 11 16 12 11 16 13 12 17 13 12 17 13 12 17 14 13 18 13 12 17 13 12 18 13 12 18 15 14 20 16 15 21 12 11 17 29 28 34 68 67 73 239 238 244 118 117 123 19 18 24 12 11 16 12 11 16 16 15 20 11 10 15 21 21 23 19 19 21 11 9 12 17 15 18 19 17 20 15 13 16 22 17 21 24 19 23 26 21 25 20 15 19 31 29 34 10 8 13 21 20 26 25 24 30 28 27 33 16 15 21 32 31 36 23 22 27 20 20 22 22 22 24 23 21 24 21 19 22 22 21 26 22 21 26 22 21 26 22 21 26 22 21 29 22 21 29 22 20 31 22 20 31 23 21 32 24 22 33 24 22 33 24 22 33 23 21 32 22 20 31 20 19 27 19 18 26 21 19 32 22 20 33 23 21 34 22 20 33 21 19 32 21 19 32 23 21 34 24 22 35 22 20 33 21 19 32 20 18 31 19 17 30 20 18 31 19 17 30 18 16 29 17 15 28 14 13 27 15 14 28 17 15 29 16 14 25 16 14 19 15 13 16 13 14 18 10 14 23 10 17 36 2 16 45 102 121 161 120 144 190 117 147 199 113 145 204 107 140 207 116 151 219 213 169 144 198 158 133 195 157 138 186 153 138 143 114 106 37 13 9 35 17 17 15 3 3 18 12 14 15 13 14 15 13 16 14 14 16 14 13 18 14 13 18 15 12 19 15 13 18 13 12 17 13 13 15 14 14 16 15 15 17 15 15 17 15 15 17 14 14 16 13 13 15 13 13 15 13 13 15 14 14 16 14 14 16 14 14 16 14 14 16 13 13 15 12 12 14 11 11 13 12 12 14 13 13 15 12 12 14 12 11 16 12 11 16 13 12 17 14 13 18 11 10 15 12 11 16 12 11 16 13 12 17 13 12 18 15 14 20 17 16 22 19 18 24 22 21 27 11 10 16 33 32 38 106 105 111 16 15 21 20 19 25 19 18 23 11 10 15 15 14 19 13 12 17 17 17 19 14 14 16 13 11 14 15 13 16 14 12 15 21 19 22 20 15 19 20 15 19 25 20 24 21 19 22 13 11 16 31 29 34 21 20 26 24 23 29 19 18 24 23 22 28 21 20 25 22 21 26 15 14 19 23 23 25 18 16 19 22 20 23 20 19 24 20 19 24 21 20 25 21 20 25 21 20 28 21 20 28 22 20 31 22 20 31 25 23 34 25 23 34 25 23 34 24 22 33 23 21 32 20 18 29 18 17 25 17 16 24 18 16 27 19 17 30 20 18 31 20 18 31 18 16 29 18 16 29 20 18 31 21 19 32 19 17 30 18 16 29 18 16 29 18 16 29 19 17 30 19 17 30 19 17 30 18 16 29 13 12 26 14 13 27 16 14 27 16 15 23 16 14 19 15 13 16 14 13 18 11 14 21 5 11 25 7 18 40 57 73 106 123 146 188 116 144 194 111 141 201 116 149 216 112 146 217 216 170 144 197 155 130 201 160 140 182 146 130 147 119 108 48 24 20 25 7 7 24 12 12 17 11 13 14 12 13 13 11 14 13 13 15 13 12 17 15 14 19 17 14 21 18 16 21 14 13 18 13 13 15 13 13 15 13 13 15 13 13 15 14 14 16 14 14 16 15 15 17 15 15 17 14 14 16 13 13 15 13 13 15 14 14 16 14 14 16 13 13 15 12 12 14 13 13 15 13 13 15 12 12 14 12 12 14 12 11 16 12 11 16 13 12 17 13 12 17 15 14 19 15 14 19 14 13 18 13 12 17 13 12 18 14 13 19 15 14 20 17 16 22 16 16 24 16 16 24 27 28 33 14 15 20 15 16 21 24 25 30 11 10 15 17 16 21 24 23 28 19 18 23 22 20 23 18 16 19 25 23 26 13 11 14 23 21 22 41 39 40 33 28 32 38 33 37 45 43 48 22 20 25 21 18 25 19 18 24 20 19 25 24 23 29 20 21 26 19 20 25 20 19 25 21 20 25 23 22 27 23 22 27 23 21 24 22 20 23 22 21 26 22 21 26 22 21 26 22 21 26 22 21 29 23 22 30 23 21 32 24 22 33 24 22 33 23 21 32 22 20 31 23 21 32 24 22 33 24 22 33 23 22 30 22 21 29 20 18 29 20 18 29 19 17 28 17 15 26 17 15 26 18 16 27 21 19 30 23 21 32 22 20 31 20 18 29 19 17 28 18 16 27 18 16 27 19 17 28 19 17 28 18 16 29 14 13 27 14 13 27 15 13 24 15 14 22 16 14 19 16 14 19 16 15 20 15 16 21 13 17 28 7 16 33 22 36 63 126 146 183 120 146 195 113 143 203 116 149 216 109 146 216 217 172 143 202 158 131 200 159 139 182 146 130 150 120 110 43 20 14 23 5 5 21 11 12 17 11 13 14 12 13 13 13 15 14 14 16 14 13 18 14 13 18 15 12 19 15 13 18 14 13 18 14 14 16 14 14 16 13 13 15 14 14 16 14 14 16 15 15 17 15 15 17 14 14 16 13 13 15 13 13 15 13 13 15 14 14 16 14 14 16 13 13 15 12 12 14 13 13 15 13 13 15 13 13 15 12 12 14 12 11 16 13 12 17 13 12 17 13 12 17 14 13 18 14 13 18 14 13 18 13 12 17 12 11 17 12 11 17 14 13 19 16 15 21 17 17 25 16 16 24 24 25 30 16 17 22 10 11 16 12 13 18 9 8 13 19 18 23 13 12 17 16 15 20 15 13 16 129 127 130 171 169 172 200 198 201 216 214 215 206 204 205 214 209 213 204 199 203 185 183 188 158 156 161 29 28 34 17 16 22 20 19 25 17 16 22 18 19 24 18 19 24 19 18 24 20 19 25 22 21 26 23 22 27 23 21 24 22 20 23 21 20 25 20 19 24 19 18 23 18 17 22 18 17 25 18 17 25 20 18 29 20 18 29 21 19 30 21 19 30 21 19 30 23 21 32 25 23 34 25 23 34 24 23 31 22 21 29 20 18 29 20 18 29 19 17 28 17 15 26 17 15 26 18 16 27 21 19 30 23 21 32 23 21 32 21 19 30 19 17 28 18 16 27 18 16 27 18 16 27 17 15 26 17 15 28 15 14 28 15 15 27 15 13 24 15 14 20 15 12 19 15 12 19 14 13 19 14 13 19 10 13 20 6 12 24 12 23 45 107 123 157 119 141 191 116 145 205 114 147 214 112 149 219 215 170 141 204 160 133 196 155 135 181 145 129 150 122 111 35 15 8 22 6 6 20 10 11 17 11 13 15 13 16 14 14 16 14 15 17 14 13 18 13 12 17 13 10 17 12 10 15 14 13 18 14 14 16 14 14 16 14 14 16 14 14 16 15 15 17 15 15 17 15 15 17 14 14 16 13 13 15 12 12 14 12 12 14 13 13 15 14 14 16 14 14 16 13 13 15 14 14 16 14 14 16 13 13 15 13 13 15 13 12 17 13 12 17 14 13 18 14 13 18 14 13 18 14 13 18 14 13 18 13 12 17 12 11 17 12 11 17 14 13 19 15 14 20 12 12 20 15 18 25 21 21 29 17 17 25 16 15 21 24 23 29 26 24 29 17 15 20 26 24 29 22 20 25 105 103 106 205 203 206 241 239 240 253 251 252 255 254 255 255 254 255 255 250 254 255 250 254 242 240 245 223 221 226 91 90 96 26 25 31 16 17 22 14 15 20 16 17 22 16 17 22 17 18 23 18 19 24 21 20 25 22 21 26 22 22 24 21 21 23 21 20 25 20 19 24 18 17 22 16 15 20 15 14 22 16 15 23 17 15 26 18 16 27 19 17 28 20 18 29 21 19 30 24 22 33 25 23 34 25 23 34 23 22 30 21 20 28 20 18 29 20 18 29 19 17 28 17 15 26 17 15 26 18 16 27 20 18 29 22 20 31 23 21 32 21 19 30 19 17 28 18 16 27 17 15 26 17 15 26 16 14 25 15 13 24 16 16 28 16 16 26 15 15 23 14 15 20 14 13 21 13 12 20 14 11 20 13 12 18 11 10 15 7 12 18 2 11 28 74 89 120 119 139 189 120 146 205 111 145 209 114 151 219 212 167 138 205 161 136 193 152 132 181 145 129 147 119 108 31 10 5 25 9 9 20 11 12 16 12 13 14 14 16 13 14 16 13 14 16 13 12 17 13 12 17 13 10 17 12 10 15 14 14 16 14 14 16 14 14 16 14 14 16 14 14 16 15 15 17 15 15 17 15 15 17 13 13 15 12 12 14 12 12 14 12 12 14 13 13 15 14 14 16 14 14 16 13 13 15 14 14 16 14 14 16 14 14 16 14 14 16 14 13 18 14 13 18 14 13 18 14 13 18 15 14 19 16 15 20 15 14 19 14 13 18 13 12 18 13 12 18 14 13 19 14 15 20 15 15 23 16 19 26 16 16 24 17 17 25 17 16 22 21 20 26 27 25 30 14 12 17 18 16 21 29 27 32 176 174 177 222 220 223 255 254 255 255 254 255 249 247 248 255 254 255 253 248 252 252 247 251 237 235 240 222 220 225 116 115 121 25 24 30 14 15 20 20 21 26 16 17 22 16 17 22 17 18 23 18 19 24 21 20 25 21 20 25 22 22 24 22 22 24 22 21 26 21 20 25 19 18 23 17 16 21 17 16 24 17 16 24 18 16 27 18 16 27 19 17 28 21 19 30 22 20 31 24 22 33 24 22 33 23 21 32 20 19 27 18 17 25 19 17 28 19 17 28 18 16 27 17 15 26 16 14 25 16 14 25 18 16 27 20 18 29 21 19 30 20 18 29 18 16 27 17 15 26 17 15 26 17 15 26 16 14 25 15 13 24 16 16 26 15 15 23 14 15 19 13 14 18 13 12 20 13 11 22 13 9 23 13 10 19 15 13 16 11 12 16 2 10 23 43 57 84 125 143 191 121 147 206 111 145 209 113 151 216 212 167 138 206 162 137 191 153 132 180 147 132 134 107 98 27 8 2 25 11 10 21 12 13 17 13 14 14 14 16 12 13 15 11 12 14 12 11 16 13 12 17 14 12 17 14 12 17 13 13 15 13 13 15 13 13 15 14 14 16 14 14 16 14 14 16 14 14 16 14 14 16 14 14 16 13 13 15 12 12 14 12 12 14 13 13 15 13 13 15 14 14 16 13 13 15 14 14 16 14 14 16 14 14 16 14 14 16 14 13 18 14 13 18 14 13 18 14 13 18 15 14 19 15 14 19 15 14 19 15 14 19 13 12 18 13 12 18 14 13 19 14 15 20 17 17 25 12 15 22 13 13 21 23 23 31 23 22 28 17 16 22 25 23 28 31 26 32 24 19 25 105 100 106 205 200 204 252 247 251 255 254 255 255 253 254 255 254 255 253 251 252 255 253 255 255 250 255 239 237 242 226 224 229 64 63 69 18 17 23 18 18 26 16 16 24 17 17 25 18 18 26 19 20 25 20 21 26 21 20 25 22 21 26 22 21 26 23 22 27 21 20 25 21 20 25 21 20 25 21 20 25 21 20 28 20 19 27 20 18 29 20 18 29 22 20 31 23 21 32 24 22 33 24 22 33 22 20 31 19 17 28 16 15 23 15 14 22 19 17 28 19 17 28 18 16 27 16 14 25 15 13 24 15 13 24 17 15 26 18 16 27 20 18 29 18 16 27 17 15 26 17 15 26 17 15 26 17 15 26 16 14 25 15 13 24 14 14 22 14 15 20 13 14 16 13 14 16 13 11 22 13 11 24 14 10 25 16 10 20 18 14 15 12 12 14 10 14 25 21 31 58 127 145 191 121 146 203 113 147 210 111 149 212 213 168 139 203 161 136 193 155 134 181 148 133 115 88 79 26 7 3 24 10 10 19 10 13 15 13 16 14 14 16 12 13 15 11 12 14 12 11 16 13 12 17 15 13 18 16 14 19 13 13 15 13 13 15 13 13 15 14 14 16 14 14 16 14 14 16 14 14 16 14 14 16 17 17 19 15 15 17 13 13 15 12 12 14 13 13 15 13 13 15 13 13 15 13 13 15 14 14 16 14 14 16 14 14 16 14 14 16 14 13 18 14 13 18 14 13 18 14 13 18 13 12 17 14 13 18 14 13 18 14 13 18 13 12 18 13 12 18 13 12 18 13 14 19 12 12 20 14 17 24 17 17 25 18 18 26 27 26 32 27 24 31 22 17 23 22 17 23 55 50 56 166 161 167 225 220 224 255 253 255 255 251 252 252 248 249 255 254 255 255 253 254 252 247 251 242 237 243 231 229 234 172 170 175 22 21 27 19 18 24 26 26 34 13 13 21 19 19 27 20 20 28 21 22 27 21 22 27 22 21 26 22 21 26 22 21 26 23 22 27 21 20 25 21 20 25 22 21 26 23 22 27 23 22 30 22 21 29 22 20 31 21 19 30 25 23 34 25 23 34 24 22 33 22 20 31 19 17 28 16 14 25 14 13 21 14 13 21 19 17 28 19 17 28 18 16 27 17 15 26 15 13 24 15 13 24 17 15 26 18 16 27 18 16 27 17 15 26 17 15 26 17 15 26 17 15 26 17 15 26 16 14 25 15 14 22 13 14 19 13 14 18 12 14 13 12 13 15 13 11 22 13 11 25 16 9 25 16 10 22 17 13 12 11 10 8 12 15 24 7 17 42 118 135 179 122 147 204 115 149 210 111 149 211 211 167 140 200 158 133 194 156 135 180 148 133 96 69 62 27 8 4 21 9 9 17 11 13 15 13 16 14 13 18 13 14 18 13 14 18 13 12 17 14 13 18 15 13 18 15 13 18 13 13 15 13 13 15 14 14 16 14 14 16 15 15 17 14 14 16 14 14 16 14 14 16 19 19 21 17 17 19 15 15 17 13 13 15 13 13 15 13 13 15 12 12 14 12 12 14 13 13 15 13 13 15 14 14 16 14 14 16 14 13 18 14 13 18 13 12 17 13 12 17 13 12 17 13 12 17 14 13 18 14 13 18 13 12 18 13 12 18 14 13 19 13 14 19 14 14 22 17 20 29 21 21 29 13 13 21 20 19 25 21 18 25 19 14 21 45 40 46 152 145 152 210 204 208 252 246 250 255 250 254 255 254 255 255 254 255 255 254 253 253 249 250 255 254 255 236 234 239 210 208 213 76 74 79 21 20 26 22 21 27 23 23 31 21 21 29 21 21 29 22 22 30 23 24 29 22 23 28 22 21 26 21 20 25 21 20 25 22 21 26 23 22 27 23 22 27 23 22 27 23 22 27 23 22 30 23 22 30 23 21 32 23 21 32 25 23 34 25 23 34 23 21 32 20 18 29 16 14 25 15 13 24 15 14 22 16 15 23 21 19 30 20 18 29 20 18 29 18 16 27 17 15 26 16 14 25 17 15 26 18 16 27 18 16 27 18 16 27 17 15 26 16 14 25 16 14 25 16 14 25 15 13 24 13 12 20 14 13 19 14 14 16 12 14 11 12 13 15 13 11 22 13 10 27 16 9 27 16 10 22 18 12 12 13 12 10 10 13 22 6 14 37 100 114 159 123 148 204 114 149 207 113 152 211 210 165 136 196 154 129 194 156 135 180 148 133 82 57 50 27 9 7 21 11 12 19 13 17 15 13 18 14 13 18 15 14 19 15 14 19 15 14 19 14 13 18 13 12 17 12 11 16 13 13 15 14 14 14 14 14 16 15 15 15 15 15 17 15 15 15 15 15 17 14 14 14 20 20 22 18 18 20 15 15 17 14 14 16 13 13 15 12 12 14 12 12 14 11 11 13 13 13 15 13 13 15 14 14 16 14 14 16 14 13 18 14 13 18 13 12 17 13 12 17 13 12 17 14 13 18 15 14 19 15 14 19 14 13 19 14 13 19 15 14 20 16 15 21 17 17 25 9 9 17 20 20 28 26 26 34 27 26 34 16 15 21 48 45 52 149 144 151 208 203 209 237 231 235 255 251 255 255 253 255 251 247 248 255 252 253 255 251 252 255 254 255 246 239 246 211 201 209 179 172 179 24 19 25 27 24 31 29 28 34 16 16 24 23 26 33 20 23 30 23 24 29 24 25 30 23 24 28 22 21 26 21 21 23 21 21 23 22 22 24 26 25 30 26 25 30 25 24 29 24 23 28 23 24 29 23 23 31 24 22 33 25 23 34 24 22 33 24 22 33 24 18 30 19 16 25 15 13 24 13 13 21 17 14 23 19 16 25 23 20 29 23 20 31 21 19 30 19 17 28 17 17 27 16 16 26 17 17 27 18 18 28 18 18 28 17 17 27 16 16 26 16 14 25 17 14 23 16 13 22 13 12 20 12 11 19 14 13 19 14 13 18 13 13 13 13 13 15 12 10 21 12 10 24 13 9 26 13 9 23 19 14 18 17 15 18 10 10 20 10 16 40 85 98 142 126 149 203 114 146 205 114 152 214 206 157 127 203 157 131 194 156 135 181 152 138 68 45 39 22 8 8 22 13 16 13 8 14 17 15 20 16 14 19 15 13 16 14 12 15 14 12 15 13 12 17 13 12 17 14 13 18 11 11 11 10 10 8 19 19 19 5 5 3 24 24 24 16 16 14 10 10 10 17 17 15 16 16 16 12 12 12 13 11 12 20 18 19 9 7 8 15 13 14 15 13 14 11 9 10 9 7 10 23 21 24 16 14 17 13 11 14 14 12 17 15 13 18 19 17 22 13 11 16 17 16 21 17 16 21 16 15 20 15 14 19 14 13 19 14 13 19 15 14 20 16 15 21 20 19 25 12 11 17 25 25 33 23 23 31 24 24 32 21 21 29 153 152 160 193 192 198 231 226 232 255 250 254 253 247 249 255 253 255 255 253 255 255 252 255 252 250 255 253 246 253 222 205 215 202 182 193 72 56 66 33 23 31 29 26 33 22 23 28 16 19 24 22 27 31 24 29 33 22 26 29 22 23 27 23 23 25 22 20 23 19 17 18 19 17 18 22 20 21 24 24 26 15 16 18 25 24 29 20 21 25 17 20 25 22 25 30 20 19 27 19 18 26 22 22 30 17 16 24 27 15 27 17 7 16 22 22 30 11 14 19 22 17 24 23 16 24 24 17 25 17 11 21 21 18 29 15 13 24 16 21 27 18 23 29 15 20 26 16 19 26 17 20 27 14 17 24 14 17 26 16 15 23 19 14 21 19 14 20 13 10 17 14 13 19 15 15 23 14 15 20 16 14 19 15 13 18 15 12 19 14 12 23 13 12 26 11 13 25 16 16 26 11 11 21 13 12 26 14 16 39 70 79 118 128 148 199 123 154 218 113 150 218 210 159 128 202 157 128 192 154 133 181 152 138 55 34 29 19 7 7 20 14 18 15 10 16 16 14 19 16 14 17 17 12 16 16 12 13 14 12 15 13 13 15 13 12 18 13 14 18 22 22 22 10 9 7 13 12 10 27 26 24 12 11 9 12 11 9 32 31 29 13 12 10 18 17 15 17 16 14 19 15 16 25 21 22 13 9 10 18 14 15 19 15 16 19 15 16 14 9 13 9 7 10 13 11 14 15 13 16 23 21 26 24 22 27 5 3 8 25 23 28 16 15 20 16 15 20 16 15 20 14 13 18 13 12 18 13 12 18 14 13 19 15 14 20 15 13 18 20 19 25 18 17 25 17 17 25 21 24 33 30 33 42 127 127 135 196 195 201 225 220 226 255 253 255 255 253 255 255 251 253 255 252 255 255 253 255 244 242 247 219 212 220 168 152 163 125 107 119 43 30 40 24 17 25 24 21 28 25 26 31 16 21 27 20 25 29 23 26 31 23 24 28 22 21 26 24 22 25 23 21 24 20 18 19 20 18 19 22 20 21 24 22 27 19 16 23 24 21 28 30 27 34 25 26 31 22 23 28 28 25 32 29 24 31 26 18 29 28 15 25 29 9 21 27 7 19 14 4 15 21 11 22 29 13 24 31 13 25 37 19 31 23 9 22 30 27 36 8 11 18 8 17 22 7 16 21 15 18 25 19 18 26 17 17 25 13 13 21 13 13 21 15 14 22 21 14 22 22 15 22 16 14 19 15 16 21 12 15 22 14 15 20 15 13 18 17 12 18 14 11 18 14 13 21 11 13 25 10 14 26 13 15 27 11 13 25 15 13 27 13 14 35 58 66 102 131 149 197 123 153 217 115 152 222 212 163 133 199 153 127 189 151 132 179 151 139 39 20 14 18 6 6 20 14 18 16 14 19 15 13 18 14 12 15 16 11 15 16 12 13 14 12 15 13 13 15 13 12 18 13 12 17 9 7 8 17 13 12 134 130 129 141 137 136 143 139 140 125 121 122 114 110 111 95 91 92 87 83 84 75 71 72 57 51 53 45 39 41 24 18 22 22 16 20 17 11 15 14 8 12 23 17 21 19 14 18 22 17 21 18 13 17 11 6 12 24 19 25 10 8 13 15 13 18 16 14 19 16 14 19 15 14 19 14 13 18 13 12 18 12 11 17 13 12 18 14 13 19 13 10 17 25 24 30 11 10 18 16 16 24 17 20 29 27 30 39 76 76 84 184 183 189 220 215 221 246 240 244 255 246 249 255 252 255 255 252 255 251 245 249 214 207 214 153 148 155 116 111 118 51 45 55 23 20 29 23 22 30 22 22 30 27 30 37 19 22 31 22 22 30 24 23 31 24 21 30 26 20 30 26 21 28 26 21 27 22 20 23 21 19 22 22 20 25 23 17 27 31 23 36 26 15 29 27 16 30 23 17 27 23 18 25 23 18 25 23 10 19 35 7 22 46 9 27 44 10 27 46 13 32 34 0 21 44 9 31 43 8 32 41 6 28 35 0 20 38 11 28 20 17 24 12 22 24 13 28 33 15 24 31 17 11 21 22 10 22 25 14 28 21 13 24 17 14 21 18 15 22 20 12 23 16 8 19 11 10 15 9 13 16 10 13 18 12 13 18 14 12 17 16 11 17 14 11 18 14 13 21 11 13 25 10 14 26 13 15 27 14 16 28 16 14 28 13 14 35 41 49 85 134 152 200 122 152 214 120 155 223 211 162 132 196 152 125 188 151 132 174 146 134 29 10 4 19 9 8 19 14 18 16 14 19 13 11 16 14 12 15 16 12 13 17 13 14 15 13 16 13 13 15 13 12 18 13 12 17 32 28 29 13 7 7 140 131 132 193 184 185 255 252 255 255 252 255 251 242 245 150 141 144 153 144 147 160 151 154 167 158 161 186 175 179 190 179 185 193 182 188 177 166 172 163 154 159 140 131 136 132 126 130 104 98 102 81 76 80 18 13 19 6 1 7 28 23 29 18 16 21 16 14 19 16 14 19 15 14 19 14 13 18 13 12 18 13 12 18 13 12 18 14 13 19 15 12 19 20 19 25 11 11 19 22 22 30 17 20 29 19 19 29 31 30 38 153 150 157 198 191 198 241 232 237 255 251 255 255 247 251 248 237 243 224 215 220 163 153 161 105 100 106 84 84 92 22 25 34 22 25 34 24 27 36 22 24 36 24 24 34 23 21 34 22 20 31 23 19 33 25 19 31 26 20 32 27 21 31 25 22 29 22 21 27 20 21 26 21 20 28 18 11 27 32 23 42 31 18 36 30 17 34 29 21 32 26 19 27 30 24 28 91 68 76 97 38 58 115 39 65 117 43 68 116 43 70 117 42 72 116 41 71 115 40 71 117 42 75 120 46 81 147 94 120 26 17 22 7 22 19 5 19 22 13 20 28 16 6 15 30 14 25 21 8 18 20 10 19 16 11 15 19 17 22 18 15 26 12 10 21 14 15 17 14 18 19 9 12 17 11 12 17 14 12 17 16 11 15 14 12 17 14 13 21 11 13 25 11 15 26 12 14 26 15 17 29 16 14 27 11 12 32 25 34 67 133 150 196 121 150 210 119 154 220 206 159 131 195 151 126 190 153 135 159 133 120 26 9 2 21 11 10 17 12 16 14 12 17 13 11 14 14 12 15 16 12 13 17 13 14 15 13 16 13 13 15 13 12 18 13 12 17 14 8 12 38 29 32 150 139 143 204 193 197 255 246 252 255 249 255 217 206 212 130 119 125 154 143 149 159 148 154 158 147 153 169 156 163 175 162 171 190 177 186 191 178 187 194 181 190 186 175 181 185 176 181 175 166 171 175 169 173 101 94 101 21 16 22 9 4 10 12 7 13 16 14 19 16 14 19 16 15 20 15 14 19 14 13 19 14 13 19 14 15 20 14 15 20 16 15 23 13 12 20 17 17 27 24 24 34 23 23 35 22 22 32 19 18 26 103 98 105 187 177 185 226 215 221 255 240 245 246 231 234 223 208 213 162 150 154 115 102 109 126 119 126 46 49 58 14 21 31 18 25 35 19 23 34 24 23 37 16 14 27 23 19 34 25 19 33 24 17 33 25 19 33 26 20 34 25 22 33 24 22 33 20 23 30 18 23 29 17 21 30 30 29 45 20 15 35 19 10 29 24 16 31 34 26 37 20 14 18 24 15 16 166 129 136 150 52 75 177 46 78 176 38 72 174 39 72 174 49 81 173 48 80 180 41 80 190 53 97 172 45 98 233 147 186 44 24 26 10 23 13 14 21 27 19 19 29 24 15 20 26 14 18 26 17 20 23 17 17 17 9 6 18 17 15 10 17 27 0 10 20 8 14 14 8 12 11 9 13 16 12 13 18 14 12 17 17 12 16 15 13 18 15 14 20 12 15 24 11 15 26 10 13 22 13 16 25 14 12 23 9 10 28 16 23 52 120 137 180 119 148 206 116 150 214 204 157 131 194 152 128 191 156 137 135 108 97 28 10 6 22 14 12 16 11 15 14 12 17 15 13 16 14 12 15 16 12 13 16 12 13 14 12 15 13 13 15 13 12 17 13 12 17 13 4 9 50 39 43 176 165 169 194 183 187 222 209 216 235 222 229 211 198 205 170 157 164 152 139 146 174 161 168 184 171 178 192 179 186 190 174 184 193 177 187 189 173 183 194 178 188 191 178 185 181 170 176 177 166 172 181 172 177 160 150 158 83 76 83 23 16 23 17 12 18 17 12 18 16 14 19 17 15 20 16 15 20 15 14 20 15 14 20 15 16 21 16 17 22 19 18 26 13 12 20 19 19 29 17 17 27 21 21 33 28 26 37 23 20 31 46 41 48 185 175 183 202 190 194 235 218 224 230 214 217 180 163 169 140 125 130 150 135 142 143 133 141 19 22 31 15 21 33 19 23 35 20 19 33 26 24 38 17 13 28 26 17 34 26 17 34 25 18 34 26 20 34 25 21 35 22 22 32 20 23 32 19 24 30 16 23 29 15 22 30 14 18 29 21 20 34 37 26 40 25 13 25 24 17 25 28 19 24 32 16 19 184 138 149 150 54 81 170 46 80 178 44 81 178 44 81 176 48 83 177 47 85 185 44 86 184 47 93 177 56 110 229 147 185 57 36 33 20 22 9 25 14 22 26 2 16 50 9 17 44 0 4 34 0 1 33 9 5 25 11 0 27 24 15 16 20 31 2 8 22 14 15 17 15 15 13 12 13 17 12 13 17 15 13 16 18 13 17 16 14 19 16 15 21 13 16 25 12 16 25 13 16 25 16 16 24 18 17 25 12 14 29 13 20 48 104 119 160 123 149 206 118 152 215 202 156 132 197 155 133 191 155 139 105 81 69 28 13 8 22 13 14 15 10 14 14 13 18 16 14 17 16 14 17 17 13 14 16 12 11 14 12 13 13 13 15 13 12 17 14 13 18 28 19 24 66 55 61 179 168 174 219 208 214 214 203 209 201 190 196 231 218 227 158 145 154 148 135 144 179 166 175 197 184 193 209 196 205 208 195 204 209 196 205 203 187 198 209 193 203 206 193 200 199 188 194 195 184 190 187 178 183 197 187 195 156 149 156 86 79 86 11 6 12 16 11 17 16 14 19 17 15 20 17 15 20 16 15 21 16 15 21 16 17 22 17 18 23 19 18 26 17 16 24 17 17 27 17 17 27 19 19 31 23 21 32 26 23 34 21 14 22 141 130 138 207 195 199 229 212 218 197 178 182 148 129 135 167 150 156 205 188 196 86 75 83 20 17 28 21 19 32 25 21 35 23 17 31 28 19 36 26 17 34 26 17 34 25 18 34 24 20 34 25 23 36 24 24 36 20 23 32 18 22 31 17 24 30 16 23 29 14 22 24 18 28 27 19 19 19 31 12 18 43 20 28 100 89 95 167 151 161 127 93 109 142 94 116 133 79 105 119 63 92 158 99 131 140 75 109 152 74 114 143 57 102 172 85 130 130 53 97 162 107 147 162 128 152 106 87 80 142 122 111 132 90 102 138 69 90 148 45 62 145 35 46 137 46 55 145 81 79 129 104 82 112 105 89 71 58 75 23 9 32 21 8 15 22 12 13 14 13 18 14 15 19 17 15 18 19 14 18 18 16 21 16 17 22 12 16 25 12 16 25 15 18 27 16 16 24 23 22 30 16 15 29 12 19 45 82 97 136 125 152 205 124 156 217 202 156 133 198 157 135 189 156 139 86 62 52 28 13 10 19 13 13 13 11 14 16 15 20 17 15 18 16 14 15 17 13 14 16 12 11 14 12 13 14 12 15 13 12 17 14 13 18 19 13 17 82 73 78 135 126 131 180 171 176 232 221 227 225 214 220 156 145 153 129 118 126 142 131 139 161 150 158 163 152 160 168 157 165 171 160 168 181 168 177 179 166 176 188 175 184 187 174 183 183 170 177 179 168 174 175 164 170 178 168 176 171 161 169 157 150 157 38 31 38 16 11 17 17 12 18 16 14 19 17 15 20 16 15 21 16 15 21 16 17 22 17 18 23 15 14 22 18 17 25 13 13 23 25 25 35 22 22 34 16 14 25 29 26 37 29 22 30 80 69 77 206 191 196 199 182 188 168 149 153 151 132 138 152 133 139 167 150 158 25 12 21 26 18 29 17 11 23 24 16 31 20 12 27 21 13 28 29 21 36 23 17 31 21 17 31 24 22 35 25 25 35 22 25 34 20 23 30 19 22 29 22 23 28 22 21 27 21 19 20 21 17 8 39 20 14 72 30 34 114 67 77 190 154 166 255 235 253 214 155 183 144 87 119 163 124 153 117 91 118 184 164 191 130 104 133 160 114 151 134 79 118 198 146 184 123 83 118 192 177 208 114 106 121 125 102 94 225 182 173 184 113 127 199 95 118 186 43 61 204 50 62 175 39 49 207 105 103 204 154 129 177 151 134 103 76 93 27 3 29 19 2 10 25 15 16 16 14 19 15 16 20 17 15 18 18 16 19 18 16 21 16 17 22 13 17 26 10 17 25 13 16 23 14 15 20 23 22 28 14 14 26 8 16 39 63 79 115 124 150 201 125 157 214 206 161 140 191 153 132 190 158 143 56 34 23 25 11 8 22 16 16 14 12 15 11 12 16 12 12 14 14 12 13 16 12 13 16 12 11 15 11 12 13 11 14 13 12 17 14 13 18 20 15 19 57 51 55 98 91 98 117 110 117 117 107 115 117 107 115 131 121 129 148 138 146 149 139 147 154 144 152 160 150 159 165 155 164 169 159 168 174 162 172 180 168 178 184 173 181 175 162 171 178 165 172 171 160 166 171 160 166 169 159 167 164 154 162 159 152 159 37 30 37 15 10 16 16 11 17 15 13 18 16 14 19 15 14 20 14 13 19 12 13 18 11 12 17 17 16 22 17 16 24 16 16 26 16 16 26 17 17 29 19 17 28 20 17 28 24 17 25 23 12 20 190 175 180 186 169 175 127 108 112 91 72 78 156 137 143 53 36 44 23 10 19 26 16 27 22 14 25 19 11 24 20 12 25 21 15 27 22 19 30 22 20 31 21 21 31 25 28 37 18 23 29 16 19 26 22 21 27 27 22 29 28 17 25 31 15 25 41 16 20 52 11 7 89 30 26 135 52 62 164 75 95 239 160 182 255 227 255 231 146 185 153 78 117 168 118 153 120 87 116 196 173 199 138 116 139 160 132 155 139 106 127 193 154 175 125 97 119 182 182 206 120 118 132 129 96 89 223 158 152 206 112 126 214 87 108 209 44 58 216 39 47 205 35 44 216 76 75 212 125 105 199 148 131 110 71 89 32 8 32 21 10 18 18 16 17 16 15 20 17 16 21 19 17 20 18 16 19 18 16 21 15 15 23 13 17 26 12 19 27 15 18 25 17 18 23 21 20 26 13 13 25 14 20 42 45 61 95 123 150 197 126 157 212 202 160 138 192 154 135 180 148 135 48 25 17 20 9 5 21 15 15 12 12 14 13 14 18 14 14 16 14 14 14 18 14 13 17 13 12 17 13 14 15 13 14 16 14 19 16 15 20 11 9 12 17 12 16 19 14 20 15 10 16 10 5 11 13 8 14 24 19 25 35 30 36 42 37 43 50 45 51 62 55 63 75 68 76 89 82 90 102 95 103 115 108 116 125 115 123 141 130 136 151 140 146 154 143 149 156 147 152 159 149 157 158 151 158 144 137 144 33 28 34 15 10 16 14 12 17 14 12 17 14 12 17 14 13 19 14 13 19 13 14 19 13 14 19 17 16 22 17 16 22 16 16 24 16 16 26 16 16 28 17 15 26 19 16 25 22 15 23 30 19 27 99 86 93 154 137 143 81 65 68 70 53 59 106 89 97 23 7 17 27 15 25 23 18 25 20 17 24 19 16 25 18 15 24 18 17 25 19 19 27 17 20 27 17 22 28 14 21 27 15 20 24 20 21 26 27 22 28 31 15 25 32 9 19 39 9 21 56 11 16 99 33 21 146 64 50 167 76 73 170 66 75 168 52 75 197 79 113 159 50 91 148 63 102 149 100 130 171 143 168 149 132 151 128 114 131 135 119 132 164 142 155 129 95 109 130 103 118 135 133 155 113 105 120 121 73 71 160 74 73 170 47 68 201 47 71 207 31 42 205 19 24 208 24 32 192 34 33 166 55 38 171 101 89 65 24 40 19 2 21 14 9 15 16 18 17 14 15 19 17 16 22 19 17 22 20 18 23 19 16 23 16 16 24 12 16 27 10 17 25 14 19 25 16 17 22 20 19 24 17 17 27 13 19 41 32 47 80 128 152 200 127 158 212 198 157 137 192 155 137 161 131 120 36 16 9 18 7 5 19 15 16 11 11 13 14 15 19 12 12 14 13 13 13 16 12 11 16 12 11 15 11 12 14 12 13 15 13 18 15 14 19 15 15 17 15 13 16 14 12 15 15 13 16 16 14 17 16 14 17 15 13 18 14 12 17 17 15 20 17 15 20 18 13 19 16 11 17 14 9 15 13 8 14 15 10 16 18 11 18 22 13 18 22 11 17 27 16 22 38 29 34 42 32 40 49 42 49 58 51 58 18 13 19 15 10 16 13 11 16 13 11 16 12 11 16 13 12 18 14 13 19 15 16 21 16 17 22 17 16 21 17 16 22 15 15 23 15 15 23 15 15 25 16 14 25 17 14 23 19 14 21 25 15 23 34 23 29 90 78 82 69 54 59 72 57 64 42 29 36 19 8 16 21 14 22 15 16 21 12 17 20 14 17 22 15 18 23 16 19 24 16 21 25 16 24 27 17 25 28 16 26 28 18 23 26 22 21 26 28 17 23 34 11 21 48 12 24 72 25 41 100 40 42 182 105 77 237 155 115 232 159 124 223 130 112 179 33 46 186 27 57 168 39 70 196 107 135 187 150 167 195 185 196 79 71 84 151 143 154 188 176 186 243 221 233 92 54 67 115 78 96 182 164 188 169 141 163 161 94 103 164 54 65 194 36 69 209 28 61 208 26 41 207 26 33 207 30 38 189 30 34 170 46 38 192 112 105 52 22 30 17 15 28 14 12 17 20 20 22 14 15 20 16 15 21 19 17 22 20 18 23 19 16 23 16 16 24 10 17 27 10 17 27 14 18 27 15 16 21 18 17 22 22 22 32 12 17 37 15 30 61 132 156 202 127 157 209 195 154 136 191 156 137 141 113 101 27 8 1 17 7 5 19 15 16 10 10 12 15 16 18 11 11 13 12 12 10 15 11 10 15 11 8 15 11 12 13 11 12 14 12 17 14 13 18 11 11 13 12 12 14 13 13 15 15 15 17 15 15 17 15 15 17 15 14 19 15 14 19 15 13 18 16 14 19 16 14 19 15 13 18 14 12 17 13 11 16 15 13 18 18 13 19 20 11 16 14 5 10 19 10 15 21 15 19 12 5 12 11 6 12 15 10 16 15 10 16 13 11 16 13 11 16 12 11 16 12 11 16 13 12 18 14 13 19 14 15 20 16 15 21 18 16 21 17 15 20 16 15 21 14 14 22 14 14 24 14 14 24 15 14 22 16 13 20 17 10 17 21 12 17 38 27 31 71 60 64 64 53 59 15 5 13 28 18 27 16 13 20 8 16 19 8 18 19 11 19 21 13 18 21 14 17 22 15 20 24 16 24 27 19 27 30 21 29 31 20 25 28 22 20 25 27 14 21 39 13 24 60 22 35 89 41 57 118 59 61 191 124 95 232 168 124 209 160 119 205 133 109 173 42 50 177 33 58 157 45 69 165 92 112 180 152 164 194 191 198 98 98 106 149 148 154 160 153 161 221 204 212 112 80 91 132 100 115 178 159 181 161 129 150 151 88 99 157 59 72 188 51 81 185 35 64 175 34 43 178 42 44 185 46 51 175 47 48 169 61 58 181 110 106 53 32 37 14 17 24 7 8 12 10 11 15 14 15 20 17 16 24 19 16 23 19 16 23 19 16 25 16 16 26 10 16 28 10 17 27 14 18 27 17 18 23 18 17 23 22 22 32 11 16 36 6 19 51 136 158 205 125 155 207 191 152 135 188 152 136 122 94 83 25 6 0 20 10 8 19 15 16 9 10 12 14 15 17 13 13 15 14 14 12 17 13 12 17 13 10 16 12 13 14 12 13 15 13 18 15 14 19 15 16 18 16 18 17 16 16 18 13 13 15 10 10 12 9 9 11 11 11 13 13 13 15 12 12 14 13 13 15 15 13 18 15 13 18 14 12 17 13 11 16 13 11 16 15 10 16 16 10 14 18 12 16 24 18 22 15 10 14 15 10 16 28 23 29 19 14 20 10 8 13 13 11 16 13 11 16 13 12 17 13 12 17 13 12 18 13 12 18 13 12 18 13 12 18 17 15 20 17 15 20 15 14 20 14 15 20 13 13 21 13 13 21 13 13 21 14 13 19 20 15 21 17 11 15 22 16 20 44 35 40 30 23 30 21 16 22 15 10 17 19 20 25 10 20 22 9 20 22 11 19 22 13 16 21 15 16 21 16 17 22 17 20 25 20 23 28 18 23 27 17 21 24 19 18 23 26 17 22 38 17 26 52 20 31 68 26 40 76 34 38 95 59 45 108 77 56 88 61 42 90 52 43 87 16 24 93 16 34 80 21 39 71 32 50 71 51 63 65 62 71 24 29 35 33 41 44 38 35 42 75 66 71 43 31 35 47 34 41 56 45 59 50 32 46 54 14 23 61 8 16 63 6 15 66 9 15 59 8 4 57 4 0 70 7 2 64 0 0 63 5 3 66 25 23 24 9 12 8 9 13 14 18 21 17 22 25 14 17 24 17 16 24 19 16 23 18 15 22 17 14 23 15 15 25 11 17 29 12 18 30 13 17 26 16 19 24 20 17 24 20 18 29 13 16 35 5 19 48 128 151 195 125 153 203 192 153 136 183 147 133 103 76 65 27 8 2 22 12 10 19 15 16 10 11 13 11 15 16 12 12 14 13 13 11 16 12 11 16 12 9 15 11 10 15 11 12 14 12 15 14 14 16 14 14 16 13 15 14 15 15 17 17 17 19 19 19 21 18 18 20 16 16 18 14 14 16 15 15 17 16 16 18 18 16 21 19 17 22 19 17 22 19 17 22 18 16 21 17 15 20 22 17 21 19 14 18 25 20 24 12 7 11 12 7 13 18 13 19 12 10 15 13 11 16 14 12 17 14 12 17 13 12 17 13 12 17 13 12 18 13 12 18 12 11 17 12 11 16 18 13 17 16 14 17 16 14 19 14 15 20 14 14 22 12 15 22 14 14 22 15 16 21 18 16 21 19 14 18 23 18 22 19 14 18 13 8 14 24 21 28 11 10 18 13 16 23 8 17 22 8 18 20 12 17 21 15 16 21 19 16 23 23 18 25 24 21 30 25 24 30 18 21 26 15 20 24 15 18 23 19 18 23 29 18 26 36 16 25 39 11 23 38 11 18 33 17 17 31 20 16 29 15 14 39 20 22 42 15 24 43 13 25 43 17 30 42 20 33 35 21 34 26 20 30 21 26 32 26 31 37 32 27 34 28 21 29 23 22 27 27 26 31 26 23 30 30 18 28 39 16 24 49 24 30 27 12 15 28 20 18 26 21 15 26 17 12 40 19 18 38 9 11 37 8 10 22 0 3 24 13 17 11 9 12 15 19 20 12 17 20 15 18 25 18 16 27 18 15 24 17 14 23 16 13 24 15 15 27 11 17 29 12 20 31 13 17 26 16 19 26 21 18 25 16 14 25 14 17 36 7 18 48 106 129 173 126 154 204 194 157 139 176 143 128 89 62 51 29 10 4 23 13 12 15 13 14 12 13 15 11 15 16 11 11 13 11 11 9 15 11 10 14 10 7 14 10 9 14 10 11 13 11 14 13 13 15 19 19 21 14 14 14 9 9 9 7 7 7 10 10 10 13 13 13 16 14 17 16 14 17 15 13 16 15 13 16 15 13 16 15 13 16 15 13 16 14 12 15 13 11 14 12 10 13 11 9 12 4 2 5 20 18 21 18 16 19 21 19 24 8 6 11 12 10 15 19 17 22 14 13 18 13 12 17 13 12 17 12 11 16 12 11 17 12 11 17 12 11 17 13 12 17 17 12 16 15 13 16 15 13 18 14 15 20 15 15 23 13 16 23 14 17 22 17 18 23 15 14 19 21 19 24 17 15 18 19 17 20 14 13 18 15 16 21 18 21 28 8 13 19 9 16 22 11 16 22 17 16 24 23 15 26 29 17 29 30 18 30 30 19 33 27 21 31 20 20 28 14 22 25 12 22 24 12 20 22 19 20 24 22 20 23 28 19 24 28 19 24 28 25 32 24 21 30 34 24 35 38 28 37 27 26 32 24 21 28 30 14 24 35 18 28 33 23 32 34 31 38 27 26 34 21 18 27 30 19 33 38 30 43 28 31 40 12 17 23 21 22 26 24 19 25 30 17 27 38 25 35 25 18 26 20 17 24 20 19 27 27 24 33 24 12 24 29 15 28 34 20 33 24 11 21 26 15 21 16 10 12 13 13 13 11 12 16 16 16 24 17 15 26 18 15 24 18 15 24 17 14 25 15 15 27 11 17 29 11 19 30 14 18 29 13 16 23 21 18 25 14 12 23 15 18 37 5 16 46 78 99 142 131 157 206 197 160 142 173 140 125 81 54 43 29 12 5 23 13 12 13 11 12 13 14 18 11 15 16 12 12 14 13 13 11 16 12 11 16 12 9 15 11 10 16 12 13 15 13 16 16 14 17 13 13 15 14 14 14 15 15 15 15 15 15 15 15 15 16 16 16 17 15 18 17 15 18 17 15 18 16 14 17 16 14 17 16 14 17 16 14 17 16 14 17 16 14 17 16 14 17 19 17 20 10 8 11 19 17 20 8 6 9 19 17 22 14 12 17 22 20 25 13 11 16 15 14 19 13 12 17 12 11 16 11 10 15 11 10 16 12 11 17 13 12 18 14 13 18 17 12 16 15 13 14 15 13 18 14 15 19 15 15 23 14 17 24 15 18 23 16 19 24 22 21 26 11 10 15 14 12 15 21 21 23 9 8 14 13 16 21 16 19 28 15 19 28 17 22 28 18 21 28 24 18 28 29 19 30 34 17 33 32 15 31 27 13 28 20 12 25 14 14 22 12 19 25 13 24 26 13 24 26 13 23 24 17 22 25 23 23 25 25 24 30 21 23 35 20 19 35 28 19 36 25 21 35 8 21 27 21 32 34 31 19 29 35 18 28 25 18 25 24 22 27 26 20 30 39 31 42 34 20 37 26 15 31 16 20 32 19 28 35 21 22 26 29 27 30 29 19 30 20 9 23 22 19 30 23 21 34 18 17 33 17 14 33 20 16 33 22 15 33 24 15 32 23 15 28 16 5 13 23 14 17 17 15 16 20 20 22 15 15 25 17 15 26 19 16 27 19 16 25 18 14 28 16 16 28 11 17 31 10 18 29 15 19 30 9 12 19 21 18 25 14 12 23 16 19 38 2 13 43 56 77 120 134 160 209 \ No newline at end of file diff --git a/Tests/images/hopper_bigtiff.tif b/Tests/images/hopper_bigtiff.tif new file mode 100644 index 00000000000..9588a37d80b Binary files /dev/null and b/Tests/images/hopper_bigtiff.tif differ diff --git a/Tests/images/hopper_lzma.tif b/Tests/images/hopper_lzma.tif new file mode 100644 index 00000000000..d7ca089fc40 Binary files /dev/null and b/Tests/images/hopper_lzma.tif differ diff --git a/Tests/images/hopper_palette_chunk_second.fli b/Tests/images/hopper_palette_chunk_second.fli new file mode 100644 index 00000000000..54447de0af7 Binary files /dev/null and b/Tests/images/hopper_palette_chunk_second.fli differ diff --git a/Tests/images/hopper_rle8.bmp b/Tests/images/hopper_rle8.bmp new file mode 100644 index 00000000000..0fff4a0d43d Binary files /dev/null and b/Tests/images/hopper_rle8.bmp differ diff --git a/Tests/images/hopper_rle8_greyscale.bmp b/Tests/images/hopper_rle8_greyscale.bmp new file mode 100644 index 00000000000..ead32ff95a4 Binary files /dev/null and b/Tests/images/hopper_rle8_greyscale.bmp differ diff --git a/Tests/images/hopper_rle8_row_overflow.bmp b/Tests/images/hopper_rle8_row_overflow.bmp new file mode 100644 index 00000000000..d606dc3e41a Binary files /dev/null and b/Tests/images/hopper_rle8_row_overflow.bmp differ diff --git a/Tests/images/hopper_webp.png b/Tests/images/hopper_webp.png new file mode 100644 index 00000000000..94b927ac24a Binary files /dev/null and b/Tests/images/hopper_webp.png differ diff --git a/Tests/images/hopper_webp.tif b/Tests/images/hopper_webp.tif new file mode 100644 index 00000000000..5e398606c34 Binary files /dev/null and b/Tests/images/hopper_webp.tif differ diff --git a/Tests/images/imagedraw/discontiguous_corners_polygon.png b/Tests/images/imagedraw/discontiguous_corners_polygon.png new file mode 100644 index 00000000000..509c42b26e0 Binary files /dev/null and b/Tests/images/imagedraw/discontiguous_corners_polygon.png 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 00000000000..8bbf9397c72 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 00000000000..9bdc53763fe 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 00000000000..6b4c1f37696 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 00000000000..b1b8851670b Binary files /dev/null and b/Tests/images/issue_6194.j2k differ diff --git a/Tests/images/mmap_error.bmp b/Tests/images/mmap_error.bmp new file mode 100644 index 00000000000..04df163d7fe Binary files /dev/null and b/Tests/images/mmap_error.bmp differ diff --git a/Tests/images/multiple_comments.gif b/Tests/images/multiple_comments.gif new file mode 100644 index 00000000000..88b2af800e8 Binary files /dev/null and b/Tests/images/multiple_comments.gif differ diff --git a/Tests/images/no_palette.gif b/Tests/images/no_palette.gif new file mode 100644 index 00000000000..0432ebcb61c Binary files /dev/null and b/Tests/images/no_palette.gif differ diff --git a/Tests/images/no_palette_after_rgb.gif b/Tests/images/no_palette_after_rgb.gif new file mode 100644 index 00000000000..8704c464cc4 Binary files /dev/null and b/Tests/images/no_palette_after_rgb.gif differ diff --git a/Tests/images/no_palette_with_background.gif b/Tests/images/no_palette_with_background.gif new file mode 100644 index 00000000000..e49e5d461aa Binary files /dev/null and b/Tests/images/no_palette_with_background.gif differ diff --git a/Tests/images/no_palette_with_transparency.gif b/Tests/images/no_palette_with_transparency.gif new file mode 100644 index 00000000000..031bdcfce10 Binary files /dev/null and b/Tests/images/no_palette_with_transparency.gif differ diff --git a/Tests/images/oom-225817ca0f8c663be7ab4b9e717b02c661e66834.tif b/Tests/images/oom-225817ca0f8c663be7ab4b9e717b02c661e66834.tif new file mode 100644 index 00000000000..01dca594f53 Binary files /dev/null and b/Tests/images/oom-225817ca0f8c663be7ab4b9e717b02c661e66834.tif differ diff --git a/Tests/images/palette_negative.png b/Tests/images/palette_negative.png index 938a7285fd7..7fcfd29a0db 100644 Binary files a/Tests/images/palette_negative.png and b/Tests/images/palette_negative.png differ diff --git a/Tests/images/palette_not_needed_for_second_frame.gif b/Tests/images/palette_not_needed_for_second_frame.gif new file mode 100644 index 00000000000..0617291d152 Binary files /dev/null and b/Tests/images/palette_not_needed_for_second_frame.gif differ diff --git a/Tests/images/palette_sepia.png b/Tests/images/palette_sepia.png index f3fc932531f..9e7d6b0345b 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 23fb7940d6d..4b3d9ff3a21 100644 Binary files a/Tests/images/palette_wedge.png and b/Tests/images/palette_wedge.png differ diff --git a/Tests/images/pillow3.icns b/Tests/images/pillow3.icns index ef9b8917872..49b691d90f2 100644 Binary files a/Tests/images/pillow3.icns and b/Tests/images/pillow3.icns differ diff --git a/Tests/images/rectangle_surrounding_text.png b/Tests/images/rectangle_surrounding_text.png index 2b75a5e9c7a..ca77cea7323 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 00000000000..2443714cadc 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 00000000000..45fb7c3cca0 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 00000000000..c8fc957911e Binary files /dev/null and b/Tests/images/second_frame_comment.gif differ diff --git a/Tests/images/test_anchor_multiline_mm_right.png b/Tests/images/test_anchor_multiline_mm_right.png index cf002b12cd0..7e98b8eac8d 100644 Binary files a/Tests/images/test_anchor_multiline_mm_right.png and b/Tests/images/test_anchor_multiline_mm_right.png differ diff --git a/Tests/images/test_combine_multiline_lm_center.png b/Tests/images/test_combine_multiline_lm_center.png index 7b1e9c4e42f..6a15130248a 100644 Binary files a/Tests/images/test_combine_multiline_lm_center.png and b/Tests/images/test_combine_multiline_lm_center.png differ diff --git a/Tests/images/test_combine_multiline_lm_left.png b/Tests/images/test_combine_multiline_lm_left.png index a26996c2dbe..8eb254fdf26 100644 Binary files a/Tests/images/test_combine_multiline_lm_left.png and b/Tests/images/test_combine_multiline_lm_left.png differ diff --git a/Tests/images/test_combine_multiline_lm_right.png b/Tests/images/test_combine_multiline_lm_right.png index 7caf5cb742a..cb640a7409f 100644 Binary files a/Tests/images/test_combine_multiline_lm_right.png and b/Tests/images/test_combine_multiline_lm_right.png differ diff --git a/Tests/images/test_combine_multiline_mm_center.png b/Tests/images/test_combine_multiline_mm_center.png index a859e9570c8..d1146b8b856 100644 Binary files a/Tests/images/test_combine_multiline_mm_center.png and b/Tests/images/test_combine_multiline_mm_center.png differ diff --git a/Tests/images/test_combine_multiline_mm_left.png b/Tests/images/test_combine_multiline_mm_left.png index aadb5191f0e..f539a8e62e6 100644 Binary files a/Tests/images/test_combine_multiline_mm_left.png and b/Tests/images/test_combine_multiline_mm_left.png differ diff --git a/Tests/images/test_combine_multiline_mm_right.png b/Tests/images/test_combine_multiline_mm_right.png index 8238d4ec8ca..02634163e1c 100644 Binary files a/Tests/images/test_combine_multiline_mm_right.png and b/Tests/images/test_combine_multiline_mm_right.png differ diff --git a/Tests/images/test_combine_multiline_rm_center.png b/Tests/images/test_combine_multiline_rm_center.png index 7568dd63a33..4cce8f6a00e 100644 Binary files a/Tests/images/test_combine_multiline_rm_center.png and b/Tests/images/test_combine_multiline_rm_center.png differ diff --git a/Tests/images/test_combine_multiline_rm_left.png b/Tests/images/test_combine_multiline_rm_left.png index b8c3b5b143d..93d8162b3bf 100644 Binary files a/Tests/images/test_combine_multiline_rm_left.png and b/Tests/images/test_combine_multiline_rm_left.png differ diff --git a/Tests/images/test_combine_multiline_rm_right.png b/Tests/images/test_combine_multiline_rm_right.png index 14c478a72d0..6c4634560ed 100644 Binary files a/Tests/images/test_combine_multiline_rm_right.png and b/Tests/images/test_combine_multiline_rm_right.png differ diff --git a/Tests/images/test_woff2.png b/Tests/images/test_woff2.png new file mode 100644 index 00000000000..4eb3be4c73c Binary files /dev/null and b/Tests/images/test_woff2.png differ diff --git a/Tests/images/text_float_coord.png b/Tests/images/text_float_coord.png new file mode 100644 index 00000000000..d2270826a5b Binary files /dev/null and b/Tests/images/text_float_coord.png differ diff --git a/Tests/images/text_float_coord_1_alt.png b/Tests/images/text_float_coord_1_alt.png new file mode 100644 index 00000000000..2287071ffab Binary files /dev/null and b/Tests/images/text_float_coord_1_alt.png differ diff --git a/Tests/images/tiff_wrong_bits_per_sample_2.tiff b/Tests/images/tiff_wrong_bits_per_sample_2.tiff new file mode 100644 index 00000000000..d44176ce76c Binary files /dev/null and b/Tests/images/tiff_wrong_bits_per_sample_2.tiff differ diff --git a/Tests/images/tiff_wrong_bits_per_sample_3.tiff b/Tests/images/tiff_wrong_bits_per_sample_3.tiff new file mode 100644 index 00000000000..43526b157a5 Binary files /dev/null and b/Tests/images/tiff_wrong_bits_per_sample_3.tiff differ diff --git a/Tests/images/tiny.png b/Tests/images/tiny.png new file mode 100644 index 00000000000..3d9ff56e7ef Binary files /dev/null and b/Tests/images/tiny.png differ diff --git a/Tests/images/uncompressed_l.dds b/Tests/images/uncompressed_l.dds new file mode 100644 index 00000000000..b82282587ec Binary files /dev/null and b/Tests/images/uncompressed_l.dds differ diff --git a/Tests/images/uncompressed_l.png b/Tests/images/uncompressed_l.png new file mode 100644 index 00000000000..9d22a26a446 Binary files /dev/null and b/Tests/images/uncompressed_l.png differ diff --git a/Tests/images/uncompressed_la.dds b/Tests/images/uncompressed_la.dds new file mode 100644 index 00000000000..30bf93576fd Binary files /dev/null and b/Tests/images/uncompressed_la.dds differ diff --git a/Tests/images/uncompressed_la.png b/Tests/images/uncompressed_la.png new file mode 100644 index 00000000000..0d4ea602fc3 Binary files /dev/null and b/Tests/images/uncompressed_la.png differ diff --git a/Tests/images/unimplemented_dxgi_format.dds b/Tests/images/unimplemented_dxgi_format.dds index 5ecb42006c4..70860f2fcc4 100644 Binary files a/Tests/images/unimplemented_dxgi_format.dds and b/Tests/images/unimplemented_dxgi_format.dds differ diff --git a/Tests/images/variation_adobe_name.png b/Tests/images/variation_adobe_name.png index 11ceaf6e65b..5168e04b99b 100644 Binary files a/Tests/images/variation_adobe_name.png and b/Tests/images/variation_adobe_name.png differ diff --git a/Tests/images/variation_adobe_older_harfbuzz_name.png b/Tests/images/variation_adobe_older_harfbuzz_name.png index 2adb517a759..fa0e307b4f6 100644 Binary files a/Tests/images/variation_adobe_older_harfbuzz_name.png and b/Tests/images/variation_adobe_older_harfbuzz_name.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 00000000000..10f0f44009a Binary files /dev/null and b/Tests/images/xmp_tags_orientation_exiftool.png differ diff --git a/Tests/images/zero_height.j2k b/Tests/images/zero_height.j2k new file mode 100644 index 00000000000..21bdd8f7667 Binary files /dev/null and b/Tests/images/zero_height.j2k differ diff --git a/Tests/oss-fuzz/build.sh b/Tests/oss-fuzz/build.sh index 09cc7bc1696..7e9098f530b 100755 --- a/Tests/oss-fuzz/build.sh +++ b/Tests/oss-fuzz/build.sh @@ -19,29 +19,17 @@ python3 setup.py build --build-base=/tmp/build install # Build fuzzers in $OUT. for fuzzer in $(find $SRC -name 'fuzz_*.py'); do - fuzzer_basename=$(basename -s .py $fuzzer) - fuzzer_package=${fuzzer_basename}.pkg - pyinstaller \ + compile_python_fuzzer $fuzzer \ --add-binary /usr/local/lib/libjpeg.so.62.3.0:. \ --add-binary /usr/local/lib/libfreetype.so.6:. \ --add-binary /usr/local/lib/liblcms2.so.2:. \ --add-binary /usr/local/lib/libopenjp2.so.7:. \ --add-binary /usr/local/lib/libpng16.so.16:. \ - --add-binary /usr/local/lib/libtiff.so.5:. \ + --add-binary /usr/local/lib/libtiff.so.6:. \ --add-binary /usr/local/lib/libwebp.so.7:. \ --add-binary /usr/local/lib/libwebpdemux.so.2:. \ --add-binary /usr/local/lib/libwebpmux.so.3:. \ - --add-binary /usr/local/lib/libxcb.so.1:. \ - --distpath $OUT --onefile --name $fuzzer_package $fuzzer - - # Create execution wrapper. - echo "#!/bin/sh -# LLVMFuzzerTestOneInput for fuzzer detection. -this_dir=\$(dirname \"\$0\") -LD_PRELOAD=\$this_dir/sanitizer_with_fuzzer.so \ -ASAN_OPTIONS=\$ASAN_OPTIONS:symbolize=1:external_symbolizer_path=\$this_dir/llvm-symbolizer:detect_leaks=0 \ -\$this_dir/$fuzzer_package \$@" > $OUT/$fuzzer_basename - chmod u+x $OUT/$fuzzer_basename + --add-binary /usr/local/lib/libxcb.so.1:. done find Tests/images Tests/icc -print | zip -q $OUT/fuzz_pillow_seed_corpus.zip -@ diff --git a/Tests/oss-fuzz/fuzzers.py b/Tests/oss-fuzz/fuzzers.py index 5786764a64d..10a172b4675 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/oss-fuzz/test_fuzzers.py b/Tests/oss-fuzz/test_fuzzers.py index 629e9ac00d4..dc111c38b36 100644 --- a/Tests/oss-fuzz/test_fuzzers.py +++ b/Tests/oss-fuzz/test_fuzzers.py @@ -57,6 +57,6 @@ def test_fuzz_fonts(path): with open(path, "rb") as f: try: fuzzers.fuzz_font(f.read()) - except (Image.DecompressionBombError, Image.DecompressionBombWarning): + except (Image.DecompressionBombError, Image.DecompressionBombWarning, OSError): pass assert True diff --git a/Tests/test_000_sanity.py b/Tests/test_000_sanity.py index 59fbac527ed..3fd982474d4 100644 --- a/Tests/test_000_sanity.py +++ b/Tests/test_000_sanity.py @@ -1,19 +1,18 @@ -import PIL -import PIL.Image +from PIL import Image def test_sanity(): # Make sure we have the binary extension - PIL.Image.core.new("L", (100, 100)) + Image.core.new("L", (100, 100)) # Create an image and do stuff with it. - im = PIL.Image.new("1", (100, 100)) + im = Image.new("1", (100, 100)) assert (im.mode, im.size) == ("1", (100, 100)) assert len(im.tobytes()) == 1300 # Create images in all remaining major modes. - PIL.Image.new("L", (100, 100)) - PIL.Image.new("P", (100, 100)) - PIL.Image.new("RGB", (100, 100)) - PIL.Image.new("I", (100, 100)) - PIL.Image.new("F", (100, 100)) + Image.new("L", (100, 100)) + Image.new("P", (100, 100)) + Image.new("RGB", (100, 100)) + Image.new("I", (100, 100)) + Image.new("F", (100, 100)) diff --git a/Tests/test_bmp_reference.py b/Tests/test_bmp_reference.py index 99e16391adc..ed9aff9cc23 100644 --- a/Tests/test_bmp_reference.py +++ b/Tests/test_bmp_reference.py @@ -1,6 +1,5 @@ import os - -import pytest +import warnings from PIL import Image @@ -20,16 +19,14 @@ def test_bad(): either""" for f in get_files("b"): - with pytest.warns(None) as record: + # Assert that there is no unclosed file warning + with warnings.catch_warnings(): try: with Image.open(f) as im: im.load() except Exception: # as msg: pass - # Assert that there is no unclosed file warning - assert not record - def test_questionable(): """These shouldn't crash/dos, but it's not well defined that these @@ -38,11 +35,13 @@ def test_questionable(): "pal8os2v2.bmp", "rgb24prof.bmp", "pal1p1.bmp", + "pal4rletrns.bmp", "pal8offs.bmp", "rgb24lprof.bmp", "rgb32fakealpha.bmp", "rgb24largepal.bmp", "pal8os2sp.bmp", + "pal8rletrns.bmp", "rgb32bf-xbgr.bmp", ] for f in get_files("q"): diff --git a/Tests/test_box_blur.py b/Tests/test_box_blur.py index 94f504e0b55..3bdd5177d3f 100644 --- a/Tests/test_box_blur.py +++ b/Tests/test_box_blur.py @@ -25,7 +25,7 @@ def box_blur(image, radius=1, n=1): return image._new(image.im.box_blur(radius, n)) -def assertImage(im, data, delta=0): +def assert_image(im, data, delta=0): it = iter(im.getdata()) for data_row in data: im_row = [next(it) for _ in range(im.size[0])] @@ -35,12 +35,12 @@ def assertImage(im, data, delta=0): next(it) -def assertBlur(im, radius, data, passes=1, delta=0): +def assert_blur(im, radius, data, passes=1, delta=0): # check grayscale image - assertImage(box_blur(im, radius, passes), data, delta) + assert_image(box_blur(im, radius, passes), data, delta) rgba = Image.merge("RGBA", (im, im, im, im)) for band in box_blur(rgba, radius, passes).split(): - assertImage(band, data, delta) + assert_image(band, data, delta) def test_color_modes(): @@ -64,7 +64,7 @@ def test_color_modes(): def test_radius_0(): - assertBlur( + assert_blur( sample, 0, [ @@ -80,7 +80,7 @@ def test_radius_0(): def test_radius_0_02(): - assertBlur( + assert_blur( sample, 0.02, [ @@ -97,7 +97,7 @@ def test_radius_0_02(): def test_radius_0_05(): - assertBlur( + assert_blur( sample, 0.05, [ @@ -114,7 +114,7 @@ def test_radius_0_05(): def test_radius_0_1(): - assertBlur( + assert_blur( sample, 0.1, [ @@ -131,7 +131,7 @@ def test_radius_0_1(): def test_radius_0_5(): - assertBlur( + assert_blur( sample, 0.5, [ @@ -148,7 +148,7 @@ def test_radius_0_5(): def test_radius_1(): - assertBlur( + assert_blur( sample, 1, [ @@ -165,7 +165,7 @@ def test_radius_1(): def test_radius_1_5(): - assertBlur( + assert_blur( sample, 1.5, [ @@ -182,7 +182,7 @@ def test_radius_1_5(): def test_radius_bigger_then_half(): - assertBlur( + assert_blur( sample, 3, [ @@ -199,7 +199,7 @@ def test_radius_bigger_then_half(): def test_radius_bigger_then_width(): - assertBlur( + assert_blur( sample, 10, [ @@ -214,7 +214,7 @@ def test_radius_bigger_then_width(): def test_extreme_large_radius(): - assertBlur( + assert_blur( sample, 600, [ @@ -229,7 +229,7 @@ def test_extreme_large_radius(): def test_two_passes(): - assertBlur( + assert_blur( sample, 1, [ @@ -247,7 +247,7 @@ def test_two_passes(): def test_three_passes(): - assertBlur( + assert_blur( sample, 1, [ diff --git a/Tests/test_color_lut.py b/Tests/test_color_lut.py index 99776ce58cf..6d9a6057029 100644 --- a/Tests/test_color_lut.py +++ b/Tests/test_color_lut.py @@ -15,27 +15,27 @@ class TestColorLut3DCoreAPI: def generate_identity_table(self, channels, size): if isinstance(size, tuple): - size1D, size2D, size3D = size + size_1d, size_2d, size_3d = size else: - size1D, size2D, size3D = (size, size, size) + size_1d, size_2d, size_3d = (size, size, size) table = [ [ - r / (size1D - 1) if size1D != 1 else 0, - g / (size2D - 1) if size2D != 1 else 0, - b / (size3D - 1) if size3D != 1 else 0, - r / (size1D - 1) if size1D != 1 else 0, - g / (size2D - 1) if size2D != 1 else 0, + r / (size_1d - 1) if size_1d != 1 else 0, + g / (size_2d - 1) if size_2d != 1 else 0, + b / (size_3d - 1) if size_3d != 1 else 0, + r / (size_1d - 1) if size_1d != 1 else 0, + g / (size_2d - 1) if size_2d != 1 else 0, ][:channels] - for b in range(size3D) - for g in range(size2D) - for r in range(size1D) + for b in range(size_3d) + for g in range(size_2d) + for r in range(size_1d) ] return ( channels, - size1D, - size2D, - size3D, + size_1d, + size_2d, + size_3d, [item for sublist in table for item in sublist], ) @@ -43,107 +43,158 @@ def test_wrong_args(self): im = Image.new("RGB", (10, 10), 0) with pytest.raises(ValueError, match="filter"): - im.im.color_lut_3d("RGB", Image.CUBIC, *self.generate_identity_table(3, 3)) + im.im.color_lut_3d( + "RGB", Image.Resampling.BICUBIC, *self.generate_identity_table(3, 3) + ) with pytest.raises(ValueError, match="image mode"): im.im.color_lut_3d( - "wrong", Image.LINEAR, *self.generate_identity_table(3, 3) + "wrong", Image.Resampling.BILINEAR, *self.generate_identity_table(3, 3) ) with pytest.raises(ValueError, match="table_channels"): - im.im.color_lut_3d("RGB", Image.LINEAR, *self.generate_identity_table(5, 3)) + im.im.color_lut_3d( + "RGB", Image.Resampling.BILINEAR, *self.generate_identity_table(5, 3) + ) with pytest.raises(ValueError, match="table_channels"): - im.im.color_lut_3d("RGB", Image.LINEAR, *self.generate_identity_table(1, 3)) + im.im.color_lut_3d( + "RGB", Image.Resampling.BILINEAR, *self.generate_identity_table(1, 3) + ) with pytest.raises(ValueError, match="table_channels"): - im.im.color_lut_3d("RGB", Image.LINEAR, *self.generate_identity_table(2, 3)) + im.im.color_lut_3d( + "RGB", Image.Resampling.BILINEAR, *self.generate_identity_table(2, 3) + ) with pytest.raises(ValueError, match="Table size"): im.im.color_lut_3d( - "RGB", Image.LINEAR, *self.generate_identity_table(3, (1, 3, 3)) + "RGB", + Image.Resampling.BILINEAR, + *self.generate_identity_table(3, (1, 3, 3)), ) with pytest.raises(ValueError, match="Table size"): im.im.color_lut_3d( - "RGB", Image.LINEAR, *self.generate_identity_table(3, (66, 3, 3)) + "RGB", + Image.Resampling.BILINEAR, + *self.generate_identity_table(3, (66, 3, 3)), ) with pytest.raises(ValueError, match=r"size1D \* size2D \* size3D"): - im.im.color_lut_3d("RGB", Image.LINEAR, 3, 2, 2, 2, [0, 0, 0] * 7) + im.im.color_lut_3d( + "RGB", Image.Resampling.BILINEAR, 3, 2, 2, 2, [0, 0, 0] * 7 + ) with pytest.raises(ValueError, match=r"size1D \* size2D \* size3D"): - im.im.color_lut_3d("RGB", Image.LINEAR, 3, 2, 2, 2, [0, 0, 0] * 9) + im.im.color_lut_3d( + "RGB", Image.Resampling.BILINEAR, 3, 2, 2, 2, [0, 0, 0] * 9 + ) with pytest.raises(TypeError): - im.im.color_lut_3d("RGB", Image.LINEAR, 3, 2, 2, 2, [0, 0, "0"] * 8) + im.im.color_lut_3d( + "RGB", Image.Resampling.BILINEAR, 3, 2, 2, 2, [0, 0, "0"] * 8 + ) with pytest.raises(TypeError): - im.im.color_lut_3d("RGB", Image.LINEAR, 3, 2, 2, 2, 16) + im.im.color_lut_3d("RGB", Image.Resampling.BILINEAR, 3, 2, 2, 2, 16) def test_correct_args(self): im = Image.new("RGB", (10, 10), 0) - im.im.color_lut_3d("RGB", Image.LINEAR, *self.generate_identity_table(3, 3)) + im.im.color_lut_3d( + "RGB", Image.Resampling.BILINEAR, *self.generate_identity_table(3, 3) + ) - im.im.color_lut_3d("CMYK", Image.LINEAR, *self.generate_identity_table(4, 3)) + im.im.color_lut_3d( + "CMYK", Image.Resampling.BILINEAR, *self.generate_identity_table(4, 3) + ) im.im.color_lut_3d( - "RGB", Image.LINEAR, *self.generate_identity_table(3, (2, 3, 3)) + "RGB", + Image.Resampling.BILINEAR, + *self.generate_identity_table(3, (2, 3, 3)), ) im.im.color_lut_3d( - "RGB", Image.LINEAR, *self.generate_identity_table(3, (65, 3, 3)) + "RGB", + Image.Resampling.BILINEAR, + *self.generate_identity_table(3, (65, 3, 3)), ) im.im.color_lut_3d( - "RGB", Image.LINEAR, *self.generate_identity_table(3, (3, 65, 3)) + "RGB", + Image.Resampling.BILINEAR, + *self.generate_identity_table(3, (3, 65, 3)), ) im.im.color_lut_3d( - "RGB", Image.LINEAR, *self.generate_identity_table(3, (3, 3, 65)) + "RGB", + Image.Resampling.BILINEAR, + *self.generate_identity_table(3, (3, 3, 65)), ) def test_wrong_mode(self): with pytest.raises(ValueError, match="wrong mode"): im = Image.new("L", (10, 10), 0) - im.im.color_lut_3d("RGB", Image.LINEAR, *self.generate_identity_table(3, 3)) + im.im.color_lut_3d( + "RGB", Image.Resampling.BILINEAR, *self.generate_identity_table(3, 3) + ) with pytest.raises(ValueError, match="wrong mode"): im = Image.new("RGB", (10, 10), 0) - im.im.color_lut_3d("L", Image.LINEAR, *self.generate_identity_table(3, 3)) + im.im.color_lut_3d( + "L", Image.Resampling.BILINEAR, *self.generate_identity_table(3, 3) + ) with pytest.raises(ValueError, match="wrong mode"): im = Image.new("L", (10, 10), 0) - im.im.color_lut_3d("L", Image.LINEAR, *self.generate_identity_table(3, 3)) + im.im.color_lut_3d( + "L", Image.Resampling.BILINEAR, *self.generate_identity_table(3, 3) + ) with pytest.raises(ValueError, match="wrong mode"): im = Image.new("RGB", (10, 10), 0) im.im.color_lut_3d( - "RGBA", Image.LINEAR, *self.generate_identity_table(3, 3) + "RGBA", Image.Resampling.BILINEAR, *self.generate_identity_table(3, 3) ) with pytest.raises(ValueError, match="wrong mode"): im = Image.new("RGB", (10, 10), 0) - im.im.color_lut_3d("RGB", Image.LINEAR, *self.generate_identity_table(4, 3)) + im.im.color_lut_3d( + "RGB", Image.Resampling.BILINEAR, *self.generate_identity_table(4, 3) + ) def test_correct_mode(self): im = Image.new("RGBA", (10, 10), 0) - im.im.color_lut_3d("RGBA", Image.LINEAR, *self.generate_identity_table(3, 3)) + im.im.color_lut_3d( + "RGBA", Image.Resampling.BILINEAR, *self.generate_identity_table(3, 3) + ) im = Image.new("RGBA", (10, 10), 0) - im.im.color_lut_3d("RGBA", Image.LINEAR, *self.generate_identity_table(4, 3)) + im.im.color_lut_3d( + "RGBA", Image.Resampling.BILINEAR, *self.generate_identity_table(4, 3) + ) im = Image.new("RGB", (10, 10), 0) - im.im.color_lut_3d("HSV", Image.LINEAR, *self.generate_identity_table(3, 3)) + im.im.color_lut_3d( + "HSV", Image.Resampling.BILINEAR, *self.generate_identity_table(3, 3) + ) im = Image.new("RGB", (10, 10), 0) - im.im.color_lut_3d("RGBA", Image.LINEAR, *self.generate_identity_table(4, 3)) + im.im.color_lut_3d( + "RGBA", Image.Resampling.BILINEAR, *self.generate_identity_table(4, 3) + ) def test_identities(self): g = Image.linear_gradient("L") im = Image.merge( - "RGB", [g, g.transpose(Image.ROTATE_90), g.transpose(Image.ROTATE_180)] + "RGB", + [ + g, + g.transpose(Image.Transpose.ROTATE_90), + g.transpose(Image.Transpose.ROTATE_180), + ], ) # Fast test with small cubes @@ -152,7 +203,9 @@ def test_identities(self): im, im._new( im.im.color_lut_3d( - "RGB", Image.LINEAR, *self.generate_identity_table(3, size) + "RGB", + Image.Resampling.BILINEAR, + *self.generate_identity_table(3, size), ) ), ) @@ -162,7 +215,9 @@ def test_identities(self): im, im._new( im.im.color_lut_3d( - "RGB", Image.LINEAR, *self.generate_identity_table(3, (2, 2, 65)) + "RGB", + Image.Resampling.BILINEAR, + *self.generate_identity_table(3, (2, 2, 65)), ) ), ) @@ -170,7 +225,12 @@ def test_identities(self): def test_identities_4_channels(self): g = Image.linear_gradient("L") im = Image.merge( - "RGB", [g, g.transpose(Image.ROTATE_90), g.transpose(Image.ROTATE_180)] + "RGB", + [ + g, + g.transpose(Image.Transpose.ROTATE_90), + g.transpose(Image.Transpose.ROTATE_180), + ], ) # Red channel copied to alpha @@ -178,7 +238,9 @@ def test_identities_4_channels(self): Image.merge("RGBA", (im.split() * 2)[:4]), im._new( im.im.color_lut_3d( - "RGBA", Image.LINEAR, *self.generate_identity_table(4, 17) + "RGBA", + Image.Resampling.BILINEAR, + *self.generate_identity_table(4, 17), ) ), ) @@ -189,9 +251,9 @@ def test_copy_alpha_channel(self): "RGBA", [ g, - g.transpose(Image.ROTATE_90), - g.transpose(Image.ROTATE_180), - g.transpose(Image.ROTATE_270), + g.transpose(Image.Transpose.ROTATE_90), + g.transpose(Image.Transpose.ROTATE_180), + g.transpose(Image.Transpose.ROTATE_270), ], ) @@ -199,7 +261,9 @@ def test_copy_alpha_channel(self): im, im._new( im.im.color_lut_3d( - "RGBA", Image.LINEAR, *self.generate_identity_table(3, 17) + "RGBA", + Image.Resampling.BILINEAR, + *self.generate_identity_table(3, 17), ) ), ) @@ -207,14 +271,19 @@ def test_copy_alpha_channel(self): def test_channels_order(self): g = Image.linear_gradient("L") im = Image.merge( - "RGB", [g, g.transpose(Image.ROTATE_90), g.transpose(Image.ROTATE_180)] + "RGB", + [ + g, + g.transpose(Image.Transpose.ROTATE_90), + g.transpose(Image.Transpose.ROTATE_180), + ], ) # Reverse channels by splitting and using table # fmt: off assert_image_equal( Image.merge('RGB', im.split()[::-1]), - im._new(im.im.color_lut_3d('RGB', Image.LINEAR, + im._new(im.im.color_lut_3d('RGB', Image.Resampling.BILINEAR, 3, 2, 2, 2, [ 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, @@ -227,11 +296,16 @@ def test_channels_order(self): def test_overflow(self): g = Image.linear_gradient("L") im = Image.merge( - "RGB", [g, g.transpose(Image.ROTATE_90), g.transpose(Image.ROTATE_180)] + "RGB", + [ + g, + g.transpose(Image.Transpose.ROTATE_90), + g.transpose(Image.Transpose.ROTATE_180), + ], ) # fmt: off - transformed = im._new(im.im.color_lut_3d('RGB', Image.LINEAR, + transformed = im._new(im.im.color_lut_3d('RGB', Image.Resampling.BILINEAR, 3, 2, 2, 2, [ -1, -1, -1, 2, -1, -1, @@ -251,7 +325,7 @@ def test_overflow(self): assert transformed[205, 205] == (255, 255, 0) # fmt: off - transformed = im._new(im.im.color_lut_3d('RGB', Image.LINEAR, + transformed = im._new(im.im.color_lut_3d('RGB', Image.Resampling.BILINEAR, 3, 2, 2, 2, [ -3, -3, -3, 5, -3, -3, @@ -354,7 +428,12 @@ def test_numpy_sources(self): def test_numpy_formats(self): g = Image.linear_gradient("L") im = Image.merge( - "RGB", [g, g.transpose(Image.ROTATE_90), g.transpose(Image.ROTATE_180)] + "RGB", + [ + g, + g.transpose(Image.Transpose.ROTATE_90), + g.transpose(Image.Transpose.ROTATE_180), + ], ) lut = ImageFilter.Color3DLUT.generate((7, 9, 11), lambda r, g, b: (r, g, b)) @@ -445,7 +524,12 @@ def test_apply(self): g = Image.linear_gradient("L") im = Image.merge( - "RGB", [g, g.transpose(Image.ROTATE_90), g.transpose(Image.ROTATE_180)] + "RGB", + [ + g, + g.transpose(Image.Transpose.ROTATE_90), + g.transpose(Image.Transpose.ROTATE_180), + ], ) assert im == im.filter(lut) @@ -483,7 +567,7 @@ def test_3_to_3_channels(self): assert tuple(lut.size) == tuple(source.size) assert len(lut.table) == len(source.table) assert lut.table != source.table - assert lut.table[0:10] == [0.0, 0.0, 0.0, 0.25, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0] + assert lut.table[:10] == [0.0, 0.0, 0.0, 0.25, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0] def test_3_to_4_channels(self): source = ImageFilter.Color3DLUT.generate((6, 5, 4), lambda r, g, b: (r, g, b)) @@ -492,7 +576,7 @@ def test_3_to_4_channels(self): assert len(lut.table) != len(source.table) assert lut.table != source.table # fmt: off - assert lut.table[0:16] == [ + assert lut.table[:16] == [ 0.0, 0.0, 0.0, 1, 0.2**2, 0.0, 0.0, 1, 0.4**2, 0.0, 0.0, 1, 0.6**2, 0.0, 0.0, 1] # fmt: on @@ -508,7 +592,7 @@ def test_4_to_3_channels(self): assert len(lut.table) != len(source.table) assert lut.table != source.table # fmt: off - assert lut.table[0:18] == [ + assert lut.table[:18] == [ 1.0, 1.0, 1.0, 0.75, 1.0, 1.0, 0.0, 1.0, 1.0, 1.0, 0.96, 1.0, 0.75, 0.96, 1.0, 0.0, 0.96, 1.0] # fmt: on @@ -522,7 +606,7 @@ def test_4_to_4_channels(self): assert len(lut.table) == len(source.table) assert lut.table != source.table # fmt: off - assert lut.table[0:16] == [ + assert lut.table[:16] == [ 0.0, 0.0, 0.0, 0.5, 0.2**2, 0.0, 0.0, 0.5, 0.4**2, 0.0, 0.0, 0.5, 0.6**2, 0.0, 0.0, 0.5] # fmt: on @@ -538,7 +622,7 @@ def test_with_normals_3_channels(self): assert len(lut.table) == len(source.table) assert lut.table != source.table # fmt: off - assert lut.table[0:18] == [ + assert lut.table[:18] == [ 0.0, 0.0, 0.0, 0.16, 0.0, 0.0, 0.24, 0.0, 0.0, 0.24, 0.0, 0.0, 0.8 - (0.8**2), 0, 0, 0, 0, 0] # fmt: on @@ -555,7 +639,7 @@ def test_with_normals_4_channels(self): assert len(lut.table) == len(source.table) assert lut.table != source.table # fmt: off - assert lut.table[0:16] == [ + assert lut.table[:16] == [ 0.0, 0.0, 0.0, 0.5, 0.25, 0.0, 0.0, 0.5, 0.0, 0.0, 0.0, 0.5, 0.0, 0.16, 0.0, 0.5] # fmt: on diff --git a/Tests/test_core_resources.py b/Tests/test_core_resources.py index 6c52d25a4aa..385192a3cdc 100644 --- a/Tests/test_core_resources.py +++ b/Tests/test_core_resources.py @@ -110,9 +110,9 @@ def test_set_blocks_max(self): with pytest.raises(ValueError): Image.core.set_blocks_max(-1) - if sys.maxsize < 2 ** 32: + if sys.maxsize < 2**32: with pytest.raises(ValueError): - Image.core.set_blocks_max(2 ** 29) + Image.core.set_blocks_max(2**29) @pytest.mark.skipif(is_pypy(), reason="Images not collected") def test_set_blocks_max_stats(self): diff --git a/Tests/test_decompression_bomb.py b/Tests/test_decompression_bomb.py index d918ef9410c..63071b78c9c 100644 --- a/Tests/test_decompression_bomb.py +++ b/Tests/test_decompression_bomb.py @@ -51,7 +51,6 @@ def test_exception(self): 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 @@ def test_exception_gif(self): 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"): @@ -70,15 +74,15 @@ def test_exception_bmp(self): class TestDecompressionCrop: @classmethod - def setup_class(self): + def setup_class(cls): width, height = 128, 128 Image.MAX_IMAGE_PIXELS = height * width * 4 - 1 @classmethod - def teardown_class(self): + def teardown_class(cls): Image.MAX_IMAGE_PIXELS = ORIGINAL_LIMIT - def testEnlargeCrop(self): + def test_enlarge_crop(self): # Crops can extend the extents, therefore we should have the # same decompression bomb warnings on them. with hopper() as src: @@ -86,21 +90,12 @@ def testEnlargeCrop(self): pytest.warns(Image.DecompressionBombWarning, src.crop, box) def test_crop_decompression_checks(self): - im = Image.new("RGB", (100, 100)) - good_values = ((-9999, -9999, -9990, -9990), (-999, -999, -990, -990)) - - warning_values = ((-160, -160, 99, 99), (160, 160, -99, -99)) - - error_values = ((-99909, -99990, 99999, 99999), (99909, 99990, -99999, -99999)) - - for value in good_values: + for value in ((-9999, -9999, -9990, -9990), (-999, -999, -990, -990)): assert im.crop(value).size == (9, 9) - for value in warning_values: - pytest.warns(Image.DecompressionBombWarning, im.crop, value) + pytest.warns(Image.DecompressionBombWarning, im.crop, (-160, -160, 99, 99)) - for value in error_values: - with pytest.raises(Image.DecompressionBombError): - im.crop(value) + with pytest.raises(Image.DecompressionBombError): + im.crop((-99909, -99990, 99999, 99999)) diff --git a/Tests/test_deprecate.py b/Tests/test_deprecate.py new file mode 100644 index 00000000000..30ed4a8081d --- /dev/null +++ b/Tests/test_deprecate.py @@ -0,0 +1,91 @@ +import pytest + +from PIL import _deprecate + + +@pytest.mark.parametrize( + "version, expected", + [ + ( + 10, + "Old thing is deprecated and will be removed in Pillow 10 " + r"\(2023-07-01\)\. Use new thing instead\.", + ), + ( + None, + r"Old thing is deprecated and will be removed in a future version\. " + r"Use new thing instead\.", + ), + ], +) +def test_version(version, expected): + with pytest.warns(DeprecationWarning, match=expected): + _deprecate.deprecate("Old thing", version, "new thing") + + +def test_unknown_version(): + expected = r"Unknown removal version, update PIL\._deprecate\?" + with pytest.raises(ValueError, match=expected): + _deprecate.deprecate("Old thing", 12345, "new thing") + + +@pytest.mark.parametrize( + "deprecated, plural, expected", + [ + ( + "Old thing", + False, + r"Old thing is deprecated and should be removed\.", + ), + ( + "Old things", + True, + r"Old things are deprecated and should be removed\.", + ), + ], +) +def test_old_version(deprecated, plural, expected): + expected = r"" + with pytest.raises(RuntimeError, match=expected): + _deprecate.deprecate(deprecated, 1, plural=plural) + + +def test_plural(): + expected = ( + r"Old things are deprecated and will be removed in Pillow 10 \(2023-07-01\)\. " + r"Use new thing instead\." + ) + with pytest.warns(DeprecationWarning, match=expected): + _deprecate.deprecate("Old things", 10, "new thing", plural=True) + + +def test_replacement_and_action(): + expected = "Use only one of 'replacement' and 'action'" + with pytest.raises(ValueError, match=expected): + _deprecate.deprecate( + "Old thing", 10, replacement="new thing", action="Upgrade to new thing" + ) + + +@pytest.mark.parametrize( + "action", + [ + "Upgrade to new thing", + "Upgrade to new thing.", + ], +) +def test_action(action): + expected = ( + r"Old thing is deprecated and will be removed in Pillow 10 \(2023-07-01\)\. " + r"Upgrade to new thing\." + ) + with pytest.warns(DeprecationWarning, match=expected): + _deprecate.deprecate("Old thing", 10, action=action) + + +def test_no_replacement_or_action(): + expected = ( + r"Old thing is deprecated and will be removed in Pillow 10 \(2023-07-01\)" + ) + with pytest.warns(DeprecationWarning, match=expected): + _deprecate.deprecate("Old thing", 10) diff --git a/Tests/test_deprecated_imageqt.py b/Tests/test_deprecated_imageqt.py new file mode 100644 index 00000000000..2528ff3f7d4 --- /dev/null +++ b/Tests/test_deprecated_imageqt.py @@ -0,0 +1,18 @@ +import warnings + +with warnings.catch_warnings(record=True) as w: + # Arrange: cause all warnings to always be triggered + warnings.simplefilter("always") + + # Act: trigger a warning with Qt5 + from PIL import ImageQt + + +def test_deprecated(): + # Assert + if ImageQt.qt_version in ("5", "side2"): + assert len(w) == 1 + assert issubclass(w[0].category, DeprecationWarning) + assert "deprecated" in str(w[0].message) + else: + assert len(w) == 0 diff --git a/Tests/test_features.py b/Tests/test_features.py index 284f72205f3..c4e9cd36811 100644 --- a/Tests/test_features.py +++ b/Tests/test_features.py @@ -70,14 +70,14 @@ def test_libimagequant_version(): assert re.search(r"\d+\.\d+\.\d+$", features.version("libimagequant")) -def test_check_modules(): - for feature in features.modules: - assert features.check_module(feature) in [True, False] +@pytest.mark.parametrize("feature", features.modules) +def test_check_modules(feature): + assert features.check_module(feature) in [True, False] -def test_check_codecs(): - for feature in features.codecs: - assert features.check_codec(feature) in [True, False] +@pytest.mark.parametrize("feature", features.codecs) +def test_check_codecs(feature): + assert features.check_codec(feature) in [True, False] def test_check_warns_on_nonexistent(): diff --git a/Tests/test_file_apng.py b/Tests/test_file_apng.py index d48e5ce07f3..51637c78645 100644 --- a/Tests/test_file_apng.py +++ b/Tests/test_file_apng.py @@ -39,13 +39,12 @@ def test_apng_basic(): assert im.getpixel((64, 32)) == (0, 255, 0, 255) -def test_apng_fdat(): - with Image.open("Tests/images/apng/split_fdat.png") as im: - im.seek(im.n_frames - 1) - assert im.getpixel((0, 0)) == (0, 255, 0, 255) - assert im.getpixel((64, 32)) == (0, 255, 0, 255) - - with Image.open("Tests/images/apng/split_fdat_zero_chunk.png") as im: +@pytest.mark.parametrize( + "filename", + ("Tests/images/apng/split_fdat.png", "Tests/images/apng/split_fdat_zero_chunk.png"), +) +def test_apng_fdat(filename): + with Image.open(filename) as im: im.seek(im.n_frames - 1) assert im.getpixel((0, 0)) == (0, 255, 0, 255) assert im.getpixel((64, 32)) == (0, 255, 0, 255) @@ -120,9 +119,9 @@ def test_apng_dispose_op_previous_frame(): # save_all=True, # append_images=[green, blue], # disposal=[ - # PngImagePlugin.APNG_DISPOSE_OP_NONE, - # PngImagePlugin.APNG_DISPOSE_OP_PREVIOUS, - # PngImagePlugin.APNG_DISPOSE_OP_PREVIOUS + # PngImagePlugin.Disposal.OP_NONE, + # PngImagePlugin.Disposal.OP_PREVIOUS, + # PngImagePlugin.Disposal.OP_PREVIOUS # ], # ) with Image.open("Tests/images/apng/dispose_op_previous_frame.png") as im: @@ -325,8 +324,9 @@ def open(): 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 +334,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): @@ -455,31 +456,31 @@ def test_apng_save_disposal(tmp_path): green = Image.new("RGBA", size, (0, 255, 0, 255)) transparent = Image.new("RGBA", size, (0, 0, 0, 0)) - # test APNG_DISPOSE_OP_NONE + # test OP_NONE red.save( test_file, save_all=True, append_images=[green, transparent], - disposal=PngImagePlugin.APNG_DISPOSE_OP_NONE, - blend=PngImagePlugin.APNG_BLEND_OP_OVER, + disposal=PngImagePlugin.Disposal.OP_NONE, + blend=PngImagePlugin.Blend.OP_OVER, ) with Image.open(test_file) as im: im.seek(2) assert im.getpixel((0, 0)) == (0, 255, 0, 255) assert im.getpixel((64, 32)) == (0, 255, 0, 255) - # test APNG_DISPOSE_OP_BACKGROUND + # test OP_BACKGROUND disposal = [ - PngImagePlugin.APNG_DISPOSE_OP_NONE, - PngImagePlugin.APNG_DISPOSE_OP_BACKGROUND, - PngImagePlugin.APNG_DISPOSE_OP_NONE, + PngImagePlugin.Disposal.OP_NONE, + PngImagePlugin.Disposal.OP_BACKGROUND, + PngImagePlugin.Disposal.OP_NONE, ] red.save( test_file, save_all=True, append_images=[red, transparent], disposal=disposal, - blend=PngImagePlugin.APNG_BLEND_OP_OVER, + blend=PngImagePlugin.Blend.OP_OVER, ) with Image.open(test_file) as im: im.seek(2) @@ -487,26 +488,26 @@ def test_apng_save_disposal(tmp_path): assert im.getpixel((64, 32)) == (0, 0, 0, 0) disposal = [ - PngImagePlugin.APNG_DISPOSE_OP_NONE, - PngImagePlugin.APNG_DISPOSE_OP_BACKGROUND, + PngImagePlugin.Disposal.OP_NONE, + PngImagePlugin.Disposal.OP_BACKGROUND, ] red.save( test_file, save_all=True, append_images=[green], disposal=disposal, - blend=PngImagePlugin.APNG_BLEND_OP_OVER, + blend=PngImagePlugin.Blend.OP_OVER, ) with Image.open(test_file) as im: im.seek(1) assert im.getpixel((0, 0)) == (0, 255, 0, 255) assert im.getpixel((64, 32)) == (0, 255, 0, 255) - # test APNG_DISPOSE_OP_PREVIOUS + # test OP_PREVIOUS disposal = [ - PngImagePlugin.APNG_DISPOSE_OP_NONE, - PngImagePlugin.APNG_DISPOSE_OP_PREVIOUS, - PngImagePlugin.APNG_DISPOSE_OP_NONE, + PngImagePlugin.Disposal.OP_NONE, + PngImagePlugin.Disposal.OP_PREVIOUS, + PngImagePlugin.Disposal.OP_NONE, ] red.save( test_file, @@ -514,7 +515,7 @@ def test_apng_save_disposal(tmp_path): append_images=[green, red, transparent], default_image=True, disposal=disposal, - blend=PngImagePlugin.APNG_BLEND_OP_OVER, + blend=PngImagePlugin.Blend.OP_OVER, ) with Image.open(test_file) as im: im.seek(3) @@ -522,15 +523,15 @@ def test_apng_save_disposal(tmp_path): assert im.getpixel((64, 32)) == (0, 255, 0, 255) disposal = [ - PngImagePlugin.APNG_DISPOSE_OP_NONE, - PngImagePlugin.APNG_DISPOSE_OP_PREVIOUS, + PngImagePlugin.Disposal.OP_NONE, + PngImagePlugin.Disposal.OP_PREVIOUS, ] red.save( test_file, save_all=True, append_images=[green], disposal=disposal, - blend=PngImagePlugin.APNG_BLEND_OP_OVER, + blend=PngImagePlugin.Blend.OP_OVER, ) with Image.open(test_file) as im: im.seek(1) @@ -538,7 +539,7 @@ def test_apng_save_disposal(tmp_path): assert im.getpixel((64, 32)) == (0, 255, 0, 255) # test info disposal - red.info["disposal"] = PngImagePlugin.APNG_DISPOSE_OP_BACKGROUND + red.info["disposal"] = PngImagePlugin.Disposal.OP_BACKGROUND red.save( test_file, save_all=True, @@ -552,18 +553,20 @@ def test_apng_save_disposal(tmp_path): def test_apng_save_disposal_previous(tmp_path): test_file = str(tmp_path / "temp.png") size = (128, 64) - transparent = Image.new("RGBA", size, (0, 0, 0, 0)) + blue = Image.new("RGBA", size, (0, 0, 255, 255)) red = Image.new("RGBA", size, (255, 0, 0, 255)) green = Image.new("RGBA", size, (0, 255, 0, 255)) - # test APNG_DISPOSE_OP_NONE - transparent.save( + # test OP_NONE + blue.save( test_file, save_all=True, append_images=[red, green], - disposal=PngImagePlugin.APNG_DISPOSE_OP_PREVIOUS, + disposal=PngImagePlugin.Disposal.OP_PREVIOUS, ) with Image.open(test_file) as im: + assert im.getpixel((0, 0)) == (0, 0, 255, 255) + im.seek(2) assert im.getpixel((0, 0)) == (0, 255, 0, 255) assert im.getpixel((64, 32)) == (0, 255, 0, 255) @@ -576,17 +579,17 @@ def test_apng_save_blend(tmp_path): green = Image.new("RGBA", size, (0, 255, 0, 255)) transparent = Image.new("RGBA", size, (0, 0, 0, 0)) - # test APNG_BLEND_OP_SOURCE on solid color + # test OP_SOURCE on solid color blend = [ - PngImagePlugin.APNG_BLEND_OP_OVER, - PngImagePlugin.APNG_BLEND_OP_SOURCE, + PngImagePlugin.Blend.OP_OVER, + PngImagePlugin.Blend.OP_SOURCE, ] red.save( test_file, save_all=True, append_images=[red, green], default_image=True, - disposal=PngImagePlugin.APNG_DISPOSE_OP_NONE, + disposal=PngImagePlugin.Disposal.OP_NONE, blend=blend, ) with Image.open(test_file) as im: @@ -594,17 +597,17 @@ def test_apng_save_blend(tmp_path): assert im.getpixel((0, 0)) == (0, 255, 0, 255) assert im.getpixel((64, 32)) == (0, 255, 0, 255) - # test APNG_BLEND_OP_SOURCE on transparent color + # test OP_SOURCE on transparent color blend = [ - PngImagePlugin.APNG_BLEND_OP_OVER, - PngImagePlugin.APNG_BLEND_OP_SOURCE, + PngImagePlugin.Blend.OP_OVER, + PngImagePlugin.Blend.OP_SOURCE, ] red.save( test_file, save_all=True, append_images=[red, transparent], default_image=True, - disposal=PngImagePlugin.APNG_DISPOSE_OP_NONE, + disposal=PngImagePlugin.Disposal.OP_NONE, blend=blend, ) with Image.open(test_file) as im: @@ -612,14 +615,14 @@ def test_apng_save_blend(tmp_path): assert im.getpixel((0, 0)) == (0, 0, 0, 0) assert im.getpixel((64, 32)) == (0, 0, 0, 0) - # test APNG_BLEND_OP_OVER + # test OP_OVER red.save( test_file, save_all=True, append_images=[green, transparent], default_image=True, - disposal=PngImagePlugin.APNG_DISPOSE_OP_NONE, - blend=PngImagePlugin.APNG_BLEND_OP_OVER, + disposal=PngImagePlugin.Disposal.OP_NONE, + blend=PngImagePlugin.Blend.OP_OVER, ) with Image.open(test_file) as im: im.seek(1) @@ -630,8 +633,37 @@ def test_apng_save_blend(tmp_path): assert im.getpixel((64, 32)) == (0, 255, 0, 255) # test info blend - red.info["blend"] = PngImagePlugin.APNG_BLEND_OP_OVER + red.info["blend"] = PngImagePlugin.Blend.OP_OVER red.save(test_file, save_all=True, append_images=[green, transparent]) with Image.open(test_file) as im: im.seek(2) 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) + + +@pytest.mark.parametrize("mode", ("RGBA", "RGB", "P")) +def test_different_modes_in_later_frames(mode, tmp_path): + test_file = str(tmp_path / "temp.png") + + im = Image.new("L", (1, 1)) + im.save(test_file, save_all=True, append_images=[Image.new(mode, (1, 1))]) + with Image.open(test_file) as reloaded: + assert reloaded.mode == mode + + +def test_constants_deprecation(): + for enum, prefix in { + PngImagePlugin.Disposal: "APNG_DISPOSE_", + PngImagePlugin.Blend: "APNG_BLEND_", + }.items(): + for name in enum.__members__: + with pytest.warns(DeprecationWarning): + assert getattr(PngImagePlugin, prefix + name) == enum[name] diff --git a/Tests/test_file_blp.py b/Tests/test_file_blp.py index 15bd7e4f8ef..ba2781820e0 100644 --- a/Tests/test_file_blp.py +++ b/Tests/test_file_blp.py @@ -1,8 +1,21 @@ import pytest -from PIL import Image +from PIL import BlpImagePlugin, Image -from .helper import assert_image_equal_tofile +from .helper import ( + assert_image_equal, + assert_image_equal_tofile, + assert_image_similar, + hopper, +) + + +def test_load_blp1(): + with Image.open("Tests/images/blp/blp1_jpeg.blp") as im: + assert_image_equal_tofile(im, "Tests/images/blp/blp1_jpeg.png") + + with Image.open("Tests/images/blp/blp1_jpeg2.blp") as im: + im.load() def test_load_blp2_raw(): @@ -20,6 +33,28 @@ def test_load_blp2_dxt1a(): assert_image_equal_tofile(im, "Tests/images/blp/blp2_dxt1a.png") +def test_save(tmp_path): + f = str(tmp_path / "temp.blp") + + for version in ("BLP1", "BLP2"): + im = hopper("P") + im.save(f, blp_version=version) + + with Image.open(f) as reloaded: + assert_image_equal(im.convert("RGB"), reloaded) + + with Image.open("Tests/images/transparent.png") as im: + f = str(tmp_path / "temp.blp") + im.convert("P").save(f, blp_version=version) + + with Image.open(f) as reloaded: + assert_image_similar(im, reloaded, 8) + + im = hopper() + with pytest.raises(ValueError): + im.save(f) + + @pytest.mark.parametrize( "test_file", [ @@ -37,3 +72,14 @@ def test_crashes(test_file): with Image.open(f) as im: with pytest.raises(OSError): im.load() + + +def test_constants_deprecation(): + for enum, prefix in { + BlpImagePlugin.Format: "BLP_FORMAT_", + BlpImagePlugin.Encoding: "BLP_ENCODING_", + BlpImagePlugin.AlphaEncoding: "BLP_ALPHA_ENCODING_", + }.items(): + for name in enum.__members__: + with pytest.warns(DeprecationWarning): + assert getattr(BlpImagePlugin, prefix + name) == enum[name] diff --git a/Tests/test_file_bmp.py b/Tests/test_file_bmp.py index 47fc97df055..5f6d523558a 100644 --- a/Tests/test_file_bmp.py +++ b/Tests/test_file_bmp.py @@ -4,7 +4,12 @@ from PIL import BmpImagePlugin, Image -from .helper import assert_image_equal, assert_image_equal_tofile, hopper +from .helper import ( + assert_image_equal, + assert_image_equal_tofile, + assert_image_similar_tofile, + hopper, +) def test_sanity(tmp_path): @@ -34,6 +39,13 @@ def test_invalid_file(): BmpImagePlugin.BmpImageFile(fp) +def test_fallback_if_mmap_errors(): + # This image has been truncated, + # so that the buffer is not large enough when using mmap + with Image.open("Tests/images/mmap_error.bmp") as im: + assert_image_equal_tofile(im, "Tests/images/pal8_offset.bmp") + + def test_save_to_bytes(): output = io.BytesIO() im = hopper() @@ -46,6 +58,18 @@ def test_save_to_bytes(): assert reloaded.format == "BMP" +def test_small_palette(tmp_path): + im = Image.new("P", (1, 1)) + colors = [0, 0, 0, 125, 125, 125, 255, 255, 255] + im.putpalette(colors) + + out = str(tmp_path / "temp.bmp") + im.save(out) + + with Image.open(out) as reloaded: + assert reloaded.getpalette() == colors + + def test_save_too_large(tmp_path): outfile = str(tmp_path / "temp.bmp") with Image.new("RGB", (1, 1)) as im: @@ -124,6 +148,57 @@ 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: + assert_image_similar_tofile(im.convert("RGB"), "Tests/images/hopper.bmp", 12) + + # Signal end of bitmap before the image is finished + with open("Tests/images/bmp/g/pal8rle.bmp", "rb") as fp: + data = fp.read(1063) + b"\x01" + with Image.open(io.BytesIO(data)) as im: + with pytest.raises(ValueError): + im.load() + + +def test_rle4(): + with Image.open("Tests/images/bmp/g/pal4rle.bmp") as im: + assert_image_similar_tofile(im, "Tests/images/bmp/g/pal4.bmp", 12) + + +@pytest.mark.parametrize( + "file_name,length", + ( + # EOF immediately after the header + ("Tests/images/hopper_rle8.bmp", 1078), + # EOF during delta + ("Tests/images/bmp/q/pal8rletrns.bmp", 3670), + # EOF when reading data in absolute mode + ("Tests/images/bmp/g/pal8rle.bmp", 1064), + ), +) +def test_rle8_eof(file_name, length): + with open(file_name, "rb") as fp: + data = fp.read(length) + with Image.open(io.BytesIO(data)) as im: + with pytest.raises(ValueError): + im.load() + def test_offset(): # This image has been hexedited diff --git a/Tests/test_file_bufrstub.py b/Tests/test_file_bufrstub.py index 11acc1c88c0..e330404d64e 100644 --- a/Tests/test_file_bufrstub.py +++ b/Tests/test_file_bufrstub.py @@ -45,3 +45,35 @@ def test_save(tmp_path): # Act / Assert: stub cannot save without an implemented handler with pytest.raises(OSError): im.save(tmpfile) + + +def test_handler(tmp_path): + class TestHandler: + opened = False + loaded = False + saved = False + + def open(self, im): + self.opened = True + + def load(self, im): + self.loaded = True + return Image.new("RGB", (1, 1)) + + def save(self, im, fp, filename): + self.saved = True + + handler = TestHandler() + BufrStubImagePlugin.register_handler(handler) + with Image.open(TEST_FILE) as im: + assert handler.opened + assert not handler.loaded + + im.load() + assert handler.loaded + + temp_file = str(tmp_path / "temp.bufr") + im.save(temp_file) + assert handler.saved + + BufrStubImagePlugin._handler = None diff --git a/Tests/test_file_container.py b/Tests/test_file_container.py index b752e217faa..65cf6a75ea3 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) - - # Act - data = container.readlines() - - # Assert - if bytesmode: - data = [line.decode() for line in data] - assert data == expected + 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() + + # Assert + if bytesmode: + data = [line.decode() for line in data] + assert data == expected diff --git a/Tests/test_file_dcx.py b/Tests/test_file_dcx.py index 58d5cbf1a61..0f09c4b9915 100644 --- a/Tests/test_file_dcx.py +++ b/Tests/test_file_dcx.py @@ -1,3 +1,5 @@ +import warnings + import pytest from PIL import DcxImagePlugin, Image @@ -31,21 +33,17 @@ def open(): def test_closed_file(): - with pytest.warns(None) as record: + with warnings.catch_warnings(): im = Image.open(TEST_FILE) im.load() im.close() - assert not record - def test_context_manager(): - with pytest.warns(None) as record: + with warnings.catch_warnings(): with Image.open(TEST_FILE) as im: im.load() - assert not record - def test_invalid_file(): with open("Tests/images/flower.jpg", "rb") as fp: diff --git a/Tests/test_file_dds.py b/Tests/test_file_dds.py index 2f46ed77e0c..cac4108a8f0 100644 --- a/Tests/test_file_dds.py +++ b/Tests/test_file_dds.py @@ -10,14 +10,20 @@ 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" TEST_FILE_BC5S = "Tests/images/bc5s.dds" +TEST_FILE_BC6H = "Tests/images/bc6h.dds" +TEST_FILE_BC6HS = "Tests/images/bc6h_sf.dds" TEST_FILE_DX10_BC7 = "Tests/images/bc7-argb-8bpp_MipMaps-1.dds" TEST_FILE_DX10_BC7_UNORM_SRGB = "Tests/images/DXGI_FORMAT_BC7_UNORM_SRGB.dds" TEST_FILE_DX10_R8G8B8A8 = "Tests/images/argb-32bpp_MipMaps-1.dds" TEST_FILE_DX10_R8G8B8A8_UNORM_SRGB = "Tests/images/DXGI_FORMAT_R8G8B8A8_UNORM_SRGB.dds" +TEST_FILE_UNCOMPRESSED_L = "Tests/images/uncompressed_l.dds" +TEST_FILE_UNCOMPRESSED_L_WITH_ALPHA = "Tests/images/uncompressed_la.dds" TEST_FILE_UNCOMPRESSED_RGB = "Tests/images/hopper.dds" TEST_FILE_UNCOMPRESSED_RGB_WITH_ALPHA = "Tests/images/uncompressed_rgb.dds" @@ -62,6 +68,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"), ( @@ -86,6 +118,20 @@ def test_dx10_bc5(image_path, expected_path): assert_image_equal_tofile(im, expected_path.replace(".dds", ".png")) +@pytest.mark.parametrize("image_path", (TEST_FILE_BC6H, TEST_FILE_BC6HS)) +def test_dx10_bc6h(image_path): + """Check DX10 BC6H/BC6HS images can be opened""" + + with Image.open(image_path) as im: + im.load() + + assert im.format == "DDS" + assert im.mode == "RGB" + assert im.size == (128, 128) + + assert_image_equal_tofile(im, image_path.replace(".dds", ".png")) + + def test_dx10_bc7(): """Check DX10 images can be opened""" @@ -150,26 +196,24 @@ def test_unimplemented_dxgi_format(): pass -def test_uncompressed_rgb(): - """Check uncompressed RGB images can be opened""" - - # convert -format dds -define dds:compression=none hopper.jpg hopper.dds - with Image.open(TEST_FILE_UNCOMPRESSED_RGB) as im: - assert im.format == "DDS" - assert im.mode == "RGB" - assert im.size == (128, 128) - - assert_image_equal_tofile(im, "Tests/images/hopper.png") +@pytest.mark.parametrize( + ("mode", "size", "test_file"), + [ + ("L", (128, 128), TEST_FILE_UNCOMPRESSED_L), + ("LA", (128, 128), TEST_FILE_UNCOMPRESSED_L_WITH_ALPHA), + ("RGB", (128, 128), TEST_FILE_UNCOMPRESSED_RGB), + ("RGBA", (800, 600), TEST_FILE_UNCOMPRESSED_RGB_WITH_ALPHA), + ], +) +def test_uncompressed(mode, size, test_file): + """Check uncompressed images can be opened""" - # Test image with alpha - with Image.open(TEST_FILE_UNCOMPRESSED_RGB_WITH_ALPHA) as im: + with Image.open(test_file) as im: assert im.format == "DDS" - assert im.mode == "RGBA" - assert im.size == (800, 600) + assert im.mode == mode + assert im.size == size - assert_image_equal_tofile( - im, TEST_FILE_UNCOMPRESSED_RGB_WITH_ALPHA.replace(".dds", ".png") - ) + assert_image_equal_tofile(im, test_file.replace(".dds", ".png")) def test__accept_true(): @@ -196,6 +240,13 @@ def test__accept_false(): assert not output +def test_invalid_file(): + invalid_file = "Tests/images/flower.jpg" + + with pytest.raises(SyntaxError): + DdsImagePlugin.DdsImageFile(invalid_file) + + def test_short_header(): """Check a short header""" with open(TEST_FILE_DXT5, "rb") as f: @@ -254,6 +305,8 @@ def test_save_unsupported_mode(tmp_path): @pytest.mark.parametrize( ("mode", "test_file"), [ + ("L", "Tests/images/linear_gradient.png"), + ("LA", "Tests/images/uncompressed_la.png"), ("RGB", "Tests/images/hopper.png"), ("RGBA", "Tests/images/pil123rgba.png"), ], diff --git a/Tests/test_file_eps.py b/Tests/test_file_eps.py index 4c0b96f7376..015dda992c6 100644 --- a/Tests/test_file_eps.py +++ b/Tests/test_file_eps.py @@ -58,6 +58,15 @@ def test_sanity(): assert image2_scale2.format == "EPS" +@pytest.mark.skipif(not HAS_GHOSTSCRIPT, reason="Ghostscript not available") +def test_load(): + with Image.open(FILE1) as im: + assert im.load()[0, 0] == (255, 255, 255) + + # Test again now that it has already been loaded once + assert im.load()[0, 0] == (255, 255, 255) + + def test_invalid_file(): invalid_file = "Tests/images/flower.jpg" @@ -115,14 +124,6 @@ def test_file_object(tmp_path): image1.save(fh, "EPS") -@pytest.mark.skipif(not HAS_GHOSTSCRIPT, reason="Ghostscript not available") -def test_iobase_object(tmp_path): - # issue 479 - with Image.open(FILE1) as image1: - with open(str(tmp_path / "temp_iobase.eps"), "wb") as fh: - image1.save(fh, "EPS") - - @pytest.mark.skipif(not HAS_GHOSTSCRIPT, reason="Ghostscript not available") def test_bytesio_object(): with open(FILE1, "rb") as f: @@ -137,6 +138,11 @@ def test_bytesio_object(): assert_image_similar(img, image1_scale1_compare, 5) +def test_1_mode(): + with Image.open("Tests/images/1.eps") as im: + assert im.mode == "1" + + def test_image_mode_not_supported(tmp_path): im = hopper("RGBA") tmpfile = str(tmp_path / "temp.eps") @@ -189,25 +195,23 @@ def test_render_scale2(): @pytest.mark.skipif(not HAS_GHOSTSCRIPT, reason="Ghostscript not available") -def test_resize(): - files = [FILE1, FILE2, "Tests/images/illu10_preview.eps"] - for fn in files: - with Image.open(fn) as im: - new_size = (100, 100) - im = im.resize(new_size) - assert im.size == new_size +@pytest.mark.parametrize("filename", (FILE1, FILE2, "Tests/images/illu10_preview.eps")) +def test_resize(filename): + with Image.open(filename) as im: + new_size = (100, 100) + im = im.resize(new_size) + assert im.size == new_size @pytest.mark.skipif(not HAS_GHOSTSCRIPT, reason="Ghostscript not available") -def test_thumbnail(): +@pytest.mark.parametrize("filename", (FILE1, FILE2)) +def test_thumbnail(filename): # Issue #619 # Arrange - files = [FILE1, FILE2] - for fn in files: - with Image.open(FILE1) as im: - new_size = (100, 100) - im.thumbnail(new_size) - assert max(im.size) == max(new_size) + with Image.open(filename) as im: + new_size = (100, 100) + im.thumbnail(new_size) + assert max(im.size) == max(new_size) def test_read_binary_preview(): @@ -252,20 +256,19 @@ def _test_readline_file_psfile(test_string, ending): _test_readline_file_psfile(s, ending) -def test_open_eps(): - # https://github.com/python-pillow/Pillow/issues/1104 - # Arrange - FILES = [ +@pytest.mark.parametrize( + "filename", + ( "Tests/images/illu10_no_preview.eps", "Tests/images/illu10_preview.eps", "Tests/images/illuCS6_no_preview.eps", "Tests/images/illuCS6_preview.eps", - ] - - # Act / Assert - for filename in FILES: - with Image.open(filename) as img: - assert img.mode == "RGB" + ), +) +def test_open_eps(filename): + # https://github.com/python-pillow/Pillow/issues/1104 + with Image.open(filename) as img: + assert img.mode == "RGB" @pytest.mark.skipif(not HAS_GHOSTSCRIPT, reason="Ghostscript not available") diff --git a/Tests/test_file_fits.py b/Tests/test_file_fits.py new file mode 100644 index 00000000000..447888acd8d --- /dev/null +++ b/Tests/test_file_fits.py @@ -0,0 +1,80 @@ +from io import BytesIO + +import pytest + +from PIL import FitsImagePlugin, FitsStubImagePlugin, Image + +from .helper import assert_image_equal, hopper + +TEST_FILE = "Tests/images/hopper.fits" + + +def test_open(): + # Act + with Image.open(TEST_FILE) as im: + + # Assert + assert im.format == "FITS" + assert im.size == (128, 128) + assert im.mode == "L" + + assert_image_equal(im, hopper("L")) + + +def test_invalid_file(): + # Arrange + invalid_file = "Tests/images/flower.jpg" + + # Act / Assert + with pytest.raises(SyntaxError): + FitsImagePlugin.FitsImageFile(invalid_file) + + +def test_truncated_fits(): + # No END to headers + image_data = b"SIMPLE = T" + b" " * 50 + b"TRUNCATE" + with pytest.raises(OSError): + FitsImagePlugin.FitsImageFile(BytesIO(image_data)) + + +def test_naxis_zero(): + # This test image has been manually hexedited + # to set the number of data axes to zero + with pytest.raises(ValueError): + with Image.open("Tests/images/hopper_naxis_zero.fits"): + pass + + +def test_stub_deprecated(): + class Handler: + opened = False + loaded = False + + def open(self, im): + self.opened = True + + def load(self, im): + self.loaded = True + return Image.new("RGB", (1, 1)) + + handler = Handler() + with pytest.warns(DeprecationWarning): + FitsStubImagePlugin.register_handler(handler) + + with Image.open(TEST_FILE) as im: + assert im.format == "FITS" + assert im.size == (128, 128) + assert im.mode == "L" + + assert handler.opened + assert not handler.loaded + + im.load() + assert handler.loaded + + FitsStubImagePlugin._handler = None + Image.register_open( + FitsImagePlugin.FitsImageFile.format, + FitsImagePlugin.FitsImageFile, + FitsImagePlugin._accept, + ) diff --git a/Tests/test_file_fitsstub.py b/Tests/test_file_fitsstub.py deleted file mode 100644 index c77457947ef..00000000000 --- a/Tests/test_file_fitsstub.py +++ /dev/null @@ -1,63 +0,0 @@ -from io import BytesIO - -import pytest - -from PIL import FitsStubImagePlugin, Image - -TEST_FILE = "Tests/images/hopper.fits" - - -def test_open(): - # Act - with Image.open(TEST_FILE) as im: - - # Assert - assert im.format == "FITS" - assert im.size == (128, 128) - assert im.mode == "L" - - -def test_invalid_file(): - # Arrange - invalid_file = "Tests/images/flower.jpg" - - # Act / Assert - with pytest.raises(SyntaxError): - FitsStubImagePlugin.FITSStubImageFile(invalid_file) - - -def test_load(): - # Arrange - with Image.open(TEST_FILE) as im: - - # Act / Assert: stub cannot load without an implemented handler - with pytest.raises(OSError): - im.load() - - -def test_truncated_fits(): - # No END to headers - image_data = b"SIMPLE = T" + b" " * 50 + b"TRUNCATE" - with pytest.raises(OSError): - FitsStubImagePlugin.FITSStubImageFile(BytesIO(image_data)) - - -def test_naxis_zero(): - # This test image has been manually hexedited - # to set the number of data axes to zero - with pytest.raises(ValueError): - with Image.open("Tests/images/hopper_naxis_zero.fits"): - pass - - -def test_save(): - # Arrange - with Image.open(TEST_FILE) as im: - dummy_fp = None - dummy_filename = "dummy.filename" - - # Act / Assert: stub cannot save without an implemented handler - with pytest.raises(OSError): - im.save(dummy_filename) - with pytest.raises(OSError): - FitsStubImagePlugin._save(im, dummy_fp, dummy_filename) diff --git a/Tests/test_file_fli.py b/Tests/test_file_fli.py index 675e06bf83c..b8b999d70d0 100644 --- a/Tests/test_file_fli.py +++ b/Tests/test_file_fli.py @@ -1,8 +1,10 @@ +import warnings + import pytest from PIL import FliImagePlugin, Image -from .helper import assert_image_equal_tofile, is_pypy +from .helper import assert_image_equal, assert_image_equal_tofile, is_pypy # created as an export of a palette image from Gimp2.6 # save as...-> hopper.fli, default options. @@ -38,21 +40,26 @@ def open(): def test_closed_file(): - with pytest.warns(None) as record: + with warnings.catch_warnings(): im = Image.open(static_test_file) im.load() im.close() - assert not record + +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 pytest.warns(None) as record: + with warnings.catch_warnings(): with Image.open(static_test_file) as im: im.load() - assert not record - def test_tell(): # Arrange @@ -72,6 +79,12 @@ def test_invalid_file(): FliImagePlugin.FliImageFile(invalid_file) +def test_palette_chunk_second(): + with Image.open("Tests/images/hopper_palette_chunk_second.fli") as im: + with Image.open(static_test_file) as expected: + assert_image_equal(im.convert("RGB"), expected.convert("RGB")) + + def test_n_frames(): with Image.open(static_test_file) as im: assert im.n_frames == 1 diff --git a/Tests/test_file_fpx.py b/Tests/test_file_fpx.py index 818565f88b3..fa22e90f660 100644 --- a/Tests/test_file_fpx.py +++ b/Tests/test_file_fpx.py @@ -2,11 +2,22 @@ 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_ftex.py b/Tests/test_file_ftex.py index f76fd895a58..cae20fa46eb 100644 --- a/Tests/test_file_ftex.py +++ b/Tests/test_file_ftex.py @@ -1,4 +1,6 @@ -from PIL import Image +import pytest + +from PIL import FtexImagePlugin, Image from .helper import assert_image_equal_tofile, assert_image_similar @@ -12,3 +14,19 @@ def test_load_dxt1(): with Image.open("Tests/images/ftex_dxt1.ftc") as im: with Image.open("Tests/images/ftex_dxt1.png") as target: assert_image_similar(im, target.convert("RGBA"), 15) + + +def test_invalid_file(): + invalid_file = "Tests/images/flower.jpg" + + with pytest.raises(SyntaxError): + FtexImagePlugin.FtexImageFile(invalid_file) + + +def test_constants_deprecation(): + for enum, prefix in { + FtexImagePlugin.Format: "FORMAT_", + }.items(): + for name in enum.__members__: + with pytest.warns(DeprecationWarning): + assert getattr(FtexImagePlugin, prefix + name) == enum[name] diff --git a/Tests/test_file_gbr.py b/Tests/test_file_gbr.py index 8d7fcf14779..1ea8af8ee34 100644 --- a/Tests/test_file_gbr.py +++ b/Tests/test_file_gbr.py @@ -5,20 +5,28 @@ from .helper import assert_image_equal_tofile -def test_invalid_file(): - invalid_file = "Tests/images/flower.jpg" - - with pytest.raises(SyntaxError): - GbrImagePlugin.GbrImageFile(invalid_file) - - def test_gbr_file(): with Image.open("Tests/images/gbr.gbr") as im: assert_image_equal_tofile(im, "Tests/images/gbr.png") +def test_load(): + with Image.open("Tests/images/gbr.gbr") as im: + assert im.load()[0, 0] == (0, 0, 0, 0) + + # Test again now that it has already been loaded once + assert im.load()[0, 0] == (0, 0, 0, 0) + + def test_multiple_load_operations(): with Image.open("Tests/images/gbr.gbr") as im: im.load() im.load() assert_image_equal_tofile(im, "Tests/images/gbr.png") + + +def test_invalid_file(): + invalid_file = "Tests/images/flower.jpg" + + with pytest.raises(SyntaxError): + GbrImagePlugin.GbrImageFile(invalid_file) diff --git a/Tests/test_file_gif.py b/Tests/test_file_gif.py index 00bf582fafb..d48fc144205 100644 --- a/Tests/test_file_gif.py +++ b/Tests/test_file_gif.py @@ -1,8 +1,9 @@ +import warnings from io import BytesIO import pytest -from PIL import GifImagePlugin, Image, ImageDraw, ImagePalette, features +from PIL import GifImagePlugin, Image, ImageDraw, ImagePalette, ImageSequence, features from .helper import ( assert_image_equal, @@ -39,21 +40,30 @@ def open(): def test_closed_file(): - with pytest.warns(None) as record: + with warnings.catch_warnings(): im = Image.open(TEST_GIF) im.load() im.close() - assert not record + +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 pytest.warns(None) as record: + with warnings.catch_warnings(): with Image.open(TEST_GIF) as im: im.load() - assert not record - def test_invalid_file(): invalid_file = "Tests/images/flower.jpg" @@ -62,6 +72,73 @@ def test_invalid_file(): GifImagePlugin.GifImageFile(invalid_file) +def test_l_mode_transparency(): + with Image.open("Tests/images/no_palette_with_transparency.gif") as im: + assert im.mode == "L" + assert im.load()[0, 0] == 128 + assert im.info["transparency"] == 255 + + im.seek(1) + assert im.mode == "L" + assert im.load()[0, 0] == 128 + + +def test_l_mode_after_rgb(): + with Image.open("Tests/images/no_palette_after_rgb.gif") as im: + im.seek(1) + assert im.mode == "RGB" + + im.seek(2) + assert im.mode == "RGB" + + +def test_palette_not_needed_for_second_frame(): + with Image.open("Tests/images/palette_not_needed_for_second_frame.gif") as im: + im.seek(1) + assert_image_similar(im, hopper("L").convert("RGB"), 8) + + +def test_strategy(): + with Image.open("Tests/images/iss634.gif") as im: + expected_rgb_always = im.convert("RGB") + + with Image.open("Tests/images/chi.gif") as im: + expected_rgb_always_rgba = im.convert("RGBA") + + im.seek(1) + expected_different = im.convert("RGB") + + try: + GifImagePlugin.LOADING_STRATEGY = GifImagePlugin.LoadingStrategy.RGB_ALWAYS + with Image.open("Tests/images/iss634.gif") as im: + assert im.mode == "RGB" + assert_image_equal(im, expected_rgb_always) + + with Image.open("Tests/images/chi.gif") as im: + assert im.mode == "RGBA" + assert_image_equal(im, expected_rgb_always_rgba) + + GifImagePlugin.LOADING_STRATEGY = ( + GifImagePlugin.LoadingStrategy.RGB_AFTER_DIFFERENT_PALETTE_ONLY + ) + # Stay in P mode with only a global palette + with Image.open("Tests/images/chi.gif") as im: + assert im.mode == "P" + + im.seek(1) + assert im.mode == "P" + assert_image_equal(im.convert("RGB"), expected_different) + + # Change to RGB mode when a frame has an individual palette + with Image.open("Tests/images/iss634.gif") as im: + assert im.mode == "P" + + im.seek(1) + assert im.mode == "RGB" + finally: + GifImagePlugin.LOADING_STRATEGY = GifImagePlugin.LoadingStrategy.RGB_AFTER_FIRST + + def test_optimize(): def test_grayscale(optimize): im = Image.new("L", (1, 1), 0) @@ -103,6 +180,9 @@ def check(colors, size, expected_palette_length): 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) @@ -112,11 +192,6 @@ def check(colors, size, expected_palette_length): 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))) @@ -125,6 +200,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() @@ -210,8 +298,8 @@ def test_palette_handling(tmp_path): with Image.open(TEST_GIF) as im: im = im.convert("RGB") - im = im.resize((100, 100), Image.LANCZOS) - im2 = im.convert("P", palette=Image.ADAPTIVE, colors=256) + im = im.resize((100, 100), Image.Resampling.LANCZOS) + im2 = im.convert("P", palette=Image.Palette.ADAPTIVE, colors=256) f = str(tmp_path / "temp.gif") im2.save(f, optimize=True) @@ -299,16 +387,44 @@ 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(): + # Test n_frames does not change the image + with Image.open("Tests/images/dispose_bgnd.gif") as im: + im.seek(1) + expected = im.copy() + assert im.n_frames == 5 + assert_image_equal(im, expected) + + # Test is_animated does not change the image + with Image.open("Tests/images/dispose_bgnd.gif") as im: + im.seek(3) + expected = im.copy() + 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(): @@ -370,18 +486,38 @@ def test_dispose_background_transparency(): assert px[35, 30][3] == 0 -def test_transparent_dispose(): - expected_colors = [ - (2, 1, 2), - ((0, 255, 24, 255), (0, 0, 255, 255), (0, 255, 24, 255)), - ((0, 0, 0, 0), (0, 0, 255, 255), (0, 0, 0, 0)), - ] - with Image.open("Tests/images/transparent_dispose.gif") as img: - for frame in range(3): - img.seek(frame) - for x in range(3): - color = img.getpixel((x, 0)) - assert color == expected_colors[frame][x] +@pytest.mark.parametrize( + "loading_strategy, expected_colors", + ( + ( + GifImagePlugin.LoadingStrategy.RGB_AFTER_FIRST, + ( + (2, 1, 2), + ((0, 255, 24, 255), (0, 0, 255, 255), (0, 255, 24, 255)), + ((0, 0, 0, 0), (0, 0, 255, 255), (0, 0, 0, 0)), + ), + ), + ( + GifImagePlugin.LoadingStrategy.RGB_AFTER_DIFFERENT_PALETTE_ONLY, + ( + (2, 1, 2), + (0, 1, 0), + (2, 1, 2), + ), + ), + ), +) +def test_transparent_dispose(loading_strategy, expected_colors): + GifImagePlugin.LOADING_STRATEGY = loading_strategy + try: + with Image.open("Tests/images/transparent_dispose.gif") as img: + for frame in range(3): + img.seek(frame) + for x in range(3): + color = img.getpixel((x, 0)) + assert color == expected_colors[frame][x] + finally: + GifImagePlugin.LOADING_STRATEGY = GifImagePlugin.LoadingStrategy.RGB_AFTER_FIRST def test_dispose_previous(): @@ -541,7 +677,26 @@ def test_dispose2_background(tmp_path): assert im.getpixel((0, 0)) == (255, 0, 0) -def test_transparency_in_second_frame(): +def test_dispose2_background_frame(tmp_path): + out = str(tmp_path / "temp.gif") + + im_list = [Image.new("RGBA", (1, 20))] + + different_frame = Image.new("RGBA", (1, 20)) + different_frame.putpixel((0, 10), (255, 0, 0, 255)) + im_list.append(different_frame) + + # Frame that matches the background + im_list.append(Image.new("RGBA", (1, 20))) + + im_list[0].save(out, save_all=True, append_images=im_list[1:], disposal=2) + + with Image.open(out) as im: + assert im.n_frames == 3 + + +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 @@ -551,6 +706,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: @@ -562,6 +725,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 @@ -613,6 +792,39 @@ def test_multiple_duration(tmp_path): pass +def test_roundtrip_info_duration(tmp_path): + duration_list = [100, 500, 500] + + out = str(tmp_path / "temp.gif") + with Image.open("Tests/images/transparent_dispose.gif") as im: + assert [ + frame.info["duration"] for frame in ImageSequence.Iterator(im) + ] == duration_list + + im.save(out, save_all=True) + + with Image.open(out) as reloaded: + assert [ + frame.info["duration"] for frame in ImageSequence.Iterator(reloaded) + ] == duration_list + + +def test_roundtrip_info_duration_combined(tmp_path): + out = str(tmp_path / "temp.gif") + with Image.open("Tests/images/duplicate_frame.gif") as im: + assert [frame.info["duration"] for frame in ImageSequence.Iterator(im)] == [ + 1000, + 1000, + 1000, + ] + im.save(out, save_all=True) + + with Image.open(out) as reloaded: + assert [ + frame.info["duration"] for frame in ImageSequence.Iterator(reloaded) + ] == [1000, 2000] + + def test_identical_frames(tmp_path): duration_list = [1000, 1500, 2000, 4000] @@ -637,24 +849,24 @@ def test_identical_frames(tmp_path): assert reread.info["duration"] == 4500 -def test_identical_frames_to_single_frame(tmp_path): - for duration in ([1000, 1500, 2000, 4000], (1000, 1500, 2000, 4000), 8500): - out = str(tmp_path / "temp.gif") - im_list = [ - Image.new("L", (100, 100), "#000"), - Image.new("L", (100, 100), "#000"), - Image.new("L", (100, 100), "#000"), - ] +@pytest.mark.parametrize( + "duration", ([1000, 1500, 2000, 4000], (1000, 1500, 2000, 4000), 8500) +) +def test_identical_frames_to_single_frame(duration, tmp_path): + out = str(tmp_path / "temp.gif") + im_list = [ + Image.new("L", (100, 100), "#000"), + Image.new("L", (100, 100), "#000"), + Image.new("L", (100, 100), "#000"), + ] - im_list[0].save( - out, save_all=True, append_images=im_list[1:], duration=duration - ) - with Image.open(out) as reread: - # Assert that all frames were combined - assert reread.n_frames == 1 + im_list[0].save(out, save_all=True, append_images=im_list[1:], duration=duration) + with Image.open(out) as reread: + # Assert that all frames were combined + assert reread.n_frames == 1 - # Assert that the new duration is the total of the identical frames - assert reread.info["duration"] == 8500 + # Assert that the new duration is the total of the identical frames + assert reread.info["duration"] == 8500 def test_number_of_loops(tmp_path): @@ -664,9 +876,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") @@ -674,14 +893,23 @@ def test_background(tmp_path): im.info["background"] = 1 im.save(out) with Image.open(out) as reread: - assert reread.info["background"] == im.info["background"] + +def test_webp_background(tmp_path): + out = str(tmp_path / "temp.gif") + + # Test opaque WebP background if features.check("webp") and features.check("webp_anim"): with Image.open("Tests/images/hopper.webp") as im: - assert isinstance(im.info["background"], tuple) + assert im.info["background"] == (255, 255, 255, 255) im.save(out) + # Test non-opaque WebP background + im = Image.new("L", (100, 100), "#000") + im.info["background"] = (0, 0, 0, 0) + im.save(out) + def test_comment(tmp_path): with Image.open(TEST_GIF) as im: @@ -699,6 +927,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") @@ -709,43 +940,95 @@ 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") - def assertVersionAfterSave(im, version): + def assert_version_after_save(im, version): im.save(out) with Image.open(out) as reread: assert reread.info["version"] == version # Test that GIF87a is used by default im = Image.new("L", (100, 100), "#000") - assertVersionAfterSave(im, b"GIF87a") + assert_version_after_save(im, b"GIF87a") # Test setting the version to 89a im = Image.new("L", (100, 100), "#000") im.info["version"] = b"89a" - assertVersionAfterSave(im, b"GIF89a") + assert_version_after_save(im, b"GIF89a") # Test that adding a GIF89a feature changes the version im.info["transparency"] = 1 - assertVersionAfterSave(im, b"GIF89a") + assert_version_after_save(im, b"GIF89a") # Test that a GIF87a image is also saved in that format with Image.open("Tests/images/test.colors.gif") as im: - assertVersionAfterSave(im, b"GIF87a") + assert_version_after_save(im, b"GIF87a") # Test that a GIF89a image is also saved in that format im.info["version"] = b"GIF89a" - assertVersionAfterSave(im, b"GIF87a") + assert_version_after_save(im, b"GIF87a") def test_append_images(tmp_path): @@ -760,10 +1043,10 @@ def test_append_images(tmp_path): assert reread.n_frames == 3 # Tests appending using a generator - def imGenerator(ims): + def im_generator(ims): yield from ims - im.save(out, save_all=True, append_images=imGenerator(ims)) + im.save(out, save_all=True, append_images=im_generator(ims)) with Image.open(out) as reread: assert reread.n_frames == 3 @@ -780,8 +1063,8 @@ def imGenerator(ims): 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) @@ -791,10 +1074,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): @@ -818,6 +1101,17 @@ def test_rgb_transparency(tmp_path): assert "transparency" not in reloaded.info +def test_rgba_transparency(tmp_path): + out = str(tmp_path / "temp.gif") + + im = hopper("P") + im.save(out, save_all=True, append_images=[Image.new("RGBA", im.size)]) + + with Image.open(out) as reloaded: + reloaded.seek(1) + assert_image_equal(hopper("P").convert("RGB"), reloaded) + + def test_bbox(tmp_path): out = str(tmp_path / "temp.gif") @@ -858,6 +1152,19 @@ def test_palette_save_P(tmp_path): assert_image_equal(reloaded, im) +def test_palette_save_duplicate_entries(tmp_path): + im = Image.new("P", (1, 2)) + im.putpixel((0, 1), 1) + + im.putpalette((0, 0, 0, 0, 0, 0)) + + out = str(tmp_path / "temp.gif") + im.save(out, palette=[0, 0, 0, 0, 0, 0, 1, 1, 1]) + + with Image.open(out) as reloaded: + assert reloaded.convert("RGB").getpixel((0, 1)) == (0, 0, 0) + + def test_palette_save_all_P(tmp_path): frames = [] colors = ((255, 0, 0), (0, 255, 0)) @@ -911,7 +1218,7 @@ def test_save_I(tmp_path): def test_getdata(): # Test getheader/getdata against legacy values. # Create a 'P' image with holes in the palette. - im = Image._wedge().resize((16, 16), Image.NEAREST) + im = Image._wedge().resize((16, 16), Image.Resampling.NEAREST) im.putpalette(ImagePalette.ImagePalette("RGB")) im.info = {"background": 0} @@ -947,6 +1254,11 @@ def test_lzw_bits(): def test_extents(): with Image.open("Tests/images/test_extents.gif") as im: assert im.size == (100, 100) + + # Check that n_frames does not change the size + assert im.n_frames == 2 + assert im.size == (100, 100) + im.seek(1) assert im.size == (150, 150) diff --git a/Tests/test_file_gribstub.py b/Tests/test_file_gribstub.py index e4930d8dc2e..fd427746e96 100644 --- a/Tests/test_file_gribstub.py +++ b/Tests/test_file_gribstub.py @@ -45,3 +45,35 @@ def test_save(tmp_path): # Act / Assert: stub cannot save without an implemented handler with pytest.raises(OSError): im.save(tmpfile) + + +def test_handler(tmp_path): + class TestHandler: + opened = False + loaded = False + saved = False + + def open(self, im): + self.opened = True + + def load(self, im): + self.loaded = True + return Image.new("RGB", (1, 1)) + + def save(self, im, fp, filename): + self.saved = True + + handler = TestHandler() + GribStubImagePlugin.register_handler(handler) + with Image.open(TEST_FILE) as im: + assert handler.opened + assert not handler.loaded + + im.load() + assert handler.loaded + + temp_file = str(tmp_path / "temp.grib") + im.save(temp_file) + assert handler.saved + + GribStubImagePlugin._handler = None diff --git a/Tests/test_file_hdf5stub.py b/Tests/test_file_hdf5stub.py index ff339705522..20b4b9619af 100644 --- a/Tests/test_file_hdf5stub.py +++ b/Tests/test_file_hdf5stub.py @@ -46,3 +46,35 @@ def test_save(): im.save(dummy_filename) with pytest.raises(OSError): Hdf5StubImagePlugin._save(im, dummy_fp, dummy_filename) + + +def test_handler(tmp_path): + class TestHandler: + opened = False + loaded = False + saved = False + + def open(self, im): + self.opened = True + + def load(self, im): + self.loaded = True + return Image.new("RGB", (1, 1)) + + def save(self, im, fp, filename): + self.saved = True + + handler = TestHandler() + Hdf5StubImagePlugin.register_handler(handler) + with Image.open(TEST_FILE) as im: + assert handler.opened + assert not handler.loaded + + im.load() + assert handler.loaded + + temp_file = str(tmp_path / "temp.h5") + im.save(temp_file) + assert handler.saved + + Hdf5StubImagePlugin._handler = None diff --git a/Tests/test_file_icns.py b/Tests/test_file_icns.py index 3afbbeaac05..55632909c6b 100644 --- a/Tests/test_file_icns.py +++ b/Tests/test_file_icns.py @@ -1,17 +1,16 @@ import io import os +import warnings import pytest -from PIL import IcnsImagePlugin, Image, _binary, features +from PIL import IcnsImagePlugin, Image, _binary -from .helper import assert_image_equal, assert_image_similar_tofile +from .helper import assert_image_equal, assert_image_similar_tofile, skip_unless_feature # sample icon file TEST_FILE = "Tests/images/pillow.icns" -ENABLE_JPEG2K = features.check_codec("jpg_2000") - def test_sanity(): # Loading this icon by default should result in the largest size @@ -19,15 +18,22 @@ def test_sanity(): with Image.open(TEST_FILE) as im: # Assert that there is no unclosed file warning - with pytest.warns(None) as record: + with warnings.catch_warnings(): im.load() - assert not record assert im.mode == "RGBA" assert im.size == (1024, 1024) assert im.format == "ICNS" +def test_load(): + with Image.open(TEST_FILE) as im: + assert im.load()[0, 0] == (0, 0, 0, 0) + + # Test again now that it has already been loaded once + assert im.load()[0, 0] == (0, 0, 0, 0) + + def test_save(tmp_path): temp_file = str(tmp_path / "temp.icns") @@ -103,16 +109,11 @@ def test_older_icon(): assert im2.size == (wr, hr) +@skip_unless_feature("jpg_2000") def test_jp2_icon(): - # This icon was made by using Uli Kusterer's oldiconutil to replace - # the PNG images with JPEG 2000 ones. The advantage of doing this is - # that OS X 10.5 supports JPEG 2000 but not PNG; some commercial - # software therefore does just this. - - # (oldiconutil is here: https://github.com/uliwitness/oldiconutil) - - if not ENABLE_JPEG2K: - return + # This icon uses JPEG 2000 images instead of the PNG images. + # The advantage of doing this is that OS X 10.5 supports JPEG 2000 + # but not PNG; some commercial software therefore does just this. with Image.open("Tests/images/pillow3.icns") as im: for w, h, r in im.info["sizes"]: @@ -144,6 +145,7 @@ def test_not_an_icns_file(): IcnsImagePlugin.IcnsFile(fp) +@skip_unless_feature("jpg_2000") def test_icns_decompression_bomb(): with Image.open( "Tests/images/oom-8ed3316a4109213ca96fb8a256a0bfefdece1461.icns" diff --git a/Tests/test_file_ico.py b/Tests/test_file_ico.py index 317264db646..afb17b1afad 100644 --- a/Tests/test_file_ico.py +++ b/Tests/test_file_ico.py @@ -1,4 +1,5 @@ import io +import os import pytest @@ -18,6 +19,11 @@ def test_sanity(): assert im.get_format_mimetype() == "image/x-icon" +def test_load(): + with Image.open(TEST_ICO_FILE) as im: + assert im.load()[0, 0] == (1, 1, 9, 255) + + def test_mask(): with Image.open("Tests/images/hopper_mask.ico") as im: assert_image_equal_tofile(im, "Tests/images/hopper_mask.png") @@ -48,7 +54,9 @@ def test_save_to_bytes(): assert im.mode == reloaded.mode assert (64, 64) == reloaded.size assert reloaded.format == "ICO" - assert_image_equal(reloaded, hopper().resize((64, 64), Image.LANCZOS)) + assert_image_equal( + reloaded, hopper().resize((64, 64), Image.Resampling.LANCZOS) + ) # The other one output.seek(0) @@ -58,7 +66,69 @@ def test_save_to_bytes(): assert im.mode == reloaded.mode assert (32, 32) == reloaded.size assert reloaded.format == "ICO" - assert_image_equal(reloaded, hopper().resize((32, 32), Image.LANCZOS)) + assert_image_equal( + reloaded, hopper().resize((32, 32), Image.Resampling.LANCZOS) + ) + + +def test_getpixel(tmp_path): + temp_file = str(tmp_path / "temp.ico") + + im = hopper() + im.save(temp_file, "ico", sizes=[(32, 32), (64, 64)]) + + with Image.open(temp_file) as reloaded: + reloaded.load() + reloaded.size = (32, 32) + + assert reloaded.getpixel((0, 0)) == (18, 20, 62) + + +def test_no_duplicates(tmp_path): + temp_file = str(tmp_path / "temp.ico") + temp_file2 = str(tmp_path / "temp2.ico") + + im = hopper() + sizes = [(32, 32), (64, 64)] + im.save(temp_file, "ico", sizes=sizes) + + sizes.append(sizes[-1]) + im.save(temp_file2, "ico", sizes=sizes) + + assert os.path.getsize(temp_file) == os.path.getsize(temp_file2) + + +def test_different_bit_depths(tmp_path): + temp_file = str(tmp_path / "temp.ico") + temp_file2 = str(tmp_path / "temp2.ico") + + im = hopper() + im.save(temp_file, "ico", bitmap_format="bmp", sizes=[(128, 128)]) + + hopper("1").save( + temp_file2, + "ico", + bitmap_format="bmp", + sizes=[(128, 128)], + append_images=[im], + ) + + assert os.path.getsize(temp_file) != os.path.getsize(temp_file2) + + # Test that only matching sizes of different bit depths are saved + temp_file3 = str(tmp_path / "temp3.ico") + temp_file4 = str(tmp_path / "temp4.ico") + + im.save(temp_file3, "ico", bitmap_format="bmp", sizes=[(128, 128)]) + im.save( + temp_file4, + "ico", + bitmap_format="bmp", + sizes=[(128, 128)], + append_images=[Image.new("P", (64, 64))], + ) + + assert os.path.getsize(temp_file3) == os.path.getsize(temp_file4) @pytest.mark.parametrize("mode", ("1", "L", "P", "RGB", "RGBA")) @@ -75,7 +145,7 @@ def test_save_to_bytes_bmp(mode): assert "RGBA" == reloaded.mode assert (64, 64) == reloaded.size assert reloaded.format == "ICO" - im = hopper(mode).resize((64, 64), Image.LANCZOS).convert("RGBA") + im = hopper(mode).resize((64, 64), Image.Resampling.LANCZOS).convert("RGBA") assert_image_equal(reloaded, im) # The other one @@ -86,7 +156,7 @@ def test_save_to_bytes_bmp(mode): assert "RGBA" == reloaded.mode assert (32, 32) == reloaded.size assert reloaded.format == "ICO" - im = hopper(mode).resize((32, 32), Image.LANCZOS).convert("RGBA") + im = hopper(mode).resize((32, 32), Image.Resampling.LANCZOS).convert("RGBA") assert_image_equal(reloaded, im) diff --git a/Tests/test_file_im.py b/Tests/test_file_im.py index 9d25a4d1a8f..5cf93713be4 100644 --- a/Tests/test_file_im.py +++ b/Tests/test_file_im.py @@ -1,4 +1,5 @@ import filecmp +import warnings import pytest @@ -35,21 +36,17 @@ def open(): def test_closed_file(): - with pytest.warns(None) as record: + with warnings.catch_warnings(): im = Image.open(TEST_IM) im.load() im.close() - assert not record - def test_context_manager(): - with pytest.warns(None) as record: + with warnings.catch_warnings(): with Image.open(TEST_IM) as im: im.load() - assert not record - def test_tell(): # Arrange @@ -81,15 +78,24 @@ 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) +@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_small_palette(tmp_path): + im = Image.new("P", (1, 1)) + colors = [0, 1, 2] + im.putpalette(colors) + + out = str(tmp_path / "temp.im") + im.save(out) - for mode in ["RGB", "P", "PA"]: - roundtrip(mode) + with Image.open(out) as reloaded: + assert reloaded.getpalette() == colors + [0] * 765 def test_save_unsupported_mode(tmp_path): diff --git a/Tests/test_file_imt.py b/Tests/test_file_imt.py new file mode 100644 index 00000000000..f56acc42949 --- /dev/null +++ b/Tests/test_file_imt.py @@ -0,0 +1,19 @@ +import io + +import pytest + +from PIL import Image, ImtImagePlugin + +from .helper import assert_image_equal_tofile + + +def test_sanity(): + with Image.open("Tests/images/bw_gradient.imt") as im: + assert_image_equal_tofile(im, "Tests/images/bw_gradient.png") + + +@pytest.mark.parametrize("data", (b"\n", b"\n-", b"width 1\n")) +def test_invalid_file(data): + with io.BytesIO(data) as fp: + with pytest.raises(SyntaxError): + ImtImagePlugin.ImtImageFile(fp) diff --git a/Tests/test_file_jpeg.py b/Tests/test_file_jpeg.py index 4b2ffe70d0c..eabc6bf7593 100644 --- a/Tests/test_file_jpeg.py +++ b/Tests/test_file_jpeg.py @@ -1,5 +1,6 @@ import os import re +import warnings from io import BytesIO import pytest @@ -29,7 +30,7 @@ ) try: - import defusedxml.ElementTree as ElementTree + from defusedxml import ElementTree except ImportError: ElementTree = None @@ -67,6 +68,13 @@ def test_sanity(self): assert im.format == "JPEG" assert im.get_format_mimetype() == "image/jpeg" + @pytest.mark.parametrize("size", ((1, 0), (0, 1), (0, 0))) + def test_zero(self, size, tmp_path): + f = str(tmp_path / "temp.jpg") + im = Image.new("RGB", size) + with pytest.raises(ValueError): + im.save(f) + def test_app(self): # Test APP/COM reader (@PIL135) with Image.open(TEST_FILE) as im: @@ -78,6 +86,33 @@ def test_app(self): assert len(im.applist) == 2 assert im.info["comment"] == b"File written by Adobe Photoshop\xa8 4.0\x00" + assert im.app["COM"] == im.info["comment"] + + def test_comment_write(self): + with Image.open(TEST_FILE) as im: + assert im.info["comment"] == b"File written by Adobe Photoshop\xa8 4.0\x00" + + # Test that existing comment is saved by default + out = BytesIO() + im.save(out, format="JPEG") + with Image.open(out) as reloaded: + assert im.info["comment"] == reloaded.info["comment"] + + # Ensure that a blank comment causes any existing comment to be removed + for comment in ("", b"", None): + out = BytesIO() + im.save(out, format="JPEG", comment=comment) + with Image.open(out) as reloaded: + assert "comment" not in reloaded.info + + # Test that a comment argument overrides the default comment + for comment in ("Test comment text", b"Text comment text"): + out = BytesIO() + im.save(out, format="JPEG", comment=comment) + with Image.open(out) as reloaded: + if not isinstance(comment, bytes): + comment = comment.encode() + assert reloaded.info["comment"] == comment def test_cmyk(self): # Test CMYK handling. Thanks to Tim and Charlie for test data, @@ -142,27 +177,30 @@ def test_icc(self, tmp_path): assert not im1.info.get("icc_profile") assert im2.info.get("icc_profile") - def test_icc_big(self): + @pytest.mark.parametrize( + "n", + ( + 0, + 1, + 3, + 4, + 5, + 65533 - 14, # full JPEG marker block + 65533 - 14 + 1, # full block plus one byte + ImageFile.MAXBLOCK, # full buffer block + ImageFile.MAXBLOCK + 1, # full buffer block plus one byte + ImageFile.MAXBLOCK * 4 + 3, # large block + ), + ) + def test_icc_big(self, n): # Make sure that the "extra" support handles large blocks - def test(n): - # The ICC APP marker can store 65519 bytes per marker, so - # using a 4-byte test code should allow us to detect out of - # order issues. - icc_profile = (b"Test" * int(n / 4 + 1))[:n] - assert len(icc_profile) == n # sanity - im1 = self.roundtrip(hopper(), icc_profile=icc_profile) - assert im1.info.get("icc_profile") == (icc_profile or None) - - test(0) - test(1) - test(3) - test(4) - test(5) - test(65533 - 14) # full JPEG marker block - test(65533 - 14 + 1) # full block plus one byte - test(ImageFile.MAXBLOCK) # full buffer block - test(ImageFile.MAXBLOCK + 1) # full buffer block plus one byte - test(ImageFile.MAXBLOCK * 4 + 3) # large block + # The ICC APP marker can store 65519 bytes per marker, so + # using a 4-byte test code should allow us to detect out of + # order issues. + icc_profile = (b"Test" * int(n / 4 + 1))[:n] + assert len(icc_profile) == n # sanity + im1 = self.roundtrip(hopper(), icc_profile=icc_profile) + assert im1.info.get("icc_profile") == (icc_profile or None) @mark_if_feature_version( pytest.mark.valgrind_known_error, "libjpeg_turbo", "2.0", reason="Known Failing" @@ -271,7 +309,7 @@ def test_empty_exif_gps(self): del exif[0x8769] # Assert that it needs to be transposed - assert exif[0x0112] == Image.TRANSVERSE + assert exif[0x0112] == Image.Transpose.TRANSVERSE # Assert that the GPS IFD is present and empty assert exif.get_ifd(0x8825) == {} @@ -404,6 +442,13 @@ def test_exif(self): info = im._getexif() assert info[305] == "Adobe Photoshop CS Macintosh" + def test_get_child_images(self): + with Image.open("Tests/images/flower.jpg") as im: + ims = im.get_child_images() + + assert len(ims) == 1 + assert_image_equal_tofile(ims[0], "Tests/images/flower_thumbnail.png") + def test_mp(self): with Image.open("Tests/images/pil_sample_rgb.jpg") as im: assert im._getmp() is None @@ -641,19 +686,19 @@ def test_bad_mpo_header(self): # Assert assert im.format == "JPEG" - def test_save_correct_modes(self): + @pytest.mark.parametrize("mode", ("1", "L", "RGB", "RGBX", "CMYK", "YCbCr")) + def test_save_correct_modes(self, mode): out = BytesIO() - for mode in ["1", "L", "RGB", "RGBX", "CMYK", "YCbCr"]: - img = Image.new(mode, (20, 20)) - img.save(out, "JPEG") + img = Image.new(mode, (20, 20)) + img.save(out, "JPEG") - def test_save_wrong_modes(self): + @pytest.mark.parametrize("mode", ("LA", "La", "RGBA", "RGBa", "P")) + def test_save_wrong_modes(self, mode): # ref https://github.com/python-pillow/Pillow/issues/2005 out = BytesIO() - for mode in ["LA", "La", "RGBA", "RGBa", "P"]: - img = Image.new(mode, (20, 20)) - with pytest.raises(OSError): - img.save(out, "JPEG") + img = Image.new(mode, (20, 20)) + with pytest.raises(OSError): + img.save(out, "JPEG") def test_save_tiff_with_dpi(self, tmp_path): # Arrange @@ -735,7 +780,7 @@ def test_no_dpi_in_exif(self): # Act / Assert # "When the image resolution is unknown, 72 [dpi] is designated." - # http://www.exiv2.org/tags.html + # https://exiv2.org/tags.html assert im.info.get("dpi") == (72, 72) def test_invalid_exif(self): @@ -756,9 +801,8 @@ def test_exif_x_resolution(self, tmp_path): assert exif[282] == 180 out = str(tmp_path / "out.jpg") - with pytest.warns(None) as record: + with warnings.catch_warnings(): im.save(out, exif=exif) - assert not record with Image.open(out) as reloaded: assert reloaded.getexif()[282] == 180 diff --git a/Tests/test_file_jpeg2k.py b/Tests/test_file_jpeg2k.py index ca410162a1c..0229b224304 100644 --- a/Tests/test_file_jpeg2k.py +++ b/Tests/test_file_jpeg2k.py @@ -126,14 +126,14 @@ def test_prog_res_rt(): assert_image_equal(im, test_card) -def test_default_num_resolutions(): - for num_resolutions in range(2, 6): - d = 1 << (num_resolutions - 1) - im = test_card.resize((d - 1, d - 1)) - with pytest.raises(OSError): - roundtrip(im, num_resolutions=num_resolutions) - reloaded = roundtrip(im) - assert_image_equal(im, reloaded) +@pytest.mark.parametrize("num_resolutions", range(2, 6)) +def test_default_num_resolutions(num_resolutions): + d = 1 << (num_resolutions - 1) + im = test_card.resize((d - 1, d - 1)) + with pytest.raises(OSError): + roundtrip(im, num_resolutions=num_resolutions) + reloaded = roundtrip(im) + assert_image_equal(im, reloaded) def test_reduce(): @@ -209,6 +209,63 @@ def test_layers(): assert_image_similar(im, test_card, 0.4) +@pytest.mark.parametrize( + "name, args, offset, data", + ( + ("foo.j2k", {}, 0, b"\xff\x4f"), + ("foo.jp2", {}, 4, b"jP"), + (None, {"no_jp2": True}, 0, b"\xff\x4f"), + ("foo.j2k", {"no_jp2": True}, 0, b"\xff\x4f"), + ("foo.jp2", {"no_jp2": True}, 0, b"\xff\x4f"), + ("foo.j2k", {"no_jp2": False}, 0, b"\xff\x4f"), + ("foo.jp2", {"no_jp2": False}, 4, b"jP"), + ("foo.jp2", {"no_jp2": False}, 4, b"jP"), + ), +) +def test_no_jp2(name, args, offset, data): + out = BytesIO() + if name: + out.name = name + test_card.save(out, "JPEG2000", **args) + out.seek(offset) + assert out.read(2) == data + + +def test_mct(): + # Three component + for val in (0, 1): + out = BytesIO() + test_card.save(out, "JPEG2000", mct=val, no_jp2=True) + + assert out.getvalue()[59] == val + with Image.open(out) as im: + assert_image_similar(im, test_card, 1.0e-3) + + # Single component should have MCT disabled + for val in (0, 1): + out = BytesIO() + with Image.open("Tests/images/16bit.cropped.jp2") as jp2: + jp2.save(out, "JPEG2000", mct=val, no_jp2=True) + + assert out.getvalue()[53] == 0 + with Image.open(out) as im: + assert_image_similar(im, jp2, 1.0e-3) + + +def test_sgnd(tmp_path): + outfile = str(tmp_path / "temp.jp2") + + im = Image.new("L", (1, 1)) + im.save(outfile) + with Image.open(outfile) as reloaded: + assert reloaded.getpixel((0, 0)) == 0 + + im = Image.new("L", (1, 1)) + im.save(outfile, signed=True) + with Image.open(outfile) as reloaded_signed: + assert reloaded_signed.getpixel((0, 0)) == 128 + + def test_rgba(): # Arrange with Image.open("Tests/images/rgb_trns_ycbc.j2k") as j2k: @@ -223,14 +280,11 @@ def test_rgba(): assert jp2.mode == "RGBA" -def test_16bit_monochrome_has_correct_mode(): - with Image.open("Tests/images/16bit.cropped.j2k") as j2k: - j2k.load() - assert j2k.mode == "I;16" - - with Image.open("Tests/images/16bit.cropped.jp2") as jp2: - jp2.load() - assert jp2.mode == "I;16" +@pytest.mark.parametrize("ext", (".j2k", ".jp2")) +def test_16bit_monochrome_has_correct_mode(ext): + with Image.open("Tests/images/16bit.cropped" + ext) as im: + im.load() + assert im.mode == "I;16" def test_16bit_monochrome_jp2_like_tiff(): @@ -255,6 +309,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): @@ -291,7 +350,7 @@ def test_subsampling_decode(name): # RGB reference images are downscaled epsilon = 3e-3 width, height = width * 2, height * 2 - expected = im2.resize((width, height), Image.NEAREST) + expected = im2.resize((width, height), Image.Resampling.NEAREST) assert_image_similar(im, expected, epsilon) diff --git a/Tests/test_file_libtiff.py b/Tests/test_file_libtiff.py index e40a19394bf..1109cd15e99 100644 --- a/Tests/test_file_libtiff.py +++ b/Tests/test_file_libtiff.py @@ -3,8 +3,8 @@ import itertools import os import re +import sys from collections import namedtuple -from ctypes import c_float import pytest @@ -112,7 +112,7 @@ def test_g4_write(self, tmp_path): test_file = "Tests/images/hopper_g4_500.tif" with Image.open(test_file) as orig: out = str(tmp_path / "temp.tif") - rot = orig.transpose(Image.ROTATE_90) + rot = orig.transpose(Image.Transpose.ROTATE_90) assert rot.size == (500, 500) rot.save(out) @@ -136,53 +136,50 @@ def test_adobe_deflate_tiff(self): 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) - - 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", - ] - - 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 ( - c_float(val[0][0] / val[0][1]).value - == c_float(value[0][0] / value[0][1]).value - ), f"{tag} didn't roundtrip" - else: - assert ( - c_float(val).value == c_float(value).value - ), f"{tag} didn't roundtrip" + 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() + + # 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() + + 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): @@ -218,7 +215,7 @@ def test_additional_metadata(self, tmp_path): values = { 2: "test", 3: 1, - 4: 2 ** 20, + 4: 2**20, 5: TiffImagePlugin.IFDRational(100, 1), 12: 1.05, } @@ -501,8 +498,8 @@ def test_cmyk_save(self, tmp_path): 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 @@ -513,20 +510,13 @@ def test_palette_save(self, tmp_path): # colormap/palette tag assert len(reloaded.tag_v2[320]) == 768 - def xtest_bw_compression_w_rgb(self, tmp_path): - """This test passes, but when running all tests causes a failure due - to output on stderr from the error thrown by libtiff. We need to - capture that but not now""" - + @pytest.mark.parametrize("compression", ("tiff_ccitt", "group3", "group4")) + def test_bw_compression_w_rgb(self, compression, tmp_path): im = hopper("RGB") out = str(tmp_path / "temp.tif") with pytest.raises(OSError): - im.save(out, compression="tiff_ccitt") - with pytest.raises(OSError): - im.save(out, compression="group3") - with pytest.raises(OSError): - im.save(out, compression="group4") + im.save(out, compression=compression) def test_fp_leak(self): im = Image.open("Tests/images/hopper_g4_500.tif") @@ -836,6 +826,44 @@ def test_sampleformat_write(self, tmp_path): assert reloaded.mode == "F" assert reloaded.getexif()[SAMPLEFORMAT] == 3 + def test_lzma(self, capfd): + try: + with Image.open("Tests/images/hopper_lzma.tif") as im: + assert im.mode == "RGB" + assert im.size == (128, 128) + assert im.format == "TIFF" + im2 = hopper() + assert_image_similar(im, im2, 5) + except OSError: + captured = capfd.readouterr() + if "LZMA compression support is not configured" in captured.err: + pytest.skip("LZMA compression support is not configured") + sys.stdout.write(captured.out) + sys.stderr.write(captured.err) + raise + + def test_webp(self, capfd): + try: + with Image.open("Tests/images/hopper_webp.tif") as im: + assert im.mode == "RGB" + assert im.size == (128, 128) + assert im.format == "TIFF" + assert_image_similar_tofile(im, "Tests/images/hopper_webp.png", 1) + except OSError: + captured = capfd.readouterr() + if "WEBP compression support is not configured" in captured.err: + pytest.skip("WEBP compression support is not configured") + if ( + "Compression scheme 50001 strip decoding is not implemented" + in captured.err + ): + pytest.skip( + "Compression scheme 50001 strip decoding is not implemented" + ) + sys.stdout.write(captured.out) + sys.stderr.write(captured.err) + raise + def test_lzw(self): with Image.open("Tests/images/hopper_lzw.tif") as im: assert im.mode == "RGB" @@ -860,7 +888,7 @@ def test_strip_cmyk_16l_jpeg(self): 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" @@ -868,7 +896,7 @@ def test_strip_ycbcr_jpeg_2x2_sampling(self): 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" @@ -881,7 +909,7 @@ def test_tiled_cmyk_jpeg(self): 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" @@ -889,7 +917,7 @@ def test_tiled_ycbcr_jpeg_1x1_sampling(self): 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 \ @@ -945,7 +973,7 @@ def test_block_tile_tags(self, compression, tmp_path): im.save(out, exif=tags, compression=compression) with Image.open(out) as reloaded: - for tag in tags.keys(): + for tag in tags: assert tag not in reloaded.getexif() def test_old_style_jpeg(self): @@ -1015,14 +1043,18 @@ def test_save_multistrip(self, compression, tmp_path): # 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 9de09645856..3e54762227a 100644 --- a/Tests/test_file_mpo.py +++ b/Tests/test_file_mpo.py @@ -1,18 +1,23 @@ +import warnings from io import BytesIO 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() @@ -22,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") @@ -41,42 +46,48 @@ def open(): def test_closed_file(): - with pytest.warns(None) as record: + with warnings.catch_warnings(): im = Image.open(test_files[0]) im.load() im.close() - assert not record + +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 pytest.warns(None) as record: + with warnings.catch_warnings(): with Image.open(test_files[0]) as im: im.load() - assert not record +@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_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_exif(test_file): + with Image.open(test_file) as im_original: + im_reloaded = roundtrip(im_original, save_all=True, exif=im_original.getexif()) -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 + for im in (im_original, im_reloaded): + info = im._getexif() + assert info[272] == "Nintendo 3DS" + assert info[296] == 2 + assert info[34665] == 188 def test_frame_size(): @@ -88,6 +99,9 @@ def test_frame_size(): im.seek(1) assert im.size == (680, 480) + im.seek(0) + assert im.size == (640, 480) + def test_ignore_frame_size(): # Ignore the different size of the second frame @@ -116,12 +130,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 +164,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() - frameNumber = 0 - for mpentry in mpinfo[0xB002]: - mpattr = mpentry["Attribute"] - if frameNumber: - 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 - frameNumber += 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_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 + + +@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 +227,55 @@ def test_eoferror(): im.seek(n_frames - 1) -def test_image_grab(): - 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.seek(0) - assert im.tell() == 0 - im02 = im.tobytes() - assert im0 == im02 - assert im0 != im1 +@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(): - # Note that only individual frames can be saved at present +def test_save_all(): 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_reloaded = roundtrip(im, save_all=True) + + im.seek(0) + assert_image_similar(im, im_reloaded, 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) + assert im_reloaded.mpinfo[45056] == b"0100" + + 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_palm.py b/Tests/test_file_palm.py index e1c1c361b1e..be7c8d0c86a 100644 --- a/Tests/test_file_palm.py +++ b/Tests/test_file_palm.py @@ -63,19 +63,7 @@ def test_p_mode(tmp_path): roundtrip(tmp_path, mode) -def test_l_oserror(tmp_path): - # Arrange - mode = "L" - - # Act / Assert - with pytest.raises(OSError): - helper_save_as_palm(tmp_path, mode) - - -def test_rgb_oserror(tmp_path): - # Arrange - mode = "RGB" - - # Act / Assert +@pytest.mark.parametrize("mode", ("L", "RGB")) +def test_oserror(tmp_path, mode): with pytest.raises(OSError): helper_save_as_palm(tmp_path, mode) diff --git a/Tests/test_file_pcx.py b/Tests/test_file_pcx.py index 61e33a57bb4..485adf7853e 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") @@ -34,14 +39,14 @@ def test_invalid_file(): PcxImagePlugin.PcxImageFile(invalid_file) -def test_odd(tmp_path): +@pytest.mark.parametrize("mode", ("1", "L", "P", "RGB")) +def test_odd(tmp_path, mode): # See issue #523, odd sized images should have a stride that's even. # Not that ImageMagick or GIMP write PCX that way. # We were not handling properly. - for mode in ("1", "L", "P", "RGB"): - # larger, odd sized images are better here to ensure that - # we handle interrupted scan lines properly. - _roundtrip(tmp_path, hopper(mode).resize((511, 511))) + # larger, odd sized images are better here to ensure that + # we handle interrupted scan lines properly. + _roundtrip(tmp_path, hopper(mode).resize((511, 511))) def test_odd_read(): diff --git a/Tests/test_file_pdf.py b/Tests/test_file_pdf.py index 10daa414b5a..5299febe915 100644 --- a/Tests/test_file_pdf.py +++ b/Tests/test_file_pdf.py @@ -6,7 +6,7 @@ import pytest -from PIL import Image, PdfParser +from PIL import Image, PdfParser, features from .helper import hopper, mark_if_feature_version @@ -37,45 +37,18 @@ def helper_save_as_pdf(tmp_path, mode, **kwargs): return outfile -def test_monochrome(tmp_path): - # Arrange - mode = "1" - - # Act / Assert - outfile = helper_save_as_pdf(tmp_path, mode) - assert os.path.getsize(outfile) < 15000 - - -def test_greyscale(tmp_path): - # Arrange - mode = "L" - - # Act / Assert +@pytest.mark.parametrize("mode", ("L", "P", "RGB", "CMYK")) +def test_save(tmp_path, mode): helper_save_as_pdf(tmp_path, mode) -def test_rgb(tmp_path): - # Arrange - mode = "RGB" - - # Act / Assert - helper_save_as_pdf(tmp_path, mode) - - -def test_p_mode(tmp_path): - # Arrange - mode = "P" - - # Act / Assert - helper_save_as_pdf(tmp_path, mode) - - -def test_cmyk_mode(tmp_path): +def test_monochrome(tmp_path): # Arrange - mode = "CMYK" + mode = "1" # Act / Assert - helper_save_as_pdf(tmp_path, mode) + outfile = helper_save_as_pdf(tmp_path, mode) + assert os.path.getsize(outfile) < (5000 if features.check("libtiff") else 15000) def test_unsupported_mode(tmp_path): @@ -131,10 +104,10 @@ def test_save_all(tmp_path): assert os.path.getsize(outfile) > 0 # Test appending using a generator - def imGenerator(ims): + def im_generator(ims): yield from ims - im.save(outfile, save_all=True, append_images=imGenerator(ims)) + im.save(outfile, save_all=True, append_images=im_generator(ims)) assert os.path.isfile(outfile) assert os.path.getsize(outfile) > 0 @@ -253,9 +226,9 @@ def test_pdf_append(tmp_path): check_pdf_pages_consistency(pdf) # append two images - mode_CMYK = hopper("CMYK") - mode_P = hopper("P") - mode_CMYK.save(pdf_filename, append=True, save_all=True, append_images=[mode_P]) + mode_cmyk = hopper("CMYK") + mode_p = hopper("P") + mode_cmyk.save(pdf_filename, append=True, save_all=True, append_images=[mode_p]) # open the PDF again, check pages and info again with PdfParser.PdfParser(pdf_filename) as pdf: @@ -313,6 +286,7 @@ def test_pdf_append_to_bytesio(): @pytest.mark.timeout(1) +@pytest.mark.skipif("PILLOW_VALGRIND_TEST" in os.environ, reason="Valgrind is slower") @pytest.mark.parametrize("newline", (b"\r", b"\n")) def test_redos(newline): malicious = b" trailer<<>>" + newline * 3456 diff --git a/Tests/test_file_png.py b/Tests/test_file_png.py index 0869cc58bc5..9481cd5ddfe 100644 --- a/Tests/test_file_png.py +++ b/Tests/test_file_png.py @@ -1,5 +1,6 @@ import re import sys +import warnings import zlib from io import BytesIO @@ -19,7 +20,7 @@ ) try: - import defusedxml.ElementTree as ElementTree + from defusedxml import ElementTree except ImportError: ElementTree = None @@ -331,9 +332,8 @@ def test_load_verify(self): with Image.open(TEST_PNG_FILE) as im: # Assert that there is no unclosed file warning - with pytest.warns(None) as record: + with warnings.catch_warnings(): im.verify() - assert not record with Image.open(TEST_PNG_FILE) as im: im.load() @@ -635,6 +635,19 @@ def test_padded_idat(self): assert_image_equal_tofile(im, "Tests/images/bw_gradient.png") + @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: + with pytest.raises(ValueError): + png.call(cid, 0, 0) + + ImageFile.LOAD_TRUNCATED_IMAGES = True + png.call(cid, 0, 0) + ImageFile.LOAD_TRUNCATED_IMAGES = False + def test_specify_bits(self, tmp_path): im = hopper("P") @@ -693,10 +706,18 @@ def test_exif(self): assert exif[274] == 3 def test_exif_save(self, tmp_path): + # Test exif is not saved from info + test_file = str(tmp_path / "temp.png") with Image.open("Tests/images/exif.png") as im: - test_file = str(tmp_path / "temp.png") im.save(test_file) + with Image.open(test_file) as reloaded: + assert reloaded._getexif() is None + + # Test passing in exif + with Image.open("Tests/images/exif.png") as im: + im.save(test_file, exif=im.getexif()) + with Image.open(test_file) as reloaded: exif = reloaded._getexif() assert exif[274] == 1 @@ -707,7 +728,7 @@ def test_exif_save(self, tmp_path): def test_exif_from_jpg(self, tmp_path): with Image.open("Tests/images/pil_sample_rgb.jpg") as im: test_file = str(tmp_path / "temp.png") - im.save(test_file) + im.save(test_file, exif=im.getexif()) with Image.open(test_file) as reloaded: exif = reloaded._getexif() diff --git a/Tests/test_file_ppm.py b/Tests/test_file_ppm.py index ad36319db27..fbcbea6c691 100644 --- a/Tests/test_file_ppm.py +++ b/Tests/test_file_ppm.py @@ -3,7 +3,7 @@ import pytest -from PIL import Image +from PIL import Image, PpmImagePlugin from .helper import assert_image_equal_tofile, assert_image_similar, hopper @@ -13,16 +13,67 @@ def test_sanity(): with Image.open(TEST_FILE) as im: - im.load() assert im.mode == "RGB" assert im.size == (128, 128) - assert im.format, "PPM" + assert im.format == "PPM" assert im.get_format_mimetype() == "image/x-portable-pixmap" +@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 + ( + b"P6 3 1 17 \x00\x01\x02\x08\x09\x0A\x0F\x10\x11", + "RGB", + ( + (0, 15, 30), + (120, 135, 150), + (225, 240, 255), + ), + ), + # P6 with maxval > 255 + ( + b"P6 3 1 257 \x00\x00\x00\x01\x00\x02" + b"\x00\x80\x00\x81\x00\x82\x01\x00\x01\x01\xFF\xFF", + "RGB", + ( + (0, 1, 2), + (127, 128, 129), + (254, 255, 255), + ), + ), + ), +) +def test_arbitrary_maxval(data, mode, pixels): + fp = BytesIO(data) + with Image.open(fp) as im: + assert im.size == (3, 1) + assert im.mode == mode + + px = im.load() + assert tuple(px[x, 0] for x in range(3)) == pixels + + def test_16bit_pgm(): with Image.open("Tests/images/16_bit_binary.pgm") as im: - im.load() assert im.mode == "I" assert im.size == (20, 100) assert im.get_format_mimetype() == "image/x-portable-graymap" @@ -32,8 +83,6 @@ def test_16bit_pgm(): def test_16bit_pgm_write(tmp_path): with Image.open("Tests/images/16_bit_binary.pgm") as im: - im.load() - f = str(tmp_path / "temp.pgm") im.save(f, "PPM") @@ -50,15 +99,175 @@ def test_pnm(tmp_path): assert_image_equal_tofile(im, f) +@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(data) + + 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): + path = str(tmp_path / "temp.ppm") + with open(path, "wb") as f: + f.write(b"P6 #comment\n#comment\r12#comment\r8\n128 #comment\n255\n") + + with Image.open(path) as im: + assert im.size == (128, 128) + + +def test_non_integer_token(tmp_path): + path = str(tmp_path / "temp.ppm") + with open(path, "wb") as f: + f.write(b"P6\nTEST") + + with pytest.raises(ValueError): + with Image.open(path): + pass + + +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") + + with pytest.raises(ValueError) as e: + with Image.open(path): + pass + + assert str(e.value) == "Token too long in file header: 01234567890" + + def test_truncated_file(tmp_path): + # Test EOF in header path = str(tmp_path / "temp.pgm") - with open(path, "w") as f: - f.write("P6") + with open(path, "wb") as f: + f.write(b"P6") - with pytest.raises(ValueError): + with pytest.raises(ValueError) as e: with Image.open(path): pass + assert str(e.value) == "Reached EOF while reading header" + + # Test EOF for PyDecoder + fp = BytesIO(b"P5 3 1 4") + with Image.open(fp) as im: + with pytest.raises(ValueError): + im.load() + + +@pytest.mark.parametrize("maxval", (b"0", b"65536")) +def test_invalid_maxval(maxval, tmp_path): + path = str(tmp_path / "temp.ppm") + with open(path, "wb") as f: + f.write(b"P6\n3 1 " + maxval) + + with pytest.raises(ValueError) as e: + with Image.open(path): + pass + + assert str(e.value) == "maxval must be greater than 0 and less than 65536" + def test_neg_ppm(): # Storage.c accepted negative values for xsize, ysize. the @@ -74,13 +283,13 @@ def test_neg_ppm(): def test_mimetypes(tmp_path): path = str(tmp_path / "temp.pgm") - with open(path, "w") as f: - f.write("P4\n128 128\n255") + with open(path, "wb") as f: + f.write(b"P4\n128 128\n255") with Image.open(path) as im: assert im.get_format_mimetype() == "image/x-portable-bitmap" - with open(path, "w") as f: - f.write("PyCMYK\n128 128\n255") + with open(path, "wb") as f: + f.write(b"PyCMYK\n128 128\n255") with Image.open(path) as im: assert im.get_format_mimetype() == "image/x-portable-anymap" diff --git a/Tests/test_file_psd.py b/Tests/test_file_psd.py index f50fe133ffc..4f934375c7c 100644 --- a/Tests/test_file_psd.py +++ b/Tests/test_file_psd.py @@ -1,8 +1,10 @@ +import warnings + 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" @@ -29,21 +31,17 @@ def open(): def test_closed_file(): - with pytest.warns(None) as record: + with warnings.catch_warnings(): im = Image.open(test_file) im.load() im.close() - assert not record - def test_context_manager(): - with pytest.warns(None) as record: + with warnings.catch_warnings(): with Image.open(test_file) as im: im.load() - assert not record - def test_invalid_file(): invalid_file = "Tests/images/flower.jpg" @@ -109,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 @@ -123,7 +126,7 @@ def test_no_icc_profile(): def test_combined_larger_than_size(): - # The 'combined' sizes of the individual parts is larger than the + # The combined size of the individual parts is larger than the # declared 'size' of the extra data field, resulting in a backwards seek. # If we instead take the 'size' of the extra data field as the source of truth, diff --git a/Tests/test_file_spider.py b/Tests/test_file_spider.py index 3c93160f11d..0e3b705a295 100644 --- a/Tests/test_file_spider.py +++ b/Tests/test_file_spider.py @@ -1,4 +1,5 @@ import tempfile +import warnings from io import BytesIO import pytest @@ -28,21 +29,17 @@ def open(): def test_closed_file(): - with pytest.warns(None) as record: + with warnings.catch_warnings(): im = Image.open(TEST_FILE) im.load() im.close() - assert not record - def test_context_manager(): - with pytest.warns(None) as record: + with warnings.catch_warnings(): with Image.open(TEST_FILE) as im: im.load() - assert not record - def test_save(tmp_path): # Arrange diff --git a/Tests/test_file_tar.py b/Tests/test_file_tar.py index b38727fb9b2..5daab47fca3 100644 --- a/Tests/test_file_tar.py +++ b/Tests/test_file_tar.py @@ -1,3 +1,5 @@ +import warnings + import pytest from PIL import Image, TarIO, features @@ -31,16 +33,12 @@ def open(): def test_close(): - with pytest.warns(None) as record: + with warnings.catch_warnings(): tar = TarIO.TarIO(TEST_TAR_FILE, "hopper.jpg") tar.close() - assert not record - def test_contextmanager(): - with pytest.warns(None) as record: + with warnings.catch_warnings(): with TarIO.TarIO(TEST_TAR_FILE, "hopper.jpg"): pass - - assert not record diff --git a/Tests/test_file_tga.py b/Tests/test_file_tga.py index e2351d72362..7d8b5139aa9 100644 --- a/Tests/test_file_tga.py +++ b/Tests/test_file_tga.py @@ -18,51 +18,48 @@ _ORIGIN_TO_ORIENTATION = {"tl": 1, "bl": -1} -def test_sanity(tmp_path): - for mode in _MODES: - - def roundtrip(original_im): - out = str(tmp_path / "temp.tga") +@pytest.mark.parametrize("mode", _MODES) +def test_sanity(mode, tmp_path): + 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: + 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() + + 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"] - ) - assert saved_im.info["orientation"] == original_im.info["orientation"] - if mode == "P": - assert saved_im.getpalette() == original_im.getpalette() - - 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" + original_im.info["orientation"] + == _ORIGIN_TO_ORIENTATION[origin] ) + if mode == "P": + assert original_im.getpalette() == reference_im.getpalette() - 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) + assert_image_equal(original_im, reference_im) - roundtrip(original_im) + roundtrip(original_im) def test_palette_depth_16(tmp_path): @@ -97,6 +94,15 @@ def test_id_field_rle(): assert im.size == (199, 199) +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" with Image.open(test_file) as im: @@ -114,6 +120,18 @@ def test_save(tmp_path): assert test_im.size == (100, 100) +def test_small_palette(tmp_path): + im = Image.new("P", (1, 1)) + colors = [0, 0, 0] + im.putpalette(colors) + + out = str(tmp_path / "temp.tga") + im.save(out) + + with Image.open(out) as reloaded: + assert reloaded.getpalette() == colors + + def test_save_wrong_mode(tmp_path): im = hopper("PA") out = str(tmp_path / "temp.tga") diff --git a/Tests/test_file_tiff.py b/Tests/test_file_tiff.py index 5801e176636..4f3c8e39010 100644 --- a/Tests/test_file_tiff.py +++ b/Tests/test_file_tiff.py @@ -1,9 +1,10 @@ import os +import warnings from io import BytesIO import pytest -from PIL import Image, ImageFile, TiffImagePlugin +from PIL import Image, ImageFile, TiffImagePlugin, UnidentifiedImageError from PIL.TiffImagePlugin import RESOLUTION_UNIT, X_RESOLUTION, Y_RESOLUTION from .helper import ( @@ -17,7 +18,7 @@ ) try: - import defusedxml.ElementTree as ElementTree + from defusedxml import ElementTree except ImportError: ElementTree = None @@ -64,19 +65,42 @@ def open(): pytest.warns(ResourceWarning, open) def test_closed_file(self): - with pytest.warns(None) as record: + with warnings.catch_warnings(): im = Image.open("Tests/images/multipage.tiff") im.load() im.close() - assert not record + 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 pytest.warns(None) as record: + with warnings.catch_warnings(): with Image.open("Tests/images/multipage.tiff") as im: im.load() - assert not record + @pytest.mark.parametrize( + "path, sizes", + ( + ("Tests/images/hopper.tif", ()), + ("Tests/images/child_ifd.tiff", (16, 8)), + ("Tests/images/child_ifd_jpeg.tiff", (20,)), + ), + ) + def test_get_child_images(self, path, sizes): + with Image.open(path) as im: + ims = im.get_child_images() + + assert len(ims) == len(sizes) + for i, im in enumerate(ims): + w = sizes[i] + expected = Image.new("RGB", (w, w), "#f00") + assert_image_similar(im, expected, 1) def test_mac_tiff(self): # Read RGBa images from macOS [@PIL136] @@ -90,11 +114,38 @@ def test_mac_tiff(self): assert_image_similar_tofile(im, "Tests/images/pil136.png", 1) - def test_wrong_bits_per_sample(self): - with Image.open("Tests/images/tiff_wrong_bits_per_sample.tiff") as im: - assert im.mode == "RGBA" - assert im.size == (52, 53) - assert im.tile == [("raw", (0, 0, 52, 53), 160, ("RGBA", 0, 1))] + def test_bigtiff(self): + with Image.open("Tests/images/hopper_bigtiff.tif") as im: + assert_image_equal_tofile(im, "Tests/images/hopper.tif") + + @pytest.mark.parametrize( + "file_name,mode,size,tile", + [ + ( + "tiff_wrong_bits_per_sample.tiff", + "RGBA", + (52, 53), + [("raw", (0, 0, 52, 53), 160, ("RGBA", 0, 1))], + ), + ( + "tiff_wrong_bits_per_sample_2.tiff", + "RGB", + (16, 16), + [("raw", (0, 0, 16, 16), 8, ("RGB", 0, 1))], + ), + ( + "tiff_wrong_bits_per_sample_3.tiff", + "RGBA", + (512, 256), + [("libtiff", (0, 0, 512, 256), 0, ("RGBA", "tiff_lzw", False, 48782))], + ), + ], + ) + def test_wrong_bits_per_sample(self, file_name, mode, size, tile): + with Image.open("Tests/images/" + file_name) as im: + assert im.mode == mode + assert im.size == size + assert im.tile == tile im.load() def test_set_legacy_api(self): @@ -143,14 +194,14 @@ def test_int_resolution(self): assert im.info["dpi"] == (71.0, 71.0) @pytest.mark.parametrize( - "resolutionUnit, dpi", + "resolution_unit, dpi", [(None, 72.8), (2, 72.8), (3, 184.912)], ) - def test_load_float_dpi(self, resolutionUnit, dpi): + def test_load_float_dpi(self, resolution_unit, dpi): with Image.open( - "Tests/images/hopper_float_dpi_" + str(resolutionUnit) + ".tif" + "Tests/images/hopper_float_dpi_" + str(resolution_unit) + ".tif" ) as im: - assert im.tag_v2.get(RESOLUTION_UNIT) == resolutionUnit + assert im.tag_v2.get(RESOLUTION_UNIT) == resolution_unit assert im.info["dpi"] == (dpi, dpi) def test_save_float_dpi(self, tmp_path): @@ -217,6 +268,15 @@ def test_big_endian(self): assert b[0] == ord(b"\x01") assert b[1] == ord(b"\xe0") + def test_16bit_r(self): + with Image.open("Tests/images/16bit.r.tif") as im: + assert im.getpixel((0, 0)) == 480 + assert im.mode == "I;16" + + b = im.tobytes() + assert b[0] == ord(b"\xe0") + assert b[1] == ord(b"\x01") + def test_16bit_s(self): with Image.open("Tests/images/16bit.s.tif") as im: im.load() @@ -251,14 +311,17 @@ def test_unknown_pixel_mode(self): with Image.open("Tests/images/hopper_unknown_pixel_mode.tif"): pass - def test_n_frames(self): - for path, n_frames in [ - ["Tests/images/multipage-lastframe.tif", 1], - ["Tests/images/multipage.tiff", 3], - ]: - with Image.open(path) as im: - assert im.n_frames == n_frames - assert im.is_animated == (n_frames != 1) + @pytest.mark.parametrize( + "path, n_frames", + ( + ("Tests/images/multipage-lastframe.tif", 1), + ("Tests/images/multipage.tiff", 3), + ), + ) + def test_n_frames(self, path, n_frames): + with Image.open(path) as im: + assert im.n_frames == n_frames + assert im.is_animated == (n_frames != 1) def test_eoferror(self): with Image.open("Tests/images/multipage-lastframe.tif") as im: @@ -374,12 +437,12 @@ def test__delitem__(self): len_after = len(dict(im.ifd)) assert len_before == len_after + 1 - def test_load_byte(self): - for legacy_api in [False, True]: - ifd = TiffImagePlugin.ImageFileDirectory_v2() - data = b"abc" - ret = ifd.load_byte(data, legacy_api) - assert ret == b"abc" + @pytest.mark.parametrize("legacy_api", (False, True)) + def test_load_byte(self, legacy_api): + ifd = TiffImagePlugin.ImageFileDirectory_v2() + data = b"abc" + ret = ifd.load_byte(data, legacy_api) + assert ret == b"abc" def test_load_string(self): ifd = TiffImagePlugin.ImageFileDirectory_v2() @@ -455,6 +518,26 @@ def check_exif(exif): 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: @@ -594,18 +677,26 @@ def test_tiled_planar_raw(self): with Image.open(infile) as im: assert_image_equal_tofile(im, "Tests/images/tiff_adobe_deflate.png") - def test_palette(self, tmp_path): - def roundtrip(mode): - outfile = str(tmp_path / "temp.tif") + def test_planar_configuration_save(self, tmp_path): + infile = "Tests/images/tiff_tiled_planar_raw.tif" + with Image.open(infile) as im: + assert im._planar_configuration == 2 - im = hopper(mode) + outfile = str(tmp_path / "temp.tif") im.save(outfile) with Image.open(outfile) as reloaded: - assert_image_equal(im.convert("RGB"), reloaded.convert("RGB")) + assert_image_equal_tofile(reloaded, infile) - for mode in ["P", "PA"]: - roundtrip(mode) + @pytest.mark.parametrize("mode", ("P", "PA")) + def test_palette(self, mode, tmp_path): + outfile = str(tmp_path / "temp.tif") + + im = hopper(mode) + im.save(outfile) + + with Image.open(outfile) as reloaded: + assert_image_equal(im.convert("RGB"), reloaded.convert("RGB")) def test_tiff_save_all(self): mp = BytesIO() @@ -627,11 +718,11 @@ def test_tiff_save_all(self): assert reread.n_frames == 3 # Test appending using a generator - def imGenerator(ims): + def im_generator(ims): yield from ims mp = BytesIO() - im.save(mp, format="TIFF", save_all=True, append_images=imGenerator(ims)) + im.save(mp, format="TIFF", save_all=True, append_images=im_generator(ims)) mp.seek(0, os.SEEK_SET) with Image.open(mp) as reread: @@ -662,6 +753,13 @@ def test_save_icc_profile(self, tmp_path): 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") @@ -685,6 +783,32 @@ def test_getxmp(self): assert description[0]["format"] == "image/tiff" assert description[3]["BitsPerSample"]["Seq"]["li"] == ["8", "8", "8"] + def test_get_photoshop_blocks(self): + with Image.open("Tests/images/lab.tif") as im: + assert list(im.get_photoshop_blocks().keys()) == [ + 1061, + 1002, + 1005, + 1062, + 1037, + 1049, + 1011, + 1034, + 10000, + 1013, + 1016, + 1032, + 1054, + 1050, + 1064, + 1041, + 1044, + 1036, + 1057, + 4000, + 4001, + ] + def test_close_on_load_exclusive(self, tmp_path): # similar to test_fd_leak, but runs on unixlike os tmpfile = str(tmp_path / "temp.tif") @@ -734,6 +858,19 @@ def test_timeout(self): im.load() ImageFile.LOAD_TRUNCATED_IMAGES = False + @pytest.mark.parametrize( + "test_file", + [ + "Tests/images/oom-225817ca0f8c663be7ab4b9e717b02c661e66834.tif", + ], + ) + @pytest.mark.timeout(2) + def test_oom(self, test_file): + with pytest.raises(UnidentifiedImageError): + with pytest.warns(UserWarning): + with Image.open(test_file): + pass + @pytest.mark.skipif(not is_win32(), reason="Windows only") class TestFileTiffW32: diff --git a/Tests/test_file_tiff_metadata.py b/Tests/test_file_tiff_metadata.py index 2213af5aadf..48797ea084d 100644 --- a/Tests/test_file_tiff_metadata.py +++ b/Tests/test_file_tiff_metadata.py @@ -28,26 +28,26 @@ def test_rt_metadata(tmp_path): # For text items, we still have to decode('ascii','replace') because # the tiff file format can't take 8 bit bytes in that field. - basetextdata = "This is some arbitrary metadata for a text field" - bindata = basetextdata.encode("ascii") + b" \xff" - textdata = basetextdata + " " + chr(255) - reloaded_textdata = basetextdata + " ?" - floatdata = 12.345 - doubledata = 67.89 + base_text_data = "This is some arbitrary metadata for a text field" + bin_data = base_text_data.encode("ascii") + b" \xff" + text_data = base_text_data + " " + chr(255) + reloaded_text_data = base_text_data + " ?" + float_data = 12.345 + double_data = 67.89 info = TiffImagePlugin.ImageFileDirectory() ImageJMetaData = TAG_IDS["ImageJMetaData"] ImageJMetaDataByteCounts = TAG_IDS["ImageJMetaDataByteCounts"] ImageDescription = TAG_IDS["ImageDescription"] - info[ImageJMetaDataByteCounts] = len(bindata) - info[ImageJMetaData] = bindata - info[TAG_IDS["RollAngle"]] = floatdata + info[ImageJMetaDataByteCounts] = len(bin_data) + info[ImageJMetaData] = bin_data + info[TAG_IDS["RollAngle"]] = float_data info.tagtype[TAG_IDS["RollAngle"]] = 11 - info[TAG_IDS["YawAngle"]] = doubledata + info[TAG_IDS["YawAngle"]] = double_data info.tagtype[TAG_IDS["YawAngle"]] = 12 - info[ImageDescription] = textdata + info[ImageDescription] = text_data f = str(tmp_path / "temp.tif") @@ -55,28 +55,28 @@ def test_rt_metadata(tmp_path): with Image.open(f) as loaded: - assert loaded.tag[ImageJMetaDataByteCounts] == (len(bindata),) - assert loaded.tag_v2[ImageJMetaDataByteCounts] == (len(bindata),) + assert loaded.tag[ImageJMetaDataByteCounts] == (len(bin_data),) + assert loaded.tag_v2[ImageJMetaDataByteCounts] == (len(bin_data),) - assert loaded.tag[ImageJMetaData] == bindata - assert loaded.tag_v2[ImageJMetaData] == bindata + assert loaded.tag[ImageJMetaData] == bin_data + assert loaded.tag_v2[ImageJMetaData] == bin_data - assert loaded.tag[ImageDescription] == (reloaded_textdata,) - assert loaded.tag_v2[ImageDescription] == reloaded_textdata + assert loaded.tag[ImageDescription] == (reloaded_text_data,) + assert loaded.tag_v2[ImageDescription] == reloaded_text_data loaded_float = loaded.tag[TAG_IDS["RollAngle"]][0] - assert round(abs(loaded_float - floatdata), 5) == 0 + assert round(abs(loaded_float - float_data), 5) == 0 loaded_double = loaded.tag[TAG_IDS["YawAngle"]][0] - assert round(abs(loaded_double - doubledata), 7) == 0 + assert round(abs(loaded_double - double_data), 7) == 0 # check with 2 element ImageJMetaDataByteCounts, issue #2006 - info[ImageJMetaDataByteCounts] = (8, len(bindata) - 8) + info[ImageJMetaDataByteCounts] = (8, len(bin_data) - 8) img.save(f, tiffinfo=info) with Image.open(f) as loaded: - assert loaded.tag[ImageJMetaDataByteCounts] == (8, len(bindata) - 8) - assert loaded.tag_v2[ImageJMetaDataByteCounts] == (8, len(bindata) - 8) + assert loaded.tag[ImageJMetaDataByteCounts] == (8, len(bin_data) - 8) + assert loaded.tag_v2[ImageJMetaDataByteCounts] == (8, len(bin_data) - 8) def test_read_metadata(): @@ -185,6 +185,39 @@ def test_iptc(tmp_path): im.save(out) +@pytest.mark.parametrize("value, expected", ((b"test", "test"), (1, "1"))) +def test_writing_other_types_to_ascii(value, expected, tmp_path): + info = TiffImagePlugin.ImageFileDirectory_v2() + + tag = TiffTags.TAGS_V2[271] + assert tag.type == TiffTags.ASCII + + info[271] = value + + im = hopper() + out = str(tmp_path / "temp.tiff") + im.save(out, tiffinfo=info) + + with Image.open(out) as reloaded: + assert reloaded.tag_v2[271] == expected + + +def test_writing_int_to_bytes(tmp_path): + im = hopper() + info = TiffImagePlugin.ImageFileDirectory_v2() + + tag = TiffTags.TAGS_V2[700] + assert tag.type == TiffTags.BYTE + + info[700] = 1 + + out = str(tmp_path / "temp.tiff") + im.save(out, tiffinfo=info) + + with Image.open(out) as reloaded: + assert reloaded.tag_v2[700] == b"\x01" + + def test_undefined_zero(tmp_path): # Check that the tag has not been changed since this test was created tag = TiffTags.TAGS_V2[45059] @@ -258,7 +291,7 @@ def test_ifd_unsigned_rational(tmp_path): im = hopper() info = TiffImagePlugin.ImageFileDirectory_v2() - max_long = 2 ** 32 - 1 + max_long = 2**32 - 1 # 4 bytes unsigned long numerator = max_long @@ -290,8 +323,8 @@ def test_ifd_signed_rational(tmp_path): info = TiffImagePlugin.ImageFileDirectory_v2() # pair of 4 byte signed longs - numerator = 2 ** 31 - 1 - denominator = -(2 ** 31) + numerator = 2**31 - 1 + denominator = -(2**31) info[37380] = TiffImagePlugin.IFDRational(numerator, denominator) @@ -302,8 +335,8 @@ def test_ifd_signed_rational(tmp_path): assert numerator == reloaded.tag_v2[37380].numerator assert denominator == reloaded.tag_v2[37380].denominator - numerator = -(2 ** 31) - denominator = 2 ** 31 - 1 + numerator = -(2**31) + denominator = 2**31 - 1 info[37380] = TiffImagePlugin.IFDRational(numerator, denominator) @@ -315,7 +348,7 @@ def test_ifd_signed_rational(tmp_path): assert denominator == reloaded.tag_v2[37380].denominator # out of bounds of 4 byte signed long - numerator = -(2 ** 31) - 1 + numerator = -(2**31) - 1 denominator = 1 info[37380] = TiffImagePlugin.IFDRational(numerator, denominator) @@ -324,7 +357,7 @@ def test_ifd_signed_rational(tmp_path): im.save(out, tiffinfo=info, compression="raw") with Image.open(out) as reloaded: - assert 2 ** 31 - 1 == reloaded.tag_v2[37380].numerator + assert 2**31 - 1 == reloaded.tag_v2[37380].numerator assert -1 == reloaded.tag_v2[37380].denominator @@ -356,7 +389,7 @@ def test_empty_values(): assert 33432 in info -def test_PhotoshopInfo(tmp_path): +def test_photoshop_info(tmp_path): with Image.open("Tests/images/issue_2278.tif") as im: assert len(im.tag_v2[34377]) == 70 assert isinstance(im.tag_v2[34377], bytes) diff --git a/Tests/test_file_wal.py b/Tests/test_file_wal.py index f25b42fe0c4..4be46e9d673 100644 --- a/Tests/test_file_wal.py +++ b/Tests/test_file_wal.py @@ -2,15 +2,11 @@ from .helper import assert_image_equal_tofile +TEST_FILE = "Tests/images/hopper.wal" -def test_open(): - # Arrange - TEST_FILE = "Tests/images/hopper.wal" - # Act +def test_open(): with WalImageFile.open(TEST_FILE) as im: - - # Assert assert im.format == "WAL" assert im.format_description == "Quake2 Texture" assert im.mode == "P" @@ -19,3 +15,11 @@ def test_open(): assert isinstance(im, WalImageFile.WalImageFile) assert_image_equal_tofile(im, "Tests/images/hopper_wal.png") + + +def test_load(): + with WalImageFile.open(TEST_FILE) as im: + assert im.load()[0, 0] == 122 + + # Test again now that it has already been loaded once + assert im.load()[0, 0] == 122 diff --git a/Tests/test_file_webp.py b/Tests/test_file_webp.py index e72b4993c63..f1bdc59cf34 100644 --- a/Tests/test_file_webp.py +++ b/Tests/test_file_webp.py @@ -1,12 +1,14 @@ import io import re import sys +import warnings import pytest from PIL import Image, WebPImagePlugin, features from .helper import ( + assert_image_equal, assert_image_similar, assert_image_similar_tofile, hopper, @@ -104,6 +106,19 @@ def test_write_method(self, tmp_path): hopper().save(buffer_method, format="WEBP", method=6) assert buffer_no_args.getbuffer() != buffer_method.getbuffer() + @skip_unless_feature("webp_anim") + def test_save_all(self, tmp_path): + temp_file = str(tmp_path / "temp.webp") + im = Image.new("RGB", (1, 1)) + im2 = Image.new("RGB", (1, 1), "#f00") + im.save(temp_file, save_all=True, append_images=[im2]) + + with Image.open(temp_file) as reloaded: + assert_image_equal(im, reloaded) + + reloaded.seek(1) + assert_image_similar(im2, reloaded, 1) + def test_icc_profile(self, tmp_path): self._roundtrip(tmp_path, self.rgb_mode, 12.5, {"icc_profile": None}) if _webp.HAVE_WEBPANIM: @@ -127,7 +142,7 @@ def test_write_unsupported_mode_P(self, tmp_path): self._roundtrip(tmp_path, "P", 50.0) - @pytest.mark.skipif(sys.maxsize <= 2 ** 32, reason="Requires 64-bit system") + @pytest.mark.skipif(sys.maxsize <= 2**32, reason="Requires 64-bit system") def test_write_encoding_error_message(self, tmp_path): temp_file = str(tmp_path / "temp.webp") im = Image.new("RGB", (15000, 15000)) @@ -161,9 +176,8 @@ def test_no_resource_warning(self, tmp_path): file_path = "Tests/images/hopper.webp" with Image.open(file_path) as image: temp_file = str(tmp_path / "temp.webp") - with pytest.warns(None) as record: + with warnings.catch_warnings(): image.save(temp_file) - assert not record def test_file_pointer_could_be_reused(self): file_path = "Tests/images/hopper.webp" @@ -171,9 +185,25 @@ def test_file_pointer_could_be_reused(self): Image.open(blob).load() Image.open(blob).load() - @skip_unless_feature("webp") + @pytest.mark.parametrize( + "background", + (0, (0,), (-1, 0, 1, 2), (253, 254, 255, 256)), + ) + @skip_unless_feature("webp_anim") + def test_invalid_background(self, background, tmp_path): + temp_file = str(tmp_path / "temp.webp") + im = hopper() + with pytest.raises(OSError): + im.save(temp_file, save_all=True, append_images=[im], background=background) + @skip_unless_feature("webp_anim") def test_background_from_gif(self, tmp_path): + # Save L mode GIF with background + with Image.open("Tests/images/no_palette_with_background.gif") as im: + out_webp = str(tmp_path / "temp.webp") + im.save(out_webp, save_all=True) + + # Save P mode GIF with background with Image.open("Tests/images/chi.gif") as im: original_value = im.convert("RGB").getpixel((1, 1)) @@ -191,7 +221,6 @@ def test_background_from_gif(self, tmp_path): difference = sum(abs(original_value[i] - reread_value[i]) for i in range(0, 3)) assert difference < 5 - @skip_unless_feature("webp") @skip_unless_feature("webp_anim") def test_duration(self, tmp_path): with Image.open("Tests/images/dispose_bgnd.gif") as im: diff --git a/Tests/test_file_webp_alpha.py b/Tests/test_file_webp_alpha.py index dc82fb742b2..5970fd2a371 100644 --- a/Tests/test_file_webp_alpha.py +++ b/Tests/test_file_webp_alpha.py @@ -97,6 +97,35 @@ def test_write_rgba(tmp_path): assert_image_similar(image, pil_image, 1.0) +def test_keep_rgb_values_when_transparent(tmp_path): + """ + Saving transparent pixels should retain their original RGB values + when using the "exact" parameter. + """ + + image = hopper("RGB") + + # create a copy of the image + # with the left half transparent + half_transparent_image = image.copy() + new_alpha = Image.new("L", (128, 128), 255) + new_alpha.paste(0, (0, 0, 64, 128)) + half_transparent_image.putalpha(new_alpha) + + # save with transparent area preserved + temp_file = str(tmp_path / "temp.webp") + half_transparent_image.save(temp_file, exact=True, lossless=True) + + with Image.open(temp_file) as reloaded: + assert reloaded.mode == "RGBA" + assert reloaded.format == "WEBP" + + # even though it is lossless, if we don't use exact=True + # in libwebp >= 0.5, the transparent area will be filled with black + # (or something more conducive to compression) + assert_image_equal(reloaded.convert("RGB"), image) + + def test_write_unsupported_mode_PA(tmp_path): """ Saving a palette-based file with transparency to WebP format diff --git a/Tests/test_file_webp_animated.py b/Tests/test_file_webp_animated.py index 25ebffe0248..c621df0d99c 100644 --- a/Tests/test_file_webp_animated.py +++ b/Tests/test_file_webp_animated.py @@ -1,6 +1,7 @@ import pytest +from packaging.version import parse as parse_version -from PIL import Image +from PIL import Image, features from .helper import ( assert_image_equal, @@ -27,7 +28,6 @@ def test_n_frames(): assert im.is_animated -@pytest.mark.xfail(is_big_endian(), reason="Fails on big-endian") def test_write_animation_L(tmp_path): """ Convert an animated GIF to animated WebP, then compare the frame count, and first @@ -46,6 +46,11 @@ def test_write_animation_L(tmp_path): orig.load() im.load() assert_image_similar(im, orig.convert("RGBA"), 32.9) + + if is_big_endian(): + webp = parse_version(features.version_module("webp")) + if webp < parse_version("1.2.2"): + pytest.skip("Fails with libwebp earlier than 1.2.2") orig.seek(orig.n_frames - 1) im.seek(im.n_frames - 1) orig.load() @@ -53,7 +58,6 @@ def test_write_animation_L(tmp_path): assert_image_similar(im, orig.convert("RGBA"), 32.9) -@pytest.mark.xfail(is_big_endian(), reason="Fails on big-endian") def test_write_animation_RGB(tmp_path): """ Write an animated WebP from RGB frames, and ensure the frames @@ -69,6 +73,10 @@ def check(temp_file): assert_image_equal(im, frame1.convert("RGBA")) # Compare second frame to original + if is_big_endian(): + webp = parse_version(features.version_module("webp")) + if webp < parse_version("1.2.2"): + pytest.skip("Fails with libwebp earlier than 1.2.2") im.seek(1) im.load() assert_image_equal(im, frame2.convert("RGBA")) @@ -82,14 +90,14 @@ def check(temp_file): check(temp_file1) # Tests appending using a generator - def imGenerator(ims): + def im_generator(ims): yield from ims temp_file2 = str(tmp_path / "temp_generator.webp") frame1.copy().save( temp_file2, save_all=True, - append_images=imGenerator([frame2]), + append_images=im_generator([frame2]), lossless=True, ) check(temp_file2) diff --git a/Tests/test_file_webp_metadata.py b/Tests/test_file_webp_metadata.py index e6d6fc63fc4..4f513d82bc8 100644 --- a/Tests/test_file_webp_metadata.py +++ b/Tests/test_file_webp_metadata.py @@ -11,6 +11,11 @@ skip_unless_feature("webp_mux"), ] +try: + from defusedxml import ElementTree +except ImportError: + ElementTree = None + def test_read_exif_metadata(): @@ -55,9 +60,7 @@ def test_write_exif_metadata(): test_buffer.seek(0) with Image.open(test_buffer) as webp_image: webp_exif = webp_image.info.get("exif", None) - assert webp_exif - if webp_exif: - assert webp_exif == expected_exif, "WebP EXIF didn't match" + assert webp_exif == expected_exif[6:], "WebP EXIF didn't match" def test_read_icc_profile(): @@ -112,6 +115,22 @@ def test_read_no_exif(): assert not webp_image._getexif() +def test_getxmp(): + with Image.open("Tests/images/flower.webp") as im: + assert "xmp" not in im.info + assert im.getxmp() == {} + + with Image.open("Tests/images/flower2.webp") as im: + if ElementTree is None: + with pytest.warns(UserWarning): + assert im.getxmp() == {} + else: + assert ( + im.getxmp()["xmpmeta"]["xmptk"] + == "Adobe XMP Core 5.3-c011 66.145661, 2012/02/06-14:56:27 " + ) + + @skip_unless_feature("webp_anim") def test_write_animated_metadata(tmp_path): iccp_data = b"" diff --git a/Tests/test_file_wmf.py b/Tests/test_file_wmf.py index 3f8bc96ccdd..439cb15bca9 100644 --- a/Tests/test_file_wmf.py +++ b/Tests/test_file_wmf.py @@ -24,6 +24,12 @@ def test_load_raw(): assert_image_similar_tofile(im, "Tests/images/drawing_wmf_ref.png", 2.0) +def test_load(): + with Image.open("Tests/images/drawing.emf") as im: + if hasattr(Image.core, "drawwmf"): + assert im.load()[0, 0] == (255, 255, 255) + + def test_register_handler(tmp_path): class TestHandler: methodCalled = False @@ -60,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_file_xbm.py b/Tests/test_file_xbm.py index 487920a9282..9c54c675560 100644 --- a/Tests/test_file_xbm.py +++ b/Tests/test_file_xbm.py @@ -2,7 +2,7 @@ import pytest -from PIL import Image +from PIL import Image, XbmImagePlugin from .helper import hopper @@ -63,6 +63,13 @@ def test_open_filename_with_underscore(): assert im.size == (128, 128) +def test_invalid_file(): + invalid_file = "Tests/images/flower.jpg" + + with pytest.raises(SyntaxError): + XbmImagePlugin.XbmImageFile(invalid_file) + + def test_save_wrong_mode(tmp_path): im = hopper() out = str(tmp_path / "temp.xbm") diff --git a/Tests/test_font_crash.py b/Tests/test_font_crash.py new file mode 100644 index 00000000000..27663f396ea --- /dev/null +++ b/Tests/test_font_crash.py @@ -0,0 +1,22 @@ +import pytest + +from PIL import Image, ImageDraw, ImageFont + +from .helper import skip_unless_feature + + +class TestFontCrash: + def _fuzz_font(self, font): + # from fuzzers.fuzz_font + font.getbbox("ABC") + font.getmask("test text") + with Image.new(mode="RGBA", size=(200, 200)) as im: + draw = ImageDraw.Draw(im) + draw.multiline_textbbox((10, 10), "ABC\nAaaa", font, stroke_width=2) + draw.text((10, 10), "Test Text", font=font, fill="#000") + + @skip_unless_feature("freetype2") + def test_segfault(self): + with pytest.raises(OSError): + font = ImageFont.truetype("Tests/fonts/fuzz_font-5203009437302784") + self._fuzz_font(font) diff --git a/Tests/test_font_pcf.py b/Tests/test_font_pcf.py index 288848f2619..c217378fb74 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 a1036fd28e6..664663fd6bb 100644 --- a/Tests/test_font_pcf_charsets.py +++ b/Tests/test_font_pcf_charsets.py @@ -1,5 +1,7 @@ import os +import pytest + from PIL import FontFile, Image, ImageDraw, ImageFont, PcfFontFile from .helper import ( @@ -59,23 +61,13 @@ def delete_tempfile(): return tempname -def _test_sanity(request, tmp_path, encoding): +@pytest.mark.parametrize("encoding", ("iso8859-1", "iso8859-2", "cp1250")) +def test_sanity(request, tmp_path, encoding): save_font(request, tmp_path, encoding) -def test_sanity_iso8859_1(request, tmp_path): - _test_sanity(request, tmp_path, "iso8859-1") - - -def test_sanity_iso8859_2(request, tmp_path): - _test_sanity(request, tmp_path, "iso8859-2") - - -def test_sanity_cp1250(request, tmp_path): - _test_sanity(request, tmp_path, "cp1250") - - -def _test_draw(request, tmp_path, encoding): +@pytest.mark.parametrize("encoding", ("iso8859-1", "iso8859-2", "cp1250")) +def test_draw(request, tmp_path, encoding): tempname = save_font(request, tmp_path, encoding) font = ImageFont.load(tempname) im = Image.new("L", (150, 30), "white") @@ -85,38 +77,19 @@ def _test_draw(request, tmp_path, encoding): assert_image_similar_tofile(im, charsets[encoding]["image1"], 0) -def test_draw_iso8859_1(request, tmp_path): - _test_draw(request, tmp_path, "iso8859-1") - - -def test_draw_iso8859_2(request, tmp_path): - _test_draw(request, tmp_path, "iso8859-2") - - -def test_draw_cp1250(request, tmp_path): - _test_draw(request, tmp_path, "cp1250") - - -def _test_textsize(request, tmp_path, encoding): +@pytest.mark.parametrize("encoding", ("iso8859-1", "iso8859-2", "cp1250")) +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) - - -def test_textsize_iso8859_1(request, tmp_path): - _test_textsize(request, tmp_path, "iso8859-1") - - -def test_textsize_iso8859_2(request, tmp_path): - _test_textsize(request, tmp_path, "iso8859-2") - - -def test_textsize_cp1250(request, tmp_path): - _test_textsize(request, tmp_path, "cp1250") + assert font.getlength(msg) == len(msg) * 10 + assert font.getbbox(msg) == (0, 0, len(msg) * 10, 20) diff --git a/Tests/test_format_hsv.py b/Tests/test_format_hsv.py index 3b9c8b07146..b485e854f52 100644 --- a/Tests/test_format_hsv.py +++ b/Tests/test_format_hsv.py @@ -77,7 +77,7 @@ def to_rgb_colorsys(im): def test_wedge(): - src = wedge().resize((3 * 32, 32), Image.BILINEAR) + src = wedge().resize((3 * 32, 32), Image.Resampling.BILINEAR) im = src.convert("HSV") comparable = to_hsv_colorsys(src) diff --git a/Tests/test_image.py b/Tests/test_image.py index 4dde66f11a1..d261638f941 100644 --- a/Tests/test_image.py +++ b/Tests/test_image.py @@ -3,10 +3,18 @@ import shutil import sys import tempfile +import warnings import pytest -from PIL import Image, ImageDraw, ImagePalette, UnidentifiedImageError +from PIL import ( + ExifTags, + Image, + ImageDraw, + ImagePalette, + UnidentifiedImageError, + features, +) from .helper import ( assert_image_equal, @@ -21,8 +29,9 @@ class TestImage: - def test_image_modes_success(self): - for mode in [ + @pytest.mark.parametrize( + "mode", + ( "1", "P", "PA", @@ -43,22 +52,18 @@ def test_image_modes_success(self): "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) @@ -89,6 +94,17 @@ def test_sanity(self): # with pytest.raises(MemoryError): # Image.new("L", (1000000, 1000000)) + def test_repr_pretty(self): + class Pretty: + def text(self, text): + self.pretty_output = text + + im = Image.new("L", (100, 100)) + + p = Pretty() + im._repr_pretty_(p, None) + assert p.pretty_output == "" + def test_open_formats(self): PNGFILE = "Tests/images/hopper.png" JPGFILE = "Tests/images/hopper.jpg" @@ -120,8 +136,6 @@ def test_width_height(self): im.size = (3, 4) def test_invalid_image(self): - import io - im = io.BytesIO(b"") with pytest.raises(UnidentifiedImageError): with Image.open(im): @@ -149,6 +163,8 @@ def test_pathlib(self, tmp_path): assert im.size == (128, 128) for ext in (".jpg", ".jp2"): + if ext == ".jp2" and not features.check_codec("jpg_2000"): + pytest.skip("jpg_2000 not available") temp_file = str(tmp_path / ("temp." + ext)) if os.path.exists(temp_file): os.remove(temp_file) @@ -158,7 +174,7 @@ def test_fp_name(self, tmp_path): temp_file = str(tmp_path / "temp.jpg") class FP: - def write(a, b): + def write(self, b): pass fp = FP() @@ -385,8 +401,6 @@ def test_alpha_inplace(self): def test_registered_extensions_uninitialized(self): # Arrange Image._initialized = 0 - extension = Image.EXTENSION - Image.EXTENSION = {} # Act Image.registered_extensions() @@ -394,10 +408,6 @@ def test_registered_extensions_uninitialized(self): # Assert assert Image._initialized == 2 - # Restore the original state and assert - Image.EXTENSION = extension - assert Image.EXTENSION - def test_registered_extensions(self): # Arrange # Open an image to trigger plugin registration @@ -502,6 +512,14 @@ def test_check_size(self): i = Image.new("RGB", [1, 1]) assert isinstance(i.size, tuple) + @pytest.mark.timeout(0.75) + @pytest.mark.skipif( + "PILLOW_VALGRIND_TEST" in os.environ, reason="Valgrind is slower" + ) + @pytest.mark.parametrize("size", ((0, 100000000), (100000000, 0))) + def test_empty_image(self, size): + Image.new("RGB", size) + def test_storage_neg(self): # Storage.c accepted negative values for xsize, ysize. Was # test_neg_ppm, but the core function for that has been @@ -525,23 +543,22 @@ def test_linear_gradient_wrong_mode(self): 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 @@ -551,23 +568,22 @@ def test_radial_gradient_wrong_mode(self): 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" @@ -590,11 +606,35 @@ def test_remap_palette(self): 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 + assert len(im_remapped.getpalette()) == 6 + + # 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") @@ -637,9 +677,17 @@ def test_no_resource_warning_on_save(self, tmp_path): # Act/Assert with Image.open(test_file) as im: - with pytest.warns(None) as record: + with warnings.catch_warnings(): im.save(temp_file) - assert not record + + def test_no_new_file_on_error(self, tmp_path): + temp_file = str(tmp_path / "temp.jpg") + + im = Image.new("RGB", (0, 0)) + with pytest.raises(ValueError): + im.save(temp_file) + + assert not os.path.exists(temp_file) def test_load_on_nonexclusive_multiframe(self): with open("Tests/images/frozenpond.mpo", "rb") as fp: @@ -655,6 +703,19 @@ def act(fp): assert not fp.closed + def test_empty_exif(self): + with Image.open("Tests/images/exif.png") as im: + exif = im.getexif() + assert dict(exif) + + # Test that exif data is cleared after another load + exif.load(None) + assert not dict(exif) + + # Test loading just the EXIF header + exif.load(b"Exif\x00\x00") + assert not dict(exif) + @mark_if_feature_version( pytest.mark.valgrind_known_error, "libjpeg_turbo", "2.0", reason="Known Failing" ) @@ -756,6 +817,18 @@ def test_exif_interop(self): reloaded_exif.load(exif.tobytes()) assert reloaded_exif.get_ifd(0xA005) == exif.get_ifd(0xA005) + def test_exif_ifd1(self): + with Image.open("Tests/images/flower.jpg") as im: + exif = im.getexif() + assert exif.get_ifd(ExifTags.IFD.IFD1) == { + 513: 2036, + 514: 5448, + 259: 6, + 296: 2, + 282: 180.0, + 283: 180.0, + } + def test_exif_ifd(self): with Image.open("Tests/images/flower.jpg") as im: exif = im.getexif() @@ -786,6 +859,65 @@ def test_exif_load_from_fp(self): 34665: 196, } + def test_exif_hide_offsets(self): + with Image.open("Tests/images/flower.jpg") as im: + exif = im.getexif() + + # Check offsets are present initially + assert 0x8769 in exif + for tag in (0xA005, 0x927C): + assert tag in exif.get_ifd(0x8769) + assert exif.get_ifd(0xA005) + loaded_exif = exif + + with Image.open("Tests/images/flower.jpg") as im: + new_exif = im.getexif() + + for exif in (loaded_exif, new_exif): + exif.hide_offsets() + + # Assert they are hidden afterwards, + # but that the IFDs are still available + assert 0x8769 not in exif + assert exif.get_ifd(0x8769) + for tag in (0xA005, 0x927C): + assert tag not in exif.get_ifd(0x8769) + assert exif.get_ifd(0xA005) + + @pytest.mark.parametrize("size", ((1, 0), (0, 1), (0, 0))) + def test_zero_tobytes(self, size): + 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 @@ -797,6 +929,25 @@ def test_categories_deprecation(self): with pytest.warns(DeprecationWarning): assert Image.CONTAINER == 2 + def test_constants(self): + with pytest.warns(DeprecationWarning): + assert Image.LINEAR == Image.Resampling.BILINEAR + with pytest.warns(DeprecationWarning): + assert Image.CUBIC == Image.Resampling.BICUBIC + with pytest.warns(DeprecationWarning): + assert Image.ANTIALIAS == Image.Resampling.LANCZOS + + for enum in ( + Image.Transpose, + Image.Transform, + Image.Resampling, + Image.Dither, + Image.Palette, + Image.Quantize, + ): + for name in enum.__members__: + assert getattr(Image, name) == enum[name] + @pytest.mark.parametrize( "path", [ diff --git a/Tests/test_image_access.py b/Tests/test_image_access.py index 7b30369793c..6c4f1ceec04 100644 --- a/Tests/test_image_access.py +++ b/Tests/test_image_access.py @@ -1,15 +1,13 @@ -import ctypes import os import subprocess import sys import sysconfig import pytest -from setuptools.command.build_ext import new_compiler from PIL import Image -from .helper import assert_image_equal, hopper, is_win32, on_ci +from .helper import assert_image_equal, hopper, is_win32 # CFFI imports pycparser which doesn't support PYTHONOPTIMIZE=2 # https://github.com/eliben/pycparser/pull/198#issuecomment-317001670 @@ -132,8 +130,7 @@ def color(mode): bands = Image.getmodebands(mode) if bands == 1: return 1 - else: - return tuple(range(1, bands + 1)) + return tuple(range(1, bands + 1)) def check(self, mode, c=None): if not c: @@ -154,14 +151,17 @@ def check(self, mode, c=None): # Check 0 im = Image.new(mode, (0, 0), None) - with pytest.raises(IndexError): + assert im.load() is not None + + error = ValueError if self._need_cffi_access else IndexError + with pytest.raises(error): im.putpixel((0, 0), c) - with pytest.raises(IndexError): + with pytest.raises(error): im.getpixel((0, 0)) # Check 0 negative index - with pytest.raises(IndexError): + with pytest.raises(error): im.putpixel((-1, -1), c) - with pytest.raises(IndexError): + with pytest.raises(error): im.getpixel((-1, -1)) # check initial color @@ -176,14 +176,15 @@ def check(self, mode, c=None): # Check 0 im = Image.new(mode, (0, 0), c) - with pytest.raises(IndexError): + with pytest.raises(error): im.getpixel((0, 0)) # Check 0 negative index - with pytest.raises(IndexError): + with pytest.raises(error): im.getpixel((-1, -1)) - def test_basic(self): - for mode in ( + @pytest.mark.parametrize( + "mode", + ( "1", "L", "LA", @@ -198,23 +199,28 @@ def test_basic(self): "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("mode", ("P", "PA")) + @pytest.mark.parametrize("color", ((255, 0, 0), (255, 0, 0, 255))) + def test_p_putpixel_rgb_rgba(self, mode, color): + im = Image.new(mode, (1, 1)) + im.putpixel((0, 0), color) + + alpha = color[3] if len(color) == 4 and mode == "PA" else 255 + assert im.convert("RGBA").getpixel((0, 0)) == (255, 0, 0, alpha) @pytest.mark.skipif(cffi is None, reason="No CFFI") @@ -335,12 +341,16 @@ def test_reference_counting(self): # pixels can contain garbage if image is released assert px[i, 0] == 0 - def test_p_putpixel_rgb_rgba(self): - for color in [(255, 0, 0), (255, 0, 0, 255)]: - im = Image.new("P", (1, 1), 0) + @pytest.mark.parametrize("mode", ("P", "PA")) + def test_p_putpixel_rgb_rgba(self, mode): + for color in ((255, 0, 0), (255, 0, 0, 127 if mode == "PA" else 255)): + im = Image.new(mode, (1, 1)) access = PyAccess.new(im, False) access.putpixel((0, 0), color) - assert im.convert("RGB").getpixel((0, 0)) == (255, 0, 0) + + if len(color) == 3: + color += (255,) + assert im.convert("RGBA").getpixel((0, 0)) == color class TestImagePutPixelError(AccessTest): @@ -386,7 +396,7 @@ def test_putpixel_type_error2(self, mode): def test_putpixel_overflow_error(self, mode): im = hopper(mode) with pytest.raises(OverflowError): - im.putpixel((0, 0), 2 ** 80) + im.putpixel((0, 0), 2**80) def test_putpixel_unrecognized_mode(self): im = hopper("BGR;15") @@ -395,13 +405,14 @@ def test_putpixel_unrecognized_mode(self): class TestEmbeddable: - @pytest.mark.skipif( - not is_win32() or on_ci(), - reason="Failing on AppVeyor / GitHub Actions when run from subprocess, " - "not from shell", - ) + @pytest.mark.xfail(reason="failing test") + @pytest.mark.skipif(not is_win32(), reason="requires Windows") def test_embeddable(self): - with open("embed_pil.c", "w") as fh: + import ctypes + + from setuptools.command.build_ext import new_compiler + + with open("embed_pil.c", "w", encoding="utf-8") as fh: fh.write( """ #include "Python.h" diff --git a/Tests/test_image_array.py b/Tests/test_image_array.py index 5c9cdd7e0e0..ae3518e44cb 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 @@ -35,8 +36,12 @@ def test_with_dtype(dtype): 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 pytest.raises(OSError): + numpy.array(im_truncated) + else: + with pytest.warns(UserWarning): + numpy.array(im_truncated) def test_fromarray(): @@ -80,3 +85,15 @@ def test(mode): 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 a5a95e96255..0a7202a338d 100644 --- a/Tests/test_image_convert.py +++ b/Tests/test_image_convert.py @@ -27,15 +27,21 @@ def convert(im, mode): "HSV", ) - for mode in modes: - im = hopper(mode) - for mode in modes: - convert(im, mode) + for input_mode in modes: + im = hopper(input_mode) + for output_mode in modes: + convert(im, output_mode) # Check 0 - im = Image.new(mode, (0, 0)) - for mode in modes: - convert(im, mode) + im = Image.new(input_mode, (0, 0)) + for output_mode in modes: + convert(im, output_mode) + + +def test_unsupported_conversion(): + im = hopper() + with pytest.raises(ValueError): + im.convert("INVALID") def test_default(): @@ -70,12 +76,24 @@ def test_16bit(): with Image.open("Tests/images/16bit.cropped.tif") as im: _test_float_conversion(im) + for color in (65535, 65536): + im = Image.new("I", (1, 1), color) + im_i16 = im.convert("I;16") + assert im_i16.getpixel((0, 0)) == 65535 + def test_16bit_workaround(): with Image.open("Tests/images/16bit.cropped.tif") as im: _test_float_conversion(im.convert("I")) +def test_opaque(): + alpha = hopper("P").convert("PA").getchannel("A") + + solid = Image.new("L", (128, 128), 255) + assert_image_equal(alpha, solid) + + def test_rgba_p(): im = hopper("RGBA") im.putalpha(hopper("L")) @@ -86,6 +104,13 @@ def test_rgba_p(): assert_image_similar(im, comparable, 20) +def test_rgba(): + with Image.open("Tests/images/transparent.png") as im: + assert im.mode == "RGBA" + + assert_image_similar(im.convert("RGBa").convert("RGB"), im.convert("RGB"), 1.5) + + def test_trns_p(tmp_path): im = hopper("P") im.info["transparency"] = 0 @@ -128,6 +153,10 @@ def test_trns_l(tmp_path): f = str(tmp_path / "temp.png") + im_la = im.convert("LA") + assert "transparency" not in im_la.info + im_la.save(f) + im_rgb = im.convert("RGB") assert im_rgb.info["transparency"] == (128, 128, 128) # undone im_rgb.save(f) @@ -136,7 +165,7 @@ def test_trns_l(tmp_path): assert "transparency" in im_p.info im_p.save(f) - im_p = im.convert("P", palette=Image.ADAPTIVE) + im_p = im.convert("P", palette=Image.Palette.ADAPTIVE) assert "transparency" in im_p.info im_p.save(f) @@ -159,13 +188,13 @@ def test_trns_RGB(tmp_path): assert "transparency" not in im_rgba.info im_rgba.save(f) - im_p = pytest.warns(UserWarning, im.convert, "P", palette=Image.ADAPTIVE) + im_p = pytest.warns(UserWarning, im.convert, "P", palette=Image.Palette.ADAPTIVE) assert "transparency" not in im_p.info im_p.save(f) im = Image.new("RGB", (1, 1)) im.info["transparency"] = im.getpixel((0, 0)) - im_p = im.convert("P", palette=Image.ADAPTIVE) + im_p = im.convert("P", palette=Image.Palette.ADAPTIVE) assert im_p.info["transparency"] == im_p.getpixel((0, 0)) im_p.save(f) @@ -206,6 +235,37 @@ 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_p2pa_palette(): + with Image.open("Tests/images/tiny.png") as im: + im_pa = im.convert("PA") + assert im_pa.getpalette() == im.getpalette() + + +@pytest.mark.parametrize("mode", ("RGB", "RGBA", "RGBX")) +def test_rgb_lab(mode): + im = Image.new(mode, (1, 1)) + converted_im = im.convert("LAB") + assert converted_im.getpixel((0, 0)) == (0, 128, 128) + + im = Image.new("LAB", (1, 1), (255, 0, 0)) + converted_im = im.convert(mode) + assert converted_im.getpixel((0, 0))[:3] == (0, 255, 255) + + def test_matrix_illegal_conversion(): # Arrange im = hopper("CMYK") @@ -238,36 +298,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" - - # 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") +@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) + + # 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 ad0391dbe5e..591832147d7 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(): - croppedCoordinates = (10, 10, 20, 20) - croppedSize = (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 on a cropped image - im = hopper(mode) - out = im.crop(croppedCoordinates).copy() - assert out.mode == im.mode - assert out.size == croppedSize - - # Python's copy method on a cropped image - im = hopper(mode) - out = copy.copy(im.crop(croppedCoordinates)) - assert out.mode == im.mode - assert out.size == croppedSize +@pytest.mark.parametrize("mode", ("1", "P", "L", "RGB", "I", "F")) +def test_copy(mode): + cropped_coordinates = (10, 10, 20, 20) + cropped_size = (10, 10) + + # 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 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 e2228758c09..4aa41de2792 100644 --- a/Tests/test_image_crop.py +++ b/Tests/test_image_crop.py @@ -5,17 +5,14 @@ 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(): @@ -47,16 +44,12 @@ def crop(*bbox): assert crop(-25, 75, 25, 125) == (1875, 625) -def test_negative_crop(): - # Check negative crop size (@PIL171) - - im = Image.new("L", (512, 512)) - im = im.crop((400, 400, 200, 200)) +@pytest.mark.parametrize("box", ((8, 2, 2, 8), (2, 8, 8, 2), (8, 8, 2, 2))) +def test_negative_crop(box): + im = Image.new("RGB", (10, 10)) - assert im.size == (0, 0) - assert len(im.getdata()) == 0 - with pytest.raises(IndexError): - im.getdata()[0] + with pytest.raises(ValueError): + im.crop(box) def test_crop_float(): diff --git a/Tests/test_image_entropy.py b/Tests/test_image_entropy.py index 876d676fe39..ea5886e72db 100644 --- a/Tests/test_image_entropy.py +++ b/Tests/test_image_entropy.py @@ -9,7 +9,7 @@ def entropy(mode): 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_filter.py b/Tests/test_image_filter.py index df8c353f391..cfe46b65898 100644 --- a/Tests/test_image_filter.py +++ b/Tests/test_image_filter.py @@ -5,90 +5,109 @@ from .helper import assert_image_equal, hopper -def test_sanity(): - def apply_filter(filter_to_apply): - for mode in ["L", "RGB", "CMYK"]: - im = hopper(mode) - out = im.filter(filter_to_apply) - assert out.mode == im.mode - assert out.size == im.size - - apply_filter(ImageFilter.BLUR) - apply_filter(ImageFilter.CONTOUR) - apply_filter(ImageFilter.DETAIL) - apply_filter(ImageFilter.EDGE_ENHANCE) - apply_filter(ImageFilter.EDGE_ENHANCE_MORE) - apply_filter(ImageFilter.EMBOSS) - apply_filter(ImageFilter.FIND_EDGES) - apply_filter(ImageFilter.SMOOTH) - apply_filter(ImageFilter.SMOOTH_MORE) - apply_filter(ImageFilter.SHARPEN) - apply_filter(ImageFilter.MaxFilter) - apply_filter(ImageFilter.MedianFilter) - apply_filter(ImageFilter.MinFilter) - apply_filter(ImageFilter.ModeFilter) - apply_filter(ImageFilter.GaussianBlur) - apply_filter(ImageFilter.GaussianBlur(5)) - apply_filter(ImageFilter.BoxBlur(5)) - apply_filter(ImageFilter.UnsharpMask) - apply_filter(ImageFilter.UnsharpMask(10)) - +@pytest.mark.parametrize( + "filter_to_apply", + ( + ImageFilter.BLUR, + ImageFilter.CONTOUR, + ImageFilter.DETAIL, + ImageFilter.EDGE_ENHANCE, + ImageFilter.EDGE_ENHANCE_MORE, + ImageFilter.EMBOSS, + ImageFilter.FIND_EDGES, + ImageFilter.SMOOTH, + ImageFilter.SMOOTH_MORE, + ImageFilter.SHARPEN, + ImageFilter.MaxFilter, + ImageFilter.MedianFilter, + ImageFilter.MinFilter, + ImageFilter.ModeFilter, + ImageFilter.GaussianBlur, + ImageFilter.GaussianBlur(5), + ImageFilter.BoxBlur(5), + ImageFilter.UnsharpMask, + ImageFilter.UnsharpMask(10), + ), +) +@pytest.mark.parametrize("mode", ("L", "RGB", "CMYK")) +def test_sanity(filter_to_apply, mode): + im = hopper(mode) + out = im.filter(filter_to_apply) + assert out.mode == im.mode + assert out.size == im.size + + +@pytest.mark.parametrize("mode", ("L", "RGB", "CMYK")) +def test_sanity_error(mode): with pytest.raises(TypeError): - apply_filter("hello") - - -def test_crash(): - - # crashes on small images - im = Image.new("RGB", (1, 1)) - im.filter(ImageFilter.SMOOTH) + im = hopper(mode) + im.filter("hello") - im = Image.new("RGB", (2, 2)) - im.filter(ImageFilter.SMOOTH) - im = Image.new("RGB", (3, 3)) +# crashes on small images +@pytest.mark.parametrize("size", ((1, 1), (2, 2), (3, 3))) +def test_crash(size): + im = Image.new("RGB", size) im.filter(ImageFilter.SMOOTH) -def test_modefilter(): - def modefilter(mode): - im = Image.new(mode, (3, 3), None) - im.putdata(list(range(9))) - # image is: - # 0 1 2 - # 3 4 5 - # 6 7 8 - mod = im.filter(ImageFilter.ModeFilter).getpixel((1, 1)) - im.putdata([0, 0, 1, 2, 5, 1, 5, 2, 0]) # mode=0 - mod2 = im.filter(ImageFilter.ModeFilter).getpixel((1, 1)) - return mod, mod2 - - assert modefilter("1") == (4, 0) - assert modefilter("L") == (4, 0) - assert modefilter("P") == (4, 0) - assert modefilter("RGB") == ((4, 0, 0), (0, 0, 0)) - - -def test_rankfilter(): - def rankfilter(mode): - im = Image.new(mode, (3, 3), None) +@pytest.mark.parametrize( + "mode, expected", + ( + ("1", (4, 0)), + ("L", (4, 0)), + ("P", (4, 0)), + ("RGB", ((4, 0, 0), (0, 0, 0))), + ), +) +def test_modefilter(mode, expected): + im = Image.new(mode, (3, 3), None) + im.putdata(list(range(9))) + # image is: + # 0 1 2 + # 3 4 5 + # 6 7 8 + mod = im.filter(ImageFilter.ModeFilter).getpixel((1, 1)) + im.putdata([0, 0, 1, 2, 5, 1, 5, 2, 0]) # mode=0 + mod2 = im.filter(ImageFilter.ModeFilter).getpixel((1, 1)) + assert (mod, mod2) == expected + + +@pytest.mark.parametrize( + "mode, expected", + ( + ("1", (0, 4, 8)), + ("L", (0, 4, 8)), + ("RGB", ((0, 0, 0), (4, 0, 0), (8, 0, 0))), + ("I", (0, 4, 8)), + ("F", (0.0, 4.0, 8.0)), + ), +) +def test_rankfilter(mode, expected): + im = Image.new(mode, (3, 3), None) + im.putdata(list(range(9))) + # image is: + # 0 1 2 + # 3 4 5 + # 6 7 8 + minimum = im.filter(ImageFilter.MinFilter).getpixel((1, 1)) + med = im.filter(ImageFilter.MedianFilter).getpixel((1, 1)) + maximum = im.filter(ImageFilter.MaxFilter).getpixel((1, 1)) + assert (minimum, med, maximum) == expected + + +@pytest.mark.parametrize( + "filter", (ImageFilter.MinFilter, ImageFilter.MedianFilter, ImageFilter.MaxFilter) +) +def test_rankfilter_error(filter): + with pytest.raises(ValueError): + im = Image.new("P", (3, 3), None) im.putdata(list(range(9))) # image is: # 0 1 2 # 3 4 5 # 6 7 8 - minimum = im.filter(ImageFilter.MinFilter).getpixel((1, 1)) - med = im.filter(ImageFilter.MedianFilter).getpixel((1, 1)) - maximum = im.filter(ImageFilter.MaxFilter).getpixel((1, 1)) - return minimum, med, maximum - - assert rankfilter("1") == (0, 4, 8) - assert rankfilter("L") == (0, 4, 8) - with pytest.raises(ValueError): - rankfilter("P") - assert rankfilter("RGB") == ((0, 0, 0), (4, 0, 0), (8, 0, 0)) - assert rankfilter("I") == (0, 4, 8) - assert rankfilter("F") == (0.0, 4.0, 8.0) + im.filter(filter).getpixel((1, 1)) def test_rankfilter_properties(): @@ -99,10 +118,10 @@ def test_rankfilter_properties(): def test_builtinfilter_p(): - builtinFilter = ImageFilter.BuiltinFilter() + builtin_filter = ImageFilter.BuiltinFilter() with pytest.raises(ValueError): - builtinFilter.filter(hopper("P")) + builtin_filter.filter(hopper("P")) def test_kernel_not_enough_coefficients(): @@ -110,7 +129,8 @@ def test_kernel_not_enough_coefficients(): ImageFilter.Kernel((3, 3), (0, 0)) -def test_consistency_3x3(): +@pytest.mark.parametrize("mode", ("L", "LA", "RGB", "CMYK")) +def test_consistency_3x3(mode): with Image.open("Tests/images/hopper.bmp") as source: with Image.open("Tests/images/hopper_emboss.bmp") as reference: kernel = ImageFilter.Kernel( @@ -125,14 +145,14 @@ def test_consistency_3x3(): source = source.split() * 2 reference = reference.split() * 2 - for mode in ["L", "LA", "RGB", "CMYK"]: - assert_image_equal( - Image.merge(mode, source[: len(mode)]).filter(kernel), - Image.merge(mode, reference[: len(mode)]), - ) + assert_image_equal( + Image.merge(mode, source[: len(mode)]).filter(kernel), + Image.merge(mode, reference[: len(mode)]), + ) -def test_consistency_5x5(): +@pytest.mark.parametrize("mode", ("L", "LA", "RGB", "CMYK")) +def test_consistency_5x5(mode): with Image.open("Tests/images/hopper.bmp") as source: with Image.open("Tests/images/hopper_emboss_more.bmp") as reference: kernel = ImageFilter.Kernel( @@ -149,8 +169,7 @@ def test_consistency_5x5(): source = source.split() * 2 reference = reference.split() * 2 - for mode in ["L", "LA", "RGB", "CMYK"]: - assert_image_equal( - Image.merge(mode, source[: len(mode)]).filter(kernel), - Image.merge(mode, reference[: len(mode)]), - ) + assert_image_equal( + Image.merge(mode, source[: len(mode)]).filter(kernel), + Image.merge(mode, reference[: len(mode)]), + ) diff --git a/Tests/test_image_fromqimage.py b/Tests/test_image_fromqimage.py index 5ad5b5c3c0a..7fe992353bc 100644 --- a/Tests/test_image_fromqimage.py +++ b/Tests/test_image_fromqimage.py @@ -1,6 +1,12 @@ +import warnings + import pytest -from PIL import Image, ImageQt +from PIL import Image + +with warnings.catch_warnings(): + warnings.simplefilter("ignore", category=DeprecationWarning) + from PIL import ImageQt from .helper import assert_image_equal, hopper diff --git a/Tests/test_image_getcolors.py b/Tests/test_image_getcolors.py index e5b6a772462..7fd0398f947 100644 --- a/Tests/test_image_getcolors.py +++ b/Tests/test_image_getcolors.py @@ -16,7 +16,7 @@ def getcolors(mode, limit=None): 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_getdata.py b/Tests/test_image_getdata.py index 159efd78aa2..36c81b40f07 100644 --- a/Tests/test_image_getdata.py +++ b/Tests/test_image_getdata.py @@ -14,7 +14,7 @@ def test_sanity(): def test_roundtrip(): def getdata(mode): - im = hopper(mode).resize((32, 30), Image.NEAREST) + im = hopper(mode).resize((32, 30), Image.Resampling.NEAREST) data = im.getdata() return data[0], len(data), len(list(data)) diff --git a/Tests/test_image_getpalette.py b/Tests/test_image_getpalette.py index 1818adca234..58a6dacbbbb 100644 --- a/Tests/test_image_getpalette.py +++ b/Tests/test_image_getpalette.py @@ -1,3 +1,5 @@ +from PIL import Image + from .helper import hopper @@ -17,3 +19,26 @@ def palette(mode): assert palette("RGBA") is None assert palette("CMYK") is None assert palette("YCbCr") is None + + +def test_palette_rawmode(): + im = Image.new("P", (1, 1)) + im.putpalette((1, 2, 3)) + + for rawmode in ("RGB", None): + rgb = im.getpalette(rawmode) + assert rgb == [1, 2, 3] + + # Convert the RGB palette to RGBA + rgba = im.getpalette("RGBA") + assert rgba == [1, 2, 3, 255] + + im.putpalette((1, 2, 3, 4), "RGBA") + + # Convert the RGBA palette to RGB + rgb = im.getpalette("RGB") + assert rgb == [1, 2, 3] + + for rawmode in ("RGBA", None): + rgba = im.getpalette(rawmode) + assert rgba == [1, 2, 3, 4] diff --git a/Tests/test_image_histogram.py b/Tests/test_image_histogram.py index 91e02973d04..0ee52e724e1 100644 --- a/Tests/test_image_histogram.py +++ b/Tests/test_image_histogram.py @@ -10,7 +10,7 @@ def histogram(mode): 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_mode.py b/Tests/test_image_mode.py index 7f92c226416..670b2f4ebde 100644 --- a/Tests/test_image_mode.py +++ b/Tests/test_image_mode.py @@ -21,6 +21,7 @@ def test_sanity(): assert m.bands == ("1",) assert m.basemode == "L" assert m.basetype == "L" + assert m.typestr == "|b1" for mode in ( "I;16", @@ -45,6 +46,7 @@ def test_sanity(): assert m.bands == ("R", "G", "B") assert m.basemode == "RGB" assert m.basetype == "L" + assert m.typestr == "|u1" def test_properties(): @@ -65,6 +67,5 @@ def check(mode, *result): check("RGB", "RGB", "L", 3, ("R", "G", "B")) check("RGBA", "RGB", "L", 4, ("R", "G", "B", "A")) check("RGBX", "RGB", "L", 4, ("R", "G", "B", "X")) - check("RGBX", "RGB", "L", 4, ("R", "G", "B", "X")) check("CMYK", "RGB", "L", 4, ("C", "M", "Y", "K")) check("YCbCr", "RGB", "L", 3, ("Y", "Cb", "Cr")) diff --git a/Tests/test_image_paste.py b/Tests/test_image_paste.py index 1d3ca813550..1ab02017de1 100644 --- a/Tests/test_image_paste.py +++ b/Tests/test_image_paste.py @@ -1,6 +1,8 @@ +import pytest + from PIL import Image -from .helper import assert_image_equal, cached_property +from .helper import CachedProperty, assert_image_equal class TestImagingPaste: @@ -34,7 +36,7 @@ def assert_9points_paste(self, im, im2, mask, expected): im.paste(im2, mask) self.assert_9points_image(im, expected) - @cached_property + @CachedProperty def mask_1(self): mask = Image.new("1", (self.size, self.size)) px = mask.load() @@ -43,11 +45,11 @@ def mask_1(self): px[y, x] = (x + y) % 2 return mask - @cached_property + @CachedProperty def mask_L(self): - return self.gradient_L.transpose(Image.ROTATE_270) + return self.gradient_L.transpose(Image.Transpose.ROTATE_270) - @cached_property + @CachedProperty def gradient_L(self): gradient = Image.new("L", (self.size, self.size)) px = gradient.load() @@ -56,239 +58,271 @@ def gradient_L(self): px[y, x] = (x + y) % 255 return gradient - @cached_property + @CachedProperty def gradient_RGB(self): return Image.merge( "RGB", [ self.gradient_L, - self.gradient_L.transpose(Image.ROTATE_90), - self.gradient_L.transpose(Image.ROTATE_180), + self.gradient_L.transpose(Image.Transpose.ROTATE_90), + self.gradient_L.transpose(Image.Transpose.ROTATE_180), + ], + ) + + @CachedProperty + def gradient_LA(self): + return Image.merge( + "LA", + [ + self.gradient_L, + self.gradient_L.transpose(Image.Transpose.ROTATE_90), ], ) - @cached_property + @CachedProperty def gradient_RGBA(self): return Image.merge( "RGBA", [ self.gradient_L, - self.gradient_L.transpose(Image.ROTATE_90), - self.gradient_L.transpose(Image.ROTATE_180), - self.gradient_L.transpose(Image.ROTATE_270), + self.gradient_L.transpose(Image.Transpose.ROTATE_90), + self.gradient_L.transpose(Image.Transpose.ROTATE_180), + self.gradient_L.transpose(Image.Transpose.ROTATE_270), ], ) - @cached_property + @CachedProperty def gradient_RGBa(self): return Image.merge( "RGBa", [ self.gradient_L, - self.gradient_L.transpose(Image.ROTATE_90), - self.gradient_L.transpose(Image.ROTATE_180), - self.gradient_L.transpose(Image.ROTATE_270), + self.gradient_L.transpose(Image.Transpose.ROTATE_90), + self.gradient_L.transpose(Image.Transpose.ROTATE_180), + self.gradient_L.transpose(Image.Transpose.ROTATE_270), + ], + ) + + @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 = im.crop((12, 23, im2.width + 12, im2.height + 23)) + assert_image_equal(im, im2) + + @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), ], ) - def test_image_solid(self): - for mode in ("RGBA", "RGB", "L"): - im = Image.new(mode, (200, 200), "red") - im2 = getattr(self, "gradient_" + mode) - - im.paste(im2, (12, 23)) - - 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) - - 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) - - 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_RGBA(self): - for mode in ("RGBA", "RGB", "L"): - 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), - ], - ) - - def test_image_mask_RGBa(self): - for mode in ("RGBA", "RGB", "L"): - 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), - ], - ) - - def test_color_solid(self): - for mode in ("RGBA", "RGB", "L"): - im = Image.new(mode, (200, 200), "black") - - 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 - - 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)] - - 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" - - 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" - - 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" - - 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), - ], - ) + @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), + ], + ) + + @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), + ], + ) + + @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), + ], + ) + + @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), + ], + ) + + @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) + + hist = im.crop(rect).histogram() + while hist: + head, hist = hist[:256], hist[256:] + assert head[255] == 128 * 128 + assert sum(head[:255]) == 0 + + @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), + ], + ) + + @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), + ], + ) + + @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), + ], + ) + + @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), + ], + ) 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 366f458544f..157ecb120f0 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 @@ -10,17 +12,31 @@ def test_sanity(): im.point(list(range(256))) im.point(list(range(256)) * 3) im.point(lambda x: x) + im.point(lambda x: x * 1.2) im = im.convert("I") with pytest.raises(ValueError): 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 * x) + with pytest.raises(TypeError): + im.point(lambda x: x / x) with pytest.raises(TypeError): - im.point(lambda x: x - 1) + im.point(lambda x: 1 / x) with pytest.raises(TypeError): - im.point(lambda x: x / 1) + im.point(lambda x: x // 2) def test_16bit_lut(): @@ -46,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_putdata.py b/Tests/test_image_putdata.py index 7e4bbaaec61..0e6293349bc 100644 --- a/Tests/test_image_putdata.py +++ b/Tests/test_image_putdata.py @@ -38,7 +38,7 @@ def put(value): assert put(0xFFFFFFFF) == (255, 255, 255, 255) assert put(-1) == (255, 255, 255, 255) assert put(-1) == (255, 255, 255, 255) - if sys.maxsize > 2 ** 32: + if sys.maxsize > 2**32: assert put(sys.maxsize) == (255, 255, 255, 255) else: assert put(sys.maxsize) == (255, 255, 255, 127) @@ -55,10 +55,11 @@ def test_mode_with_L_with_float(): assert im.getpixel((0, 0)) == 2 -def test_mode_i(): +@pytest.mark.parametrize("mode", ("I", "I;16", "I;16L", "I;16B")) +def test_mode_i(mode): src = hopper("L") data = list(src.getdata()) - im = Image.new("I", src.size, 0) + im = Image.new(mode, src.size, 0) im.putdata(data, 2, 256) target = [2 * elt + 256 for elt in data] diff --git a/Tests/test_image_putpalette.py b/Tests/test_image_putpalette.py index 012a57a0999..3b29769a7a4 100644 --- a/Tests/test_image_putpalette.py +++ b/Tests/test_image_putpalette.py @@ -62,3 +62,17 @@ def test_putpalette_with_alpha_values(): im.putpalette(palette_with_alpha_values, "RGBA") assert_image_equal(im.convert("RGBA"), expected) + + +@pytest.mark.parametrize( + "mode, palette", + ( + ("RGBA", (1, 2, 3, 4)), + ("RGBAX", (1, 2, 3, 4, 0)), + ), +) +def test_rgba_palette(mode, palette): + im = Image.new("P", (1, 1)) + im.putpalette(palette, mode) + assert im.getpalette() == [1, 2, 3] + assert im.palette.colors == {(1, 2, 3, 4): 0} diff --git a/Tests/test_image_quantize.py b/Tests/test_image_quantize.py index 53b6c900793..981753eb9b7 100644 --- a/Tests/test_image_quantize.py +++ b/Tests/test_image_quantize.py @@ -1,8 +1,9 @@ import pytest +from packaging.version import parse as parse_version -from PIL import Image +from PIL import Image, features -from .helper import assert_image_similar, hopper, is_ppc64le +from .helper import assert_image_similar, hopper, is_ppc64le, skip_unless_feature def test_sanity(): @@ -17,16 +18,14 @@ def test_sanity(): assert_image_similar(converted.convert("RGB"), image, 60) -@pytest.mark.xfail(is_ppc64le(), reason="failing on ppc64le on GHA") +@skip_unless_feature("libimagequant") def test_libimagequant_quantize(): image = hopper() - try: - converted = image.quantize(100, Image.LIBIMAGEQUANT) - except ValueError as ex: # pragma: no cover - if "dependency" in str(ex).lower(): - pytest.skip("libimagequant support not available") - else: - raise + if is_ppc64le(): + libimagequant = parse_version(features.version_feature("libimagequant")) + if libimagequant < parse_version("4"): + pytest.skip("Fails with libimagequant earlier than 4.0.0 on ppc64le") + converted = image.quantize(100, Image.Quantize.LIBIMAGEQUANT) assert converted.mode == "P" assert_image_similar(converted.convert("RGB"), image, 15) assert len(converted.getcolors()) == 100 @@ -34,7 +33,7 @@ def test_libimagequant_quantize(): def test_octree_quantize(): image = hopper() - converted = image.quantize(100, Image.FASTOCTREE) + converted = image.quantize(100, Image.Quantize.FASTOCTREE) assert converted.mode == "P" assert_image_similar(converted.convert("RGB"), image, 20) assert len(converted.getcolors()) == 100 @@ -61,18 +60,34 @@ def test_quantize_no_dither(): with Image.open("Tests/images/caption_6_33_22.png") as palette: palette = palette.convert("P") - converted = image.quantize(dither=0, palette=palette) + converted = image.quantize(dither=Image.Dither.NONE, palette=palette) assert converted.mode == "P" 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: palette = palette.convert("P") - dither = image.quantize(dither=1, palette=palette) - nodither = image.quantize(dither=0, palette=palette) + dither = image.quantize(dither=Image.Dither.FLOYDSTEINBERG, palette=palette) + nodither = image.quantize(dither=Image.Dither.NONE, palette=palette) assert dither.tobytes() != nodither.tobytes() @@ -97,10 +112,10 @@ def test_transparent_colors_equal(): @pytest.mark.parametrize( "method, color", ( - (Image.MEDIANCUT, (0, 0, 0)), - (Image.MAXCOVERAGE, (0, 0, 0)), - (Image.FASTOCTREE, (0, 0, 0)), - (Image.FASTOCTREE, (0, 0, 0, 0)), + (Image.Quantize.MEDIANCUT, (0, 0, 0)), + (Image.Quantize.MAXCOVERAGE, (0, 0, 0)), + (Image.Quantize.FASTOCTREE, (0, 0, 0)), + (Image.Quantize.FASTOCTREE, (0, 0, 0, 0)), ), ) def test_palette(method, color): @@ -109,3 +124,18 @@ def test_palette(method, color): converted = im.quantize(method=method) converted_px = converted.load() assert converted_px[0, 0] == converted.palette.colors[color] + + +def test_small_palette(): + # Arrange + im = hopper() + + colors = (255, 0, 0, 0, 0, 255) + p = Image.new("P", (1, 1)) + p.putpalette(colors) + + # Act + im = im.quantize(palette=p) + + # Assert + assert len(im.getcolors()) == 2 diff --git a/Tests/test_image_reduce.py b/Tests/test_image_reduce.py index b4eebc14218..ae8d740a027 100644 --- a/Tests/test_image_reduce.py +++ b/Tests/test_image_reduce.py @@ -38,58 +38,64 @@ gradients_image.load() -def test_args_factor(): +@pytest.mark.parametrize( + "size, expected", + ( + (3, (4, 4)), + ((3, 1), (4, 10)), + ((1, 3), (10, 4)), + ), +) +def test_args_factor(size, expected): im = Image.new("L", (10, 10)) + assert expected == im.reduce(size).size - assert (4, 4) == im.reduce(3).size - assert (4, 10) == im.reduce((3, 1)).size - assert (10, 4) == im.reduce((1, 3)).size - with pytest.raises(ValueError): - im.reduce(0) - with pytest.raises(TypeError): - im.reduce(2.0) - with pytest.raises(ValueError): - im.reduce((0, 10)) - - -def test_args_box(): +@pytest.mark.parametrize( + "size, expected_error", ((0, ValueError), (2.0, TypeError), ((0, 10), ValueError)) +) +def test_args_factor_error(size, expected_error): im = Image.new("L", (10, 10)) - - assert (5, 5) == im.reduce(2, (0, 0, 10, 10)).size - assert (1, 1) == im.reduce(2, (5, 5, 6, 6)).size - - with pytest.raises(TypeError): - im.reduce(2, "stri") - with pytest.raises(TypeError): - im.reduce(2, 2) - with pytest.raises(ValueError): - im.reduce(2, (0, 0, 11, 10)) - with pytest.raises(ValueError): - im.reduce(2, (0, 0, 10, 11)) - with pytest.raises(ValueError): - im.reduce(2, (-1, 0, 10, 10)) - with pytest.raises(ValueError): - im.reduce(2, (0, -1, 10, 10)) - with pytest.raises(ValueError): - im.reduce(2, (0, 5, 10, 5)) - with pytest.raises(ValueError): - im.reduce(2, (5, 0, 5, 10)) + with pytest.raises(expected_error): + im.reduce(size) + + +@pytest.mark.parametrize( + "size, expected", + ( + ((0, 0, 10, 10), (5, 5)), + ((5, 5, 6, 6), (1, 1)), + ), +) +def test_args_box(size, expected): + im = Image.new("L", (10, 10)) + assert expected == im.reduce(2, size).size + + +@pytest.mark.parametrize( + "size, expected_error", + ( + ("stri", TypeError), + ((0, 0, 11, 10), ValueError), + ((0, 0, 10, 11), ValueError), + ((-1, 0, 10, 10), ValueError), + ((0, -1, 10, 10), ValueError), + ((0, 5, 10, 5), ValueError), + ((5, 0, 5, 10), ValueError), + ), +) +def test_args_box_error(size, expected_error): + im = Image.new("L", (10, 10)) + with pytest.raises(expected_error): + im.reduce(2, size).size -def test_unsupported_modes(): +@pytest.mark.parametrize("mode", ("P", "1", "I;16")) +def test_unsupported_modes(mode): im = Image.new("P", (10, 10)) with pytest.raises(ValueError): im.reduce(3) - im = Image.new("1", (10, 10)) - with pytest.raises(ValueError): - im.reduce(3) - - im = Image.new("I;16", (10, 10)) - with pytest.raises(ValueError): - im.reduce(3) - def get_image(mode): mode_info = ImageMode.getmode(mode) @@ -97,7 +103,7 @@ def get_image(mode): bands = [gradients_image] for _ in mode_info.bands[1:]: # rotate previous image - band = bands[-1].transpose(Image.ROTATE_90) + band = bands[-1].transpose(Image.Transpose.ROTATE_90) bands.append(band) # Correct alpha channel by transforming completely transparent pixels. # Low alpha values also emphasize error after alpha multiplication. @@ -138,24 +144,26 @@ def compare_reduce_with_reference(im, factor, average_diff=0.4, max_diff=1): reference = Image.new(im.mode, reduced.size) area_size = (im.size[0] // factor[0], im.size[1] // factor[1]) area_box = (0, 0, area_size[0] * factor[0], area_size[1] * factor[1]) - area = im.resize(area_size, Image.BOX, area_box) + area = im.resize(area_size, Image.Resampling.BOX, area_box) reference.paste(area, (0, 0)) if area_size[0] < reduced.size[0]: assert reduced.size[0] - area_size[0] == 1 last_column_box = (area_box[2], 0, im.size[0], area_box[3]) - last_column = im.resize((1, area_size[1]), Image.BOX, last_column_box) + last_column = im.resize( + (1, area_size[1]), Image.Resampling.BOX, last_column_box + ) reference.paste(last_column, (area_size[0], 0)) if area_size[1] < reduced.size[1]: assert reduced.size[1] - area_size[1] == 1 last_row_box = (0, area_box[3], area_box[2], im.size[1]) - last_row = im.resize((area_size[0], 1), Image.BOX, last_row_box) + last_row = im.resize((area_size[0], 1), Image.Resampling.BOX, last_row_box) reference.paste(last_row, (0, area_size[1])) if area_size[0] < reduced.size[0] and area_size[1] < reduced.size[1]: last_pixel_box = (area_box[2], area_box[3], im.size[0], im.size[1]) - last_pixel = im.resize((1, 1), Image.BOX, last_pixel_box) + last_pixel = im.resize((1, 1), Image.Resampling.BOX, last_pixel_box) reference.paste(last_pixel, area_size) assert_compare_images(reduced, reference, average_diff, max_diff) @@ -188,70 +196,76 @@ def assert_compare_images(a, b, max_average_diff, max_diff=255): ) -def test_mode_L(): +@pytest.mark.parametrize("factor", remarkable_factors) +def test_mode_L(factor): im = get_image("L") - for factor in remarkable_factors: - compare_reduce_with_reference(im, factor) - compare_reduce_with_box(im, factor) + compare_reduce_with_reference(im, factor) + compare_reduce_with_box(im, factor) -def test_mode_LA(): +@pytest.mark.parametrize("factor", remarkable_factors) +def test_mode_LA(factor): im = get_image("LA") - for factor in remarkable_factors: - compare_reduce_with_reference(im, factor, 0.8, 5) + compare_reduce_with_reference(im, factor, 0.8, 5) + +@pytest.mark.parametrize("factor", remarkable_factors) +def test_mode_LA_opaque(factor): + im = get_image("LA") # With opaque alpha, an error should be way smaller. im.putalpha(Image.new("L", im.size, 255)) - for factor in remarkable_factors: - compare_reduce_with_reference(im, factor) - compare_reduce_with_box(im, factor) + compare_reduce_with_reference(im, factor) + compare_reduce_with_box(im, factor) -def test_mode_La(): +@pytest.mark.parametrize("factor", remarkable_factors) +def test_mode_La(factor): im = get_image("La") - for factor in remarkable_factors: - compare_reduce_with_reference(im, factor) - compare_reduce_with_box(im, factor) + compare_reduce_with_reference(im, factor) + compare_reduce_with_box(im, factor) -def test_mode_RGB(): +@pytest.mark.parametrize("factor", remarkable_factors) +def test_mode_RGB(factor): im = get_image("RGB") - for factor in remarkable_factors: - compare_reduce_with_reference(im, factor) - compare_reduce_with_box(im, factor) + compare_reduce_with_reference(im, factor) + compare_reduce_with_box(im, factor) -def test_mode_RGBA(): +@pytest.mark.parametrize("factor", remarkable_factors) +def test_mode_RGBA(factor): im = get_image("RGBA") - for factor in remarkable_factors: - compare_reduce_with_reference(im, factor, 0.8, 5) + compare_reduce_with_reference(im, factor, 0.8, 5) + +@pytest.mark.parametrize("factor", remarkable_factors) +def test_mode_RGBA_opaque(factor): + im = get_image("RGBA") # With opaque alpha, an error should be way smaller. im.putalpha(Image.new("L", im.size, 255)) - for factor in remarkable_factors: - compare_reduce_with_reference(im, factor) - compare_reduce_with_box(im, factor) + compare_reduce_with_reference(im, factor) + compare_reduce_with_box(im, factor) -def test_mode_RGBa(): +@pytest.mark.parametrize("factor", remarkable_factors) +def test_mode_RGBa(factor): im = get_image("RGBa") - for factor in remarkable_factors: - compare_reduce_with_reference(im, factor) - compare_reduce_with_box(im, factor) + compare_reduce_with_reference(im, factor) + compare_reduce_with_box(im, factor) -def test_mode_I(): +@pytest.mark.parametrize("factor", remarkable_factors) +def test_mode_I(factor): im = get_image("I") - for factor in remarkable_factors: - compare_reduce_with_reference(im, factor) - compare_reduce_with_box(im, factor) + compare_reduce_with_reference(im, factor) + compare_reduce_with_box(im, factor) -def test_mode_F(): +@pytest.mark.parametrize("factor", remarkable_factors) +def test_mode_F(factor): im = get_image("F") - for factor in remarkable_factors: - compare_reduce_with_reference(im, factor, 0, 0) - compare_reduce_with_box(im, factor) + compare_reduce_with_reference(im, factor, 0, 0) + compare_reduce_with_box(im, factor) @skip_unless_feature("jpg_2000") diff --git a/Tests/test_image_resample.py b/Tests/test_image_resample.py index bd75be6b161..9def01a9ca5 100644 --- a/Tests/test_image_resample.py +++ b/Tests/test_image_resample.py @@ -24,7 +24,7 @@ def test_overflow(self): ): with pytest.raises(MemoryError): # any resampling filter will do here - im.im.resize((xsize, ysize), Image.BILINEAR) + im.im.resize((xsize, ysize), Image.Resampling.BILINEAR) def test_invalid_size(self): im = hopper() @@ -101,43 +101,44 @@ def serialize_image(self, image): 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.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.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.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_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))) + + @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))) + + @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))) + + @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.BICUBIC) + case = case.resize((6, 6), Image.Resampling.BICUBIC) # fmt: off data = ("e1 e3 d4" "e3 e5 d6" @@ -146,82 +147,84 @@ def test_reduce_bicubic(self): 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.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.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.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.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.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.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)), strict=False) + @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))) + + @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))) + + @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))) + + @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))) + + @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))) + + @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)), strict=False) def test_box_filter_correct_range(self): - im = Image.new("RGB", (8, 8), "#1688ff").resize((100, 100), Image.BOX) + im = Image.new("RGB", (8, 8), "#1688ff").resize( + (100, 100), Image.Resampling.BOX + ) ref = Image.new("RGB", (100, 100), "#1688ff") assert_image_equal(im, ref) @@ -229,7 +232,7 @@ def test_box_filter_correct_range(self): class TestCoreResampleConsistency: def make_case(self, mode, fill): im = Image.new(mode, (512, 9), fill) - return im.resize((9, 512), Image.LANCZOS), im.load()[0, 0] + return im.resize((9, 512), Image.Resampling.LANCZOS), im.load()[0, 0] def run_case(self, case): channel, color = case @@ -284,20 +287,20 @@ def run_levels_case(self, i): @pytest.mark.xfail(reason="Current implementation isn't precise enough") def test_levels_rgba(self): case = self.make_levels_case("RGBA") - self.run_levels_case(case.resize((512, 32), Image.BOX)) - self.run_levels_case(case.resize((512, 32), Image.BILINEAR)) - self.run_levels_case(case.resize((512, 32), Image.HAMMING)) - self.run_levels_case(case.resize((512, 32), Image.BICUBIC)) - self.run_levels_case(case.resize((512, 32), Image.LANCZOS)) + self.run_levels_case(case.resize((512, 32), Image.Resampling.BOX)) + self.run_levels_case(case.resize((512, 32), Image.Resampling.BILINEAR)) + self.run_levels_case(case.resize((512, 32), Image.Resampling.HAMMING)) + self.run_levels_case(case.resize((512, 32), Image.Resampling.BICUBIC)) + self.run_levels_case(case.resize((512, 32), Image.Resampling.LANCZOS)) @pytest.mark.xfail(reason="Current implementation isn't precise enough") def test_levels_la(self): case = self.make_levels_case("LA") - self.run_levels_case(case.resize((512, 32), Image.BOX)) - self.run_levels_case(case.resize((512, 32), Image.BILINEAR)) - self.run_levels_case(case.resize((512, 32), Image.HAMMING)) - self.run_levels_case(case.resize((512, 32), Image.BICUBIC)) - self.run_levels_case(case.resize((512, 32), Image.LANCZOS)) + self.run_levels_case(case.resize((512, 32), Image.Resampling.BOX)) + self.run_levels_case(case.resize((512, 32), Image.Resampling.BILINEAR)) + self.run_levels_case(case.resize((512, 32), Image.Resampling.HAMMING)) + self.run_levels_case(case.resize((512, 32), Image.Resampling.BICUBIC)) + self.run_levels_case(case.resize((512, 32), Image.Resampling.LANCZOS)) def make_dirty_case(self, mode, clean_pixel, dirty_pixel): i = Image.new(mode, (64, 64), dirty_pixel) @@ -322,19 +325,27 @@ def run_dirty_case(self, i, clean_pixel): def test_dirty_pixels_rgba(self): case = self.make_dirty_case("RGBA", (255, 255, 0, 128), (0, 0, 255, 0)) - self.run_dirty_case(case.resize((20, 20), Image.BOX), (255, 255, 0)) - self.run_dirty_case(case.resize((20, 20), Image.BILINEAR), (255, 255, 0)) - self.run_dirty_case(case.resize((20, 20), Image.HAMMING), (255, 255, 0)) - self.run_dirty_case(case.resize((20, 20), Image.BICUBIC), (255, 255, 0)) - self.run_dirty_case(case.resize((20, 20), Image.LANCZOS), (255, 255, 0)) + self.run_dirty_case(case.resize((20, 20), Image.Resampling.BOX), (255, 255, 0)) + self.run_dirty_case( + case.resize((20, 20), Image.Resampling.BILINEAR), (255, 255, 0) + ) + self.run_dirty_case( + case.resize((20, 20), Image.Resampling.HAMMING), (255, 255, 0) + ) + self.run_dirty_case( + case.resize((20, 20), Image.Resampling.BICUBIC), (255, 255, 0) + ) + self.run_dirty_case( + case.resize((20, 20), Image.Resampling.LANCZOS), (255, 255, 0) + ) def test_dirty_pixels_la(self): case = self.make_dirty_case("LA", (255, 128), (0, 0)) - self.run_dirty_case(case.resize((20, 20), Image.BOX), (255,)) - self.run_dirty_case(case.resize((20, 20), Image.BILINEAR), (255,)) - self.run_dirty_case(case.resize((20, 20), Image.HAMMING), (255,)) - self.run_dirty_case(case.resize((20, 20), Image.BICUBIC), (255,)) - self.run_dirty_case(case.resize((20, 20), Image.LANCZOS), (255,)) + self.run_dirty_case(case.resize((20, 20), Image.Resampling.BOX), (255,)) + self.run_dirty_case(case.resize((20, 20), Image.Resampling.BILINEAR), (255,)) + self.run_dirty_case(case.resize((20, 20), Image.Resampling.HAMMING), (255,)) + self.run_dirty_case(case.resize((20, 20), Image.Resampling.BICUBIC), (255,)) + self.run_dirty_case(case.resize((20, 20), Image.Resampling.LANCZOS), (255,)) class TestCoreResamplePasses: @@ -347,26 +358,26 @@ def count(self, diff): def test_horizontal(self): im = hopper("L") with self.count(1): - im.resize((im.size[0] - 10, im.size[1]), Image.BILINEAR) + im.resize((im.size[0] - 10, im.size[1]), Image.Resampling.BILINEAR) def test_vertical(self): im = hopper("L") with self.count(1): - im.resize((im.size[0], im.size[1] - 10), Image.BILINEAR) + im.resize((im.size[0], im.size[1] - 10), Image.Resampling.BILINEAR) def test_both(self): im = hopper("L") with self.count(2): - im.resize((im.size[0] - 10, im.size[1] - 10), Image.BILINEAR) + im.resize((im.size[0] - 10, im.size[1] - 10), Image.Resampling.BILINEAR) def test_box_horizontal(self): im = hopper("L") box = (20, 0, im.size[0] - 20, im.size[1]) with self.count(1): # the same size, but different box - with_box = im.resize(im.size, Image.BILINEAR, box) + with_box = im.resize(im.size, Image.Resampling.BILINEAR, box) with self.count(2): - cropped = im.crop(box).resize(im.size, Image.BILINEAR) + cropped = im.crop(box).resize(im.size, Image.Resampling.BILINEAR) assert_image_similar(with_box, cropped, 0.1) def test_box_vertical(self): @@ -374,9 +385,9 @@ def test_box_vertical(self): box = (0, 20, im.size[0], im.size[1] - 20) with self.count(1): # the same size, but different box - with_box = im.resize(im.size, Image.BILINEAR, box) + with_box = im.resize(im.size, Image.Resampling.BILINEAR, box) with self.count(2): - cropped = im.crop(box).resize(im.size, Image.BILINEAR) + cropped = im.crop(box).resize(im.size, Image.Resampling.BILINEAR) assert_image_similar(with_box, cropped, 0.1) @@ -389,7 +400,7 @@ def test_reduce(self): draw = ImageDraw.Draw(i) draw.rectangle((0, 0, i.size[0] // 2 - 1, 0), test_color) - px = i.resize((5, i.size[1]), Image.BICUBIC).load() + px = i.resize((5, i.size[1]), Image.Resampling.BICUBIC).load() if px[2, 0] != test_color // 2: assert test_color // 2 == px[2, 0] @@ -397,7 +408,7 @@ def test_nonzero_coefficients(self): # regression test for the wrong coefficients calculation # due to bug https://github.com/python-pillow/Pillow/issues/2161 im = Image.new("RGBA", (1280, 1280), (0x20, 0x40, 0x60, 0xFF)) - histogram = im.resize((256, 256), Image.BICUBIC).histogram() + histogram = im.resize((256, 256), Image.Resampling.BICUBIC).histogram() # first channel assert histogram[0x100 * 0 + 0x20] == 0x10000 @@ -410,46 +421,49 @@ def test_nonzero_coefficients(self): class TestCoreResampleBox: - def test_wrong_arguments(self): + @pytest.mark.parametrize( + "resample", + ( + Image.Resampling.NEAREST, + Image.Resampling.BOX, + Image.Resampling.BILINEAR, + Image.Resampling.HAMMING, + Image.Resampling.BICUBIC, + Image.Resampling.LANCZOS, + ), + ) + def test_wrong_arguments(self, resample): im = hopper() - for resample in ( - Image.NEAREST, - Image.BOX, - Image.BILINEAR, - Image.HAMMING, - Image.BICUBIC, - Image.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)) - - 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 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)) + 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(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 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): scale = size / tiles for i in range(tiles): - yield (int(round(scale * i)), int(round(scale * (i + 1)))) + yield int(round(scale * i)), int(round(scale * (i + 1))) tiled = Image.new(im.mode, dst_size) scale = (im.size[0] / tiled.size[0], im.size[1] / tiled.size[1]) @@ -457,7 +471,7 @@ def split_range(size, tiles): for y0, y1 in split_range(dst_size[1], ytiles): for x0, x1 in split_range(dst_size[0], xtiles): box = (x0 * scale[0], y0 * scale[1], x1 * scale[0], y1 * scale[1]) - tile = im.resize((x1 - x0, y1 - y0), Image.BICUBIC, box) + tile = im.resize((x1 - x0, y1 - y0), Image.Resampling.BICUBIC, box) tiled.paste(tile, (x0, y0)) return tiled @@ -468,7 +482,7 @@ def test_tiles(self): with Image.open("Tests/images/flower.jpg") as im: assert im.size == (480, 360) dst_size = (251, 188) - reference = im.resize(dst_size, Image.BICUBIC) + reference = im.resize(dst_size, Image.Resampling.BICUBIC) for tiles in [(1, 1), (3, 3), (9, 7), (100, 100)]: tiled = self.resize_tiled(im, dst_size, *tiles) @@ -484,26 +498,32 @@ def test_subsample(self): assert im.size == (480, 360) dst_size = (48, 36) # Reference is cropped image resized to destination - reference = im.crop((0, 0, 473, 353)).resize(dst_size, Image.BICUBIC) - # Image.BOX emulates supersampling (480 / 8 = 60, 360 / 8 = 45) - supersampled = im.resize((60, 45), Image.BOX) + reference = im.crop((0, 0, 473, 353)).resize( + dst_size, Image.Resampling.BICUBIC + ) + # Image.Resampling.BOX emulates supersampling (480 / 8 = 60, 360 / 8 = 45) + supersampled = im.resize((60, 45), Image.Resampling.BOX) - with_box = supersampled.resize(dst_size, Image.BICUBIC, (0, 0, 59.125, 44.125)) - without_box = supersampled.resize(dst_size, Image.BICUBIC) + with_box = supersampled.resize( + dst_size, Image.Resampling.BICUBIC, (0, 0, 59.125, 44.125) + ) + without_box = supersampled.resize(dst_size, Image.Resampling.BICUBIC) # error with box should be much smaller than without assert_image_similar(reference, with_box, 6) with pytest.raises(AssertionError, match=r"difference 29\."): assert_image_similar(reference, without_box, 5) - def test_formats(self): - for resample in [Image.NEAREST, Image.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 @@ -515,7 +535,7 @@ def test_passthrough(self): ((40, 50), (10, 0, 50, 50)), ((40, 50), (10, 20, 50, 70)), ]: - res = im.resize(size, Image.LANCZOS, box) + res = im.resize(size, Image.Resampling.LANCZOS, box) assert res.size == size assert_image_equal(res, im.crop(box), f">>> {size} {box}") @@ -529,50 +549,54 @@ def test_no_passthrough(self): ((40, 50), (10.4, 0.4, 50.4, 50.4)), ((40, 50), (10.4, 20.4, 50.4, 70.4)), ]: - res = im.resize(size, Image.LANCZOS, box) + res = im.resize(size, Image.Resampling.LANCZOS, box) assert res.size == size with pytest.raises(AssertionError, match=r"difference \d"): # check that the difference at least that much assert_image_similar(res, im.crop(box), 20, f">>> {size} {box}") - def test_skip_horizontal(self): + @pytest.mark.parametrize( + "flt", (Image.Resampling.NEAREST, Image.Resampling.BICUBIC) + ) + def test_skip_horizontal(self, flt): # Can skip resize for one dimension im = hopper() - for flt in [Image.NEAREST, Image.BICUBIC]: - for size, box in [ - ((40, 50), (0, 0, 40, 90)), - ((40, 50), (0, 20, 40, 90)), - ((40, 50), (10, 0, 50, 90)), - ((40, 50), (10, 20, 50, 90)), - ]: - res = im.resize(size, flt, box) - assert res.size == size - # Borders should be slightly different - assert_image_similar( - res, - im.crop(box).resize(size, flt), - 0.4, - f">>> {size} {box} {flt}", - ) - - def test_skip_vertical(self): + for size, box in [ + ((40, 50), (0, 0, 40, 90)), + ((40, 50), (0, 20, 40, 90)), + ((40, 50), (10, 0, 50, 90)), + ((40, 50), (10, 20, 50, 90)), + ]: + res = im.resize(size, flt, box) + assert res.size == size + # Borders should be slightly different + assert_image_similar( + res, + im.crop(box).resize(size, flt), + 0.4, + f">>> {size} {box} {flt}", + ) + + @pytest.mark.parametrize( + "flt", (Image.Resampling.NEAREST, Image.Resampling.BICUBIC) + ) + def test_skip_vertical(self, flt): # Can skip resize for one dimension im = hopper() - for flt in [Image.NEAREST, Image.BICUBIC]: - for size, box in [ - ((40, 50), (0, 0, 90, 50)), - ((40, 50), (20, 0, 90, 50)), - ((40, 50), (0, 10, 90, 60)), - ((40, 50), (20, 10, 90, 60)), - ]: - res = im.resize(size, flt, box) - assert res.size == size - # Borders should be slightly different - assert_image_similar( - res, - im.crop(box).resize(size, flt), - 0.4, - f">>> {size} {box} {flt}", - ) + for size, box in [ + ((40, 50), (0, 0, 90, 50)), + ((40, 50), (20, 0, 90, 50)), + ((40, 50), (0, 10, 90, 60)), + ((40, 50), (20, 10, 90, 60)), + ]: + res = im.resize(size, flt, box) + assert res.size == size + # Borders should be slightly different + assert_image_similar( + res, + im.crop(box).resize(size, flt), + 0.4, + f">>> {size} {box} {flt}", + ) diff --git a/Tests/test_image_resize.py b/Tests/test_image_resize.py index 1fe278052fa..83c54cf6211 100644 --- a/Tests/test_image_resize.py +++ b/Tests/test_image_resize.py @@ -12,6 +12,7 @@ assert_image_equal_tofile, assert_image_similar, hopper, + skip_unless_feature, ) @@ -21,66 +22,82 @@ def resize(self, im, size, f): 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.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): - self.resize(hopper("1"), (15, 12), Image.BILINEAR) + self.resize(hopper("1"), (15, 12), Image.Resampling.BILINEAR) with pytest.raises(ValueError): - self.resize(hopper("P"), (15, 12), Image.BILINEAR) + self.resize(hopper("P"), (15, 12), Image.Resampling.BILINEAR) with pytest.raises(ValueError): - self.resize(hopper("I;16"), (15, 12), Image.BILINEAR) + self.resize(hopper("I;16"), (15, 12), Image.Resampling.BILINEAR) for mode in ["L", "I", "F", "RGB", "RGBA", "CMYK", "YCbCr"]: im = hopper(mode) - r = self.resize(im, (15, 12), Image.BILINEAR) + r = self.resize(im, (15, 12), Image.Resampling.BILINEAR) assert r.mode == mode assert r.size == (15, 12) assert r.im.bands == im.im.bands - def test_reduce_filters(self): - for f in [ - Image.NEAREST, - Image.BOX, - Image.BILINEAR, - Image.HAMMING, - Image.BICUBIC, - Image.LANCZOS, - ]: - r = self.resize(hopper("RGB"), (15, 12), f) - assert r.mode == "RGB" - assert r.size == (15, 12) - - def test_enlarge_filters(self): - for f in [ - Image.NEAREST, - Image.BOX, - Image.BILINEAR, - Image.HAMMING, - Image.BICUBIC, - Image.LANCZOS, - ]: - r = self.resize(hopper("RGB"), (212, 195), f) - 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, + ), + ) + def test_reduce_filters(self, resample): + r = self.resize(hopper("RGB"), (15, 12), resample) + assert r.mode == "RGB" + assert r.size == (15, 12) + + @pytest.mark.parametrize( + "resample", + ( + Image.Resampling.NEAREST, + Image.Resampling.BOX, + Image.Resampling.BILINEAR, + Image.Resampling.HAMMING, + Image.Resampling.BICUBIC, + Image.Resampling.LANCZOS, + ), + ) + def test_enlarge_filters(self, resample): + r = self.resize(hopper("RGB"), (212, 195), resample) + assert r.mode == "RGB" + assert r.size == (212, 195) + + @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. @@ -94,47 +111,37 @@ def test_endianness(self): } samples["dirty"].putpixel((1, 1), 128) - for f in [ - Image.NEAREST, - Image.BOX, - Image.BILINEAR, - Image.HAMMING, - Image.BICUBIC, - Image.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.NEAREST, - Image.BOX, - Image.BILINEAR, - Image.HAMMING, - Image.BICUBIC, - Image.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) + # 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, + ), + ) + 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): @@ -164,82 +171,85 @@ def gradients_image(): class TestReducingGapResize: def test_reducing_gap_values(self, gradients_image): - ref = gradients_image.resize((52, 34), Image.BICUBIC, reducing_gap=None) - im = gradients_image.resize((52, 34), Image.BICUBIC) + ref = gradients_image.resize( + (52, 34), Image.Resampling.BICUBIC, reducing_gap=None + ) + im = gradients_image.resize((52, 34), Image.Resampling.BICUBIC) assert_image_equal(ref, im) with pytest.raises(ValueError): - gradients_image.resize((52, 34), Image.BICUBIC, reducing_gap=0) + gradients_image.resize((52, 34), Image.Resampling.BICUBIC, reducing_gap=0) with pytest.raises(ValueError): - gradients_image.resize((52, 34), Image.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.BICUBIC, box=box) - im = gradients_image.resize( - (52, 34), Image.BICUBIC, box=box, reducing_gap=1.0 + gradients_image.resize( + (52, 34), Image.Resampling.BICUBIC, reducing_gap=0.99 ) - with pytest.raises(AssertionError): - assert_image_equal(ref, im) + @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) - assert_image_similar(ref, im, epsilon) + 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.BICUBIC, box=box) - im = gradients_image.resize( - (52, 34), Image.BICUBIC, box=box, reducing_gap=2.0 - ) + @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) + with pytest.raises(AssertionError): + assert_image_equal(ref, im) - assert_image_similar(ref, im, epsilon) + 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.BICUBIC, box=box) - im = gradients_image.resize( - (52, 34), Image.BICUBIC, box=box, reducing_gap=3.0 - ) + @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) + with pytest.raises(AssertionError): + assert_image_equal(ref, im) - assert_image_similar(ref, im, epsilon) + 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.BICUBIC, box=box) - im = gradients_image.resize( - (52, 34), Image.BICUBIC, box=box, reducing_gap=8.0 - ) + @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) + 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.BOX, box=box) - im = gradients_image.resize((52, 34), Image.BOX, box=box, reducing_gap=1.0) + @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) + assert_image_similar(ref, im, epsilon) class TestImageResize: @@ -258,15 +268,22 @@ def resize(mode, size): with pytest.raises(ValueError): im.resize((10, 10), "unknown") - def test_default_filter(self): - for mode in "L", "RGB", "I", "F": - im = hopper(mode) - assert im.resize((20, 20), Image.BICUBIC) == im.resize((20, 20)) - - for mode in "1", "P": - im = hopper(mode) - assert im.resize((20, 20), Image.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.NEAREST) == im.resize((20, 20)) + @skip_unless_feature("libtiff") + def test_load_first(self): + # load() may change the size of the image + # Test that resize() is calling it before getting the size + with Image.open("Tests/images/g4_orientation_5.tif") as im: + im = im.resize((64, 64)) + assert im.size == (64, 64) + + @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)) + + @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 2d72ffa684c..a19f19831fd 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,38 +24,38 @@ 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) +@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)) + 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)) - rotate(im, im.mode, angle) +@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. # >>> im = Image.open('Tests/images/hopper.ppm') - # >>> im = im.rotate(45, resample=Image.BICUBIC, expand=True) + # >>> im = im.rotate(45, resample=Image.Resampling.BICUBIC, expand=True) # >>> im.save('Tests/images/hopper_45.png') with Image.open("Tests/images/hopper_45.png") as target: for (resample, epsilon) in ( - (Image.NEAREST, 10), - (Image.BILINEAR, 5), - (Image.BICUBIC, 0), + (Image.Resampling.NEAREST, 10), + (Image.Resampling.BILINEAR, 5), + (Image.Resampling.BICUBIC, 0), ): im = hopper() im = im.rotate(45, resample=resample, expand=True) @@ -62,7 +64,7 @@ def test_resample(): def test_center_0(): im = hopper() - im = im.rotate(45, center=(0, 0), resample=Image.BICUBIC) + im = im.rotate(45, center=(0, 0), resample=Image.Resampling.BICUBIC) with Image.open("Tests/images/hopper_45.png") as target: target_origin = target.size[1] / 2 @@ -73,7 +75,7 @@ def test_center_0(): def test_center_14(): im = hopper() - im = im.rotate(45, center=(14, 14), resample=Image.BICUBIC) + im = im.rotate(45, center=(14, 14), resample=Image.Resampling.BICUBIC) with Image.open("Tests/images/hopper_45.png") as target: target_origin = target.size[1] / 2 - 14 @@ -90,7 +92,7 @@ def test_translate(): (target_origin, target_origin, target_origin + 128, target_origin + 128) ) - im = im.rotate(45, translate=(5, 5), resample=Image.BICUBIC) + im = im.rotate(45, translate=(5, 5), resample=Image.Resampling.BICUBIC) assert_image_similar(im, target, 1) diff --git a/Tests/test_image_split.py b/Tests/test_image_split.py index fbed276b8b7..5cb7c9a8be8 100644 --- a/Tests/test_image_split.py +++ b/Tests/test_image_split.py @@ -1,3 +1,5 @@ +import pytest + from PIL import Image, features from .helper import assert_image_equal, hopper @@ -29,19 +31,12 @@ def split(mode): assert split("YCbCr") == [("L", 128, 128), ("L", 128, 128), ("L", 128, 128)] -def test_split_merge(): - def split_merge(mode): - return Image.merge(mode, hopper(mode).split()) - - assert_image_equal(hopper("1"), split_merge("1")) - assert_image_equal(hopper("L"), split_merge("L")) - assert_image_equal(hopper("I"), split_merge("I")) - assert_image_equal(hopper("F"), split_merge("F")) - assert_image_equal(hopper("P"), split_merge("P")) - assert_image_equal(hopper("RGB"), split_merge("RGB")) - assert_image_equal(hopper("RGBA"), split_merge("RGBA")) - assert_image_equal(hopper("CMYK"), split_merge("CMYK")) - assert_image_equal(hopper("YCbCr"), split_merge("YCbCr")) +@pytest.mark.parametrize( + "mode", ("1", "L", "I", "F", "P", "RGB", "RGBA", "CMYK", "YCbCr") +) +def test_split_merge(mode): + expected = Image.merge(mode, hopper(mode).split()) + assert_image_equal(hopper(mode), expected) def test_split_open(tmp_path): diff --git a/Tests/test_image_thumbnail.py b/Tests/test_image_thumbnail.py index dd140955dee..4fd07a2b4d2 100644 --- a/Tests/test_image_thumbnail.py +++ b/Tests/test_image_thumbnail.py @@ -7,6 +7,7 @@ assert_image_similar, fromstring, hopper, + skip_unless_feature, tostring, ) @@ -88,6 +89,37 @@ def test_no_resize(): assert im.size == (64, 64) +@skip_unless_feature("libtiff") +def test_load_first(): + # load() may change the size of the image + # Test that thumbnail() is calling it before performing size calculations + with Image.open("Tests/images/g4_orientation_5.tif") as im: + im.thumbnail((64, 64)) + assert im.size == (64, 10) + + # Test thumbnail(), without draft(), + # on an image that is large enough once load() has changed the size + with Image.open("Tests/images/g4_orientation_5.tif") as im: + im.thumbnail((590, 88), reducing_gap=None) + assert im.size == (590, 88) + + +def test_load_first_unless_jpeg(): + # Test that thumbnail() still uses draft() for JPEG + with Image.open("Tests/images/hopper.jpg") as im: + draft = im.draft + + def im_draft(mode, size): + result = draft(mode, size) + assert result is not None + + return result + + im.draft = im_draft + + im.thumbnail((64, 64)) + + # valgrind test is failing with memory allocated in libjpeg @pytest.mark.valgrind_known_error(reason="Known Failing") def test_DCT_scaling_edges(): @@ -97,24 +129,24 @@ def test_DCT_scaling_edges(): thumb = fromstring(tostring(im, "JPEG", quality=99, subsampling=0)) # small reducing_gap to amplify the effect - thumb.thumbnail((32, 32), Image.BICUBIC, reducing_gap=1.0) + thumb.thumbnail((32, 32), Image.Resampling.BICUBIC, reducing_gap=1.0) - ref = im.resize((32, 32), Image.BICUBIC) + ref = im.resize((32, 32), Image.Resampling.BICUBIC) # This is still JPEG, some error is present. Without the fix it is 11.5 assert_image_similar(thumb, ref, 1.5) def test_reducing_gap_values(): im = hopper() - im.thumbnail((18, 18), Image.BICUBIC) + im.thumbnail((18, 18), Image.Resampling.BICUBIC) ref = hopper() - ref.thumbnail((18, 18), Image.BICUBIC, reducing_gap=2.0) + ref.thumbnail((18, 18), Image.Resampling.BICUBIC, reducing_gap=2.0) # reducing_gap=2.0 should be the default assert_image_equal(ref, im) ref = hopper() - ref.thumbnail((18, 18), Image.BICUBIC, reducing_gap=None) + ref.thumbnail((18, 18), Image.Resampling.BICUBIC, reducing_gap=None) with pytest.raises(AssertionError): assert_image_equal(ref, im) @@ -125,9 +157,9 @@ def test_reducing_gap_for_DCT_scaling(): with Image.open("Tests/images/hopper.jpg") as ref: # thumbnail should call draft with reducing_gap scale ref.draft(None, (18 * 3, 18 * 3)) - ref = ref.resize((18, 18), Image.BICUBIC) + ref = ref.resize((18, 18), Image.Resampling.BICUBIC) with Image.open("Tests/images/hopper.jpg") as im: - im.thumbnail((18, 18), Image.BICUBIC, reducing_gap=3.0) + im.thumbnail((18, 18), Image.Resampling.BICUBIC, reducing_gap=3.0) - assert_image_equal(ref, im) + assert_image_similar(ref, im, 1.4) diff --git a/Tests/test_image_transform.py b/Tests/test_image_transform.py index ea208362b2a..a78349801fc 100644 --- a/Tests/test_image_transform.py +++ b/Tests/test_image_transform.py @@ -34,20 +34,22 @@ def test_info(self): def test_palette(self): with Image.open("Tests/images/hopper.gif") as im: - transformed = im.transform(im.size, Image.AFFINE, [1, 0, 0, 0, 1, 0]) + transformed = im.transform( + im.size, Image.Transform.AFFINE, [1, 0, 0, 0, 1, 0] + ) assert im.palette.palette == transformed.palette.palette def test_extent(self): im = hopper("RGB") (w, h) = im.size # fmt: off - transformed = im.transform(im.size, Image.EXTENT, + transformed = im.transform(im.size, Image.Transform.EXTENT, (0, 0, w//2, h//2), # ul -> lr - Image.BILINEAR) + Image.Resampling.BILINEAR) # fmt: on - scaled = im.resize((w * 2, h * 2), Image.BILINEAR).crop((0, 0, w, h)) + scaled = im.resize((w * 2, h * 2), Image.Resampling.BILINEAR).crop((0, 0, w, h)) # undone -- precision? assert_image_similar(transformed, scaled, 23) @@ -57,54 +59,62 @@ def test_quad(self): im = hopper("RGB") (w, h) = im.size # fmt: off - transformed = im.transform(im.size, Image.QUAD, + transformed = im.transform(im.size, Image.Transform.QUAD, (0, 0, 0, h//2, # ul -> ccw around quad: w//2, h//2, w//2, 0), - Image.BILINEAR) + Image.Resampling.BILINEAR) # fmt: on scaled = im.transform( - (w, h), Image.AFFINE, (0.5, 0, 0, 0, 0.5, 0), Image.BILINEAR + (w, h), + Image.Transform.AFFINE, + (0.5, 0, 0, 0, 0.5, 0), + Image.Resampling.BILINEAR, ) assert_image_equal(transformed, scaled) - def test_fill(self): - for mode, pixel in [ - ["RGB", (255, 0, 0)], - ["RGBA", (255, 0, 0, 255)], - ["LA", (76, 0)], - ]: - im = hopper(mode) - (w, h) = im.size - transformed = im.transform( - im.size, - Image.EXTENT, - (0, 0, w * 2, h * 2), - Image.BILINEAR, - fillcolor="red", - ) - - assert transformed.getpixel((w - 1, h - 1)) == pixel + @pytest.mark.parametrize( + "mode, expected_pixel", + ( + ("RGB", (255, 0, 0)), + ("RGBA", (255, 0, 0, 255)), + ("LA", (76, 0)), + ), + ) + def test_fill(self, mode, expected_pixel): + im = hopper(mode) + (w, h) = im.size + transformed = im.transform( + im.size, + Image.Transform.EXTENT, + (0, 0, w * 2, h * 2), + Image.Resampling.BILINEAR, + fillcolor="red", + ) + assert transformed.getpixel((w - 1, h - 1)) == expected_pixel def test_mesh(self): # this should be a checkerboard of halfsized hoppers in ul, lr im = hopper("RGBA") (w, h) = im.size # fmt: off - transformed = im.transform(im.size, Image.MESH, + transformed = im.transform(im.size, Image.Transform.MESH, [((0, 0, w//2, h//2), # box (0, 0, 0, h, w, h, w, 0)), # ul -> ccw around quad ((w//2, h//2, w, h), # box (0, 0, 0, h, w, h, w, 0))], # ul -> ccw around quad - Image.BILINEAR) + Image.Resampling.BILINEAR) # fmt: on scaled = im.transform( - (w // 2, h // 2), Image.AFFINE, (2, 0, 0, 0, 2, 0), Image.BILINEAR + (w // 2, h // 2), + Image.Transform.AFFINE, + (2, 0, 0, 0, 2, 0), + Image.Resampling.BILINEAR, ) checker = Image.new("RGBA", im.size) @@ -137,14 +147,16 @@ def _test_alpha_premult(self, op): def test_alpha_premult_resize(self): def op(im, sz): - return im.resize(sz, Image.BILINEAR) + return im.resize(sz, Image.Resampling.BILINEAR) self._test_alpha_premult(op) def test_alpha_premult_transform(self): def op(im, sz): (w, h) = im.size - return im.transform(sz, Image.EXTENT, (0, 0, w, h), Image.BILINEAR) + return im.transform( + sz, Image.Transform.EXTENT, (0, 0, w, h), Image.Resampling.BILINEAR + ) self._test_alpha_premult(op) @@ -171,7 +183,7 @@ def _test_nearest(self, op, mode): @pytest.mark.parametrize("mode", ("RGBA", "LA")) def test_nearest_resize(self, mode): def op(im, sz): - return im.resize(sz, Image.NEAREST) + return im.resize(sz, Image.Resampling.NEAREST) self._test_nearest(op, mode) @@ -179,7 +191,9 @@ def op(im, sz): def test_nearest_transform(self, mode): def op(im, sz): (w, h) = im.size - return im.transform(sz, Image.EXTENT, (0, 0, w, h), Image.NEAREST) + return im.transform( + sz, Image.Transform.EXTENT, (0, 0, w, h), Image.Resampling.NEAREST + ) self._test_nearest(op, mode) @@ -210,22 +224,31 @@ def test_missing_method_data(self): with pytest.raises(ValueError): im.transform((100, 100), None) - def test_unknown_resampling_filter(self): + @pytest.mark.parametrize("resample", (Image.Resampling.BOX, "unknown")) + def test_unknown_resampling_filter(self, resample): with hopper() as im: (w, h) = im.size - for resample in (Image.BOX, "unknown"): - with pytest.raises(ValueError): - im.transform((100, 100), Image.EXTENT, (0, 0, w, h), resample) + with pytest.raises(ValueError): + im.transform((100, 100), Image.Transform.EXTENT, (0, 0, w, h), resample) class TestImageTransformAffine: - transform = Image.AFFINE + transform = Image.Transform.AFFINE def _test_image(self): im = hopper("RGB") return im.crop((10, 20, im.width - 10, im.height - 20)) - def _test_rotate(self, deg, transpose): + @pytest.mark.parametrize( + "deg, transpose", + ( + (0, None), + (90, Image.Transpose.ROTATE_90), + (180, Image.Transpose.ROTATE_180), + (270, Image.Transpose.ROTATE_270), + ), + ) + def test_rotate(self, deg, transpose): im = self._test_image() angle = -math.radians(deg) @@ -247,85 +270,77 @@ def _test_rotate(self, deg, transpose): else: transposed = im - for resample in [Image.NEAREST, Image.BILINEAR, Image.BICUBIC]: + for resample in [ + Image.Resampling.NEAREST, + Image.Resampling.BILINEAR, + Image.Resampling.BICUBIC, + ]: transformed = im.transform( transposed.size, self.transform, matrix, resample ) assert_image_equal(transposed, transformed) - def test_rotate_0_deg(self): - self._test_rotate(0, None) - - def test_rotate_90_deg(self): - self._test_rotate(90, Image.ROTATE_90) - - def test_rotate_180_deg(self): - self._test_rotate(180, Image.ROTATE_180) - - def test_rotate_270_deg(self): - self._test_rotate(270, Image.ROTATE_270) - - def _test_resize(self, scale, epsilonscale): + @pytest.mark.parametrize( + "scale, epsilon_scale", + ( + (1.1, 6.9), + (1.5, 5.5), + (2.0, 5.5), + (2.3, 3.7), + (2.5, 3.7), + ), + ) + @pytest.mark.parametrize( + "resample,epsilon", + ( + (Image.Resampling.NEAREST, 0), + (Image.Resampling.BILINEAR, 2), + (Image.Resampling.BICUBIC, 1), + ), + ) + def test_resize(self, scale, epsilon_scale, resample, epsilon): im = self._test_image() size_up = int(round(im.width * scale)), int(round(im.height * scale)) matrix_up = [1 / scale, 0, 0, 0, 1 / scale, 0, 0, 0] matrix_down = [scale, 0, 0, 0, scale, 0, 0, 0] - for resample, epsilon in [ - (Image.NEAREST, 0), - (Image.BILINEAR, 2), - (Image.BICUBIC, 1), - ]: - transformed = im.transform(size_up, self.transform, matrix_up, resample) - transformed = transformed.transform( - im.size, self.transform, matrix_down, resample - ) - assert_image_similar(transformed, im, epsilon * epsilonscale) - - def test_resize_1_1x(self): - self._test_resize(1.1, 6.9) - - def test_resize_1_5x(self): - self._test_resize(1.5, 5.5) - - def test_resize_2_0x(self): - self._test_resize(2.0, 5.5) - - def test_resize_2_3x(self): - self._test_resize(2.3, 3.7) - - def test_resize_2_5x(self): - self._test_resize(2.5, 3.7) - - def _test_translate(self, x, y, epsilonscale): + transformed = im.transform(size_up, self.transform, matrix_up, resample) + transformed = transformed.transform( + im.size, self.transform, matrix_down, resample + ) + assert_image_similar(transformed, im, epsilon * epsilon_scale) + + @pytest.mark.parametrize( + "x, y, epsilon_scale", + ( + (0.1, 0, 3.7), + (0.6, 0, 9.1), + (50, 50, 0), + ), + ) + @pytest.mark.parametrize( + "resample, epsilon", + ( + (Image.Resampling.NEAREST, 0), + (Image.Resampling.BILINEAR, 1.5), + (Image.Resampling.BICUBIC, 1), + ), + ) + def test_translate(self, x, y, epsilon_scale, resample, epsilon): im = self._test_image() size_up = int(round(im.width + x)), int(round(im.height + y)) matrix_up = [1, 0, -x, 0, 1, -y, 0, 0] matrix_down = [1, 0, x, 0, 1, y, 0, 0] - for resample, epsilon in [ - (Image.NEAREST, 0), - (Image.BILINEAR, 1.5), - (Image.BICUBIC, 1), - ]: - transformed = im.transform(size_up, self.transform, matrix_up, resample) - transformed = transformed.transform( - im.size, self.transform, matrix_down, resample - ) - assert_image_similar(transformed, im, epsilon * epsilonscale) - - def test_translate_0_1(self): - self._test_translate(0.1, 0, 3.7) - - def test_translate_0_6(self): - self._test_translate(0.6, 0, 9.1) - - def test_translate_50(self): - self._test_translate(50, 50, 0) + transformed = im.transform(size_up, self.transform, matrix_up, resample) + transformed = transformed.transform( + im.size, self.transform, matrix_down, resample + ) + assert_image_similar(transformed, im, epsilon * epsilon_scale) class TestImageTransformPerspective(TestImageTransformAffine): # Repeat all tests for AFFINE transformations with PERSPECTIVE - transform = Image.PERSPECTIVE + transform = Image.Transform.PERSPECTIVE diff --git a/Tests/test_image_transpose.py b/Tests/test_image_transpose.py index a004434dae7..877f439ca26 100644 --- a/Tests/test_image_transpose.py +++ b/Tests/test_image_transpose.py @@ -1,12 +1,6 @@ -from PIL.Image import ( - FLIP_LEFT_RIGHT, - FLIP_TOP_BOTTOM, - ROTATE_90, - ROTATE_180, - ROTATE_270, - TRANSPOSE, - TRANSVERSE, -) +import pytest + +from PIL.Image import Transpose from . import helper from .helper import assert_image_equal @@ -17,146 +11,136 @@ } -def test_flip_left_right(): - def transpose(mode): - im = HOPPER[mode] - out = im.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) - - -def test_flip_top_bottom(): - def transpose(mode): - im = HOPPER[mode] - out = im.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) - - -def test_rotate_90(): - def transpose(mode): - im = HOPPER[mode] - out = im.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) - - -def test_rotate_180(): - def transpose(mode): - im = HOPPER[mode] - out = im.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) - - -def test_rotate_270(): - def transpose(mode): - im = HOPPER[mode] - out = im.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) - - -def test_transpose(): - def transpose(mode): - im = HOPPER[mode] - out = im.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) - - -def test_tranverse(): - def transpose(mode): - im = HOPPER[mode] - out = im.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) - - -def test_roundtrip(): - for mode in HOPPER: - im = HOPPER[mode] - - def transpose(first, second): - return im.transpose(first).transpose(second) - - assert_image_equal(im, transpose(FLIP_LEFT_RIGHT, FLIP_LEFT_RIGHT)) - assert_image_equal(im, transpose(FLIP_TOP_BOTTOM, FLIP_TOP_BOTTOM)) - assert_image_equal(im, transpose(ROTATE_90, ROTATE_270)) - assert_image_equal(im, transpose(ROTATE_180, ROTATE_180)) - assert_image_equal( - im.transpose(TRANSPOSE), transpose(ROTATE_90, FLIP_TOP_BOTTOM) - ) - assert_image_equal( - im.transpose(TRANSPOSE), transpose(ROTATE_270, FLIP_LEFT_RIGHT) - ) - assert_image_equal( - im.transpose(TRANSVERSE), transpose(ROTATE_90, FLIP_LEFT_RIGHT) - ) - assert_image_equal( - im.transpose(TRANSVERSE), transpose(ROTATE_270, FLIP_TOP_BOTTOM) - ) - assert_image_equal(im.transpose(TRANSVERSE), transpose(ROTATE_180, TRANSPOSE)) +@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)) + + +@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)) + + +@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)) + + +@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)) + + +@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)) + + +@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)) + + +@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)) + + +@pytest.mark.parametrize("mode", HOPPER) +def test_roundtrip(mode): + im = HOPPER[mode] + + 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), + ) diff --git a/Tests/test_imagecms.py b/Tests/test_imagecms.py index 99f3b4e0329..3d8dbe6bbf5 100644 --- a/Tests/test_imagecms.py +++ b/Tests/test_imagecms.py @@ -140,7 +140,7 @@ def test_intent(): skip_missing() assert ImageCms.getDefaultIntent(SRGB) == 0 support = ImageCms.isIntentSupported( - SRGB, ImageCms.INTENT_ABSOLUTE_COLORIMETRIC, ImageCms.DIRECTION_INPUT + SRGB, ImageCms.Intent.ABSOLUTE_COLORIMETRIC, ImageCms.Direction.INPUT ) assert support == 1 @@ -153,7 +153,7 @@ def test_profile_object(): # ["sRGB built-in", "", "WhitePoint : D65 (daylight)", "", ""] assert ImageCms.getDefaultIntent(p) == 0 support = ImageCms.isIntentSupported( - p, ImageCms.INTENT_ABSOLUTE_COLORIMETRIC, ImageCms.DIRECTION_INPUT + p, ImageCms.Intent.ABSOLUTE_COLORIMETRIC, ImageCms.Direction.INPUT ) assert support == 1 @@ -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)) @@ -303,7 +325,7 @@ def test_extended_information(): def assert_truncated_tuple_equal(tup1, tup2, digits=10): # Helper function to reduce precision of tuples of floats # recursively and then check equality. - power = 10 ** digits + power = 10**digits def truncate_tuple(tuple_or_float): return tuple( @@ -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() @@ -593,3 +615,13 @@ def test_auxiliary_channels_isolated(): ) assert_image_equal(test_image.convert(dst_format[2]), reference_image) + + +def test_constants_deprecation(): + for enum, prefix in { + ImageCms.Intent: "INTENT_", + ImageCms.Direction: "DIRECTION_", + }.items(): + for name in enum.__members__: + with pytest.warns(DeprecationWarning): + assert getattr(ImageCms, prefix + name) == enum[name] diff --git a/Tests/test_imagedraw.py b/Tests/test_imagedraw.py index b661494c733..4c4c41b7b51 100644 --- a/Tests/test_imagedraw.py +++ b/Tests/test_imagedraw.py @@ -64,7 +64,9 @@ def test_mode_mismatch(): ImageDraw.ImageDraw(im, mode="L") -def helper_arc(bbox, start, end): +@pytest.mark.parametrize("bbox", (BBOX1, BBOX2)) +@pytest.mark.parametrize("start, end", ((0, 180), (0.5, 180.4))) +def test_arc(bbox, start, end): # Arrange im = Image.new("RGB", (W, H)) draw = ImageDraw.Draw(im) @@ -76,16 +78,6 @@ def helper_arc(bbox, start, end): assert_image_similar_tofile(im, "Tests/images/imagedraw_arc.png", 1) -def test_arc1(): - helper_arc(BBOX1, 0, 180) - helper_arc(BBOX1, 0.5, 180.4) - - -def test_arc2(): - helper_arc(BBOX2, 0, 180) - helper_arc(BBOX2, 0.5, 180.4) - - def test_arc_end_le_start(): # Arrange im = Image.new("RGB", (W, H)) @@ -183,7 +175,7 @@ def test_bitmap(): im = Image.new("RGB", (W, H)) draw = ImageDraw.Draw(im) with Image.open("Tests/images/pil123rgba.png") as small: - small = small.resize((50, 50), Image.NEAREST) + small = small.resize((50, 50), Image.Resampling.NEAREST) # Act draw.bitmap((10, 10), small) @@ -192,29 +184,21 @@ def test_bitmap(): assert_image_equal_tofile(im, "Tests/images/imagedraw_bitmap.png") -def helper_chord(mode, bbox, start, end): +@pytest.mark.parametrize("mode", ("RGB", "L")) +@pytest.mark.parametrize("bbox", (BBOX1, BBOX2)) +def test_chord(mode, bbox): # Arrange im = Image.new(mode, (W, H)) draw = ImageDraw.Draw(im) expected = f"Tests/images/imagedraw_chord_{mode}.png" # Act - draw.chord(bbox, start, end, fill="red", outline="yellow") + draw.chord(bbox, 0, 180, fill="red", outline="yellow") # Assert assert_image_similar_tofile(im, expected, 1) -def test_chord1(): - for mode in ["RGB", "L"]: - helper_chord(mode, BBOX1, 0, 180) - - -def test_chord2(): - for mode in ["RGB", "L"]: - helper_chord(mode, BBOX2, 0, 180) - - def test_chord_width(): # Arrange im = Image.new("RGB", (W, H)) @@ -263,7 +247,9 @@ def test_chord_too_fat(): assert_image_equal_tofile(im, "Tests/images/imagedraw_chord_too_fat.png") -def helper_ellipse(mode, bbox): +@pytest.mark.parametrize("mode", ("RGB", "L")) +@pytest.mark.parametrize("bbox", (BBOX1, BBOX2)) +def test_ellipse(mode, bbox): # Arrange im = Image.new(mode, (W, H)) draw = ImageDraw.Draw(im) @@ -276,16 +262,6 @@ def helper_ellipse(mode, bbox): assert_image_similar_tofile(im, expected, 1) -def test_ellipse1(): - for mode in ["RGB", "L"]: - helper_ellipse(mode, BBOX1) - - -def test_ellipse2(): - for mode in ["RGB", "L"]: - helper_ellipse(mode, BBOX2) - - def test_ellipse_translucent(): # Arrange im = Image.new("RGB", (W, H)) @@ -319,7 +295,7 @@ def test_ellipse_symmetric(): im = Image.new("RGB", (width, 100)) draw = ImageDraw.Draw(im) draw.ellipse(bbox, fill="green", outline="blue") - assert_image_equal(im, im.transpose(Image.FLIP_LEFT_RIGHT)) + assert_image_equal(im, im.transpose(Image.Transpose.FLIP_LEFT_RIGHT)) def test_ellipse_width(): @@ -405,7 +381,8 @@ def test_ellipse_various_sizes_filled(): ) -def helper_line(points): +@pytest.mark.parametrize("points", (POINTS1, POINTS2)) +def test_line(points): # Arrange im = Image.new("RGB", (W, H)) draw = ImageDraw.Draw(im) @@ -417,14 +394,6 @@ def helper_line(points): assert_image_equal_tofile(im, "Tests/images/imagedraw_line.png") -def test_line1(): - helper_line(POINTS1) - - -def test_line2(): - helper_line(POINTS2) - - def test_shape1(): # Arrange im = Image.new("RGB", (100, 100), "white") @@ -484,7 +453,9 @@ def test_transform(): assert_image_equal(im, expected) -def helper_pieslice(bbox, start, end): +@pytest.mark.parametrize("bbox", (BBOX1, BBOX2)) +@pytest.mark.parametrize("start, end", ((-92, 46), (-92.2, 46.2))) +def test_pieslice(bbox, start, end): # Arrange im = Image.new("RGB", (W, H)) draw = ImageDraw.Draw(im) @@ -496,16 +467,6 @@ def helper_pieslice(bbox, start, end): assert_image_similar_tofile(im, "Tests/images/imagedraw_pieslice.png", 1) -def test_pieslice1(): - helper_pieslice(BBOX1, -92, 46) - helper_pieslice(BBOX1, -92.2, 46.2) - - -def test_pieslice2(): - helper_pieslice(BBOX2, -92, 46) - helper_pieslice(BBOX2, -92.2, 46.2) - - def test_pieslice_width(): # Arrange im = Image.new("RGB", (W, H)) @@ -585,7 +546,8 @@ def test_pieslice_no_spikes(): assert_image_equal(im, im_pre_erase) -def helper_point(points): +@pytest.mark.parametrize("points", (POINTS1, POINTS2)) +def test_point(points): # Arrange im = Image.new("RGB", (W, H)) draw = ImageDraw.Draw(im) @@ -597,15 +559,8 @@ def helper_point(points): assert_image_equal_tofile(im, "Tests/images/imagedraw_point.png") -def test_point1(): - helper_point(POINTS1) - - -def test_point2(): - helper_point(POINTS2) - - -def helper_polygon(points): +@pytest.mark.parametrize("points", (POINTS1, POINTS2)) +def test_polygon(points): # Arrange im = Image.new("RGB", (W, H)) draw = ImageDraw.Draw(im) @@ -617,28 +572,20 @@ def helper_polygon(points): assert_image_equal_tofile(im, "Tests/images/imagedraw_polygon.png") -def test_polygon1(): - helper_polygon(POINTS1) - - -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 +602,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)) @@ -668,7 +629,8 @@ def test_polygon_translucent(): assert_image_equal_tofile(im, expected) -def helper_rectangle(bbox): +@pytest.mark.parametrize("bbox", (BBOX1, BBOX2)) +def test_rectangle(bbox): # Arrange im = Image.new("RGB", (W, H)) draw = ImageDraw.Draw(im) @@ -680,14 +642,6 @@ def helper_rectangle(bbox): assert_image_equal_tofile(im, "Tests/images/imagedraw_rectangle.png") -def test_rectangle1(): - helper_rectangle(BBOX1) - - -def test_rectangle2(): - helper_rectangle(BBOX2) - - def test_big_rectangle(): # Test drawing a rectangle bigger than the image # Arrange @@ -1218,21 +1172,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") @@ -1266,6 +1238,27 @@ def test_stroke_descender(): assert_image_similar_tofile(im, "Tests/images/imagedraw_stroke_descender.png", 6.76) +@skip_unless_feature("freetype2") +def test_split_word(): + # Arrange + im = Image.new("RGB", (230, 55)) + expected = im.copy() + expected_draw = ImageDraw.Draw(expected) + font = ImageFont.truetype("Tests/fonts/FreeMono.ttf", 48) + expected_draw.text((0, 0), "paradise", font=font) + + draw = ImageDraw.Draw(im) + + # Act + draw.text((0, 0), "par", font=font) + + length = draw.textlength("par", font=font) + draw.text((length, 0), "adise", font=font) + + # Assert + assert_image_equal(im, expected) + + @skip_unless_feature("freetype2") def test_stroke_multiline(): # Arrange @@ -1282,6 +1275,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 @@ -1440,3 +1450,23 @@ def test_continuous_horizontal_edges_polygon(): assert_image_equal_tofile( img, expected, "continuous horizontal edges polygon failed" ) + + +def test_discontiguous_corners_polygon(): + img, draw = create_base_image_draw((84, 68)) + draw.polygon(((1, 21), (34, 4), (71, 1), (38, 18)), BLACK) + draw.polygon(((71, 44), (38, 27), (1, 24)), BLACK) + draw.polygon( + ((38, 66), (5, 49), (77, 49), (47, 66), (82, 63), (82, 47), (1, 47), (1, 63)), + BLACK, + ) + expected = os.path.join(IMAGES_PATH, "discontiguous_corners_polygon.png") + assert_image_similar_tofile(img, expected, 1) + + +def test_polygon2(): + 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 3a70176cee5..6fc829f1a54 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 ( @@ -50,27 +52,19 @@ def test_sanity(): draw.line(list(range(10)), pen) -def helper_ellipse(mode, bbox): +@pytest.mark.parametrize("bbox", (BBOX1, BBOX2)) +def test_ellipse(bbox): # Arrange im = Image.new("RGB", (W, H)) draw = ImageDraw2.Draw(im) pen = ImageDraw2.Pen("blue", width=2) brush = ImageDraw2.Brush("green") - expected = f"Tests/images/imagedraw_ellipse_{mode}.png" # Act draw.ellipse(bbox, pen, brush) # Assert - assert_image_similar_tofile(im, expected, 1) - - -def test_ellipse1(): - helper_ellipse("RGB", BBOX1) - - -def test_ellipse2(): - helper_ellipse("RGB", BBOX2) + assert_image_similar_tofile(im, "Tests/images/imagedraw_ellipse_RGB.png", 1) def test_ellipse_edge(): @@ -86,7 +80,8 @@ def test_ellipse_edge(): assert_image_similar_tofile(im, "Tests/images/imagedraw_ellipse_edge.png", 1) -def helper_line(points): +@pytest.mark.parametrize("points", (POINTS1, POINTS2)) +def test_line(points): # Arrange im = Image.new("RGB", (W, H)) draw = ImageDraw2.Draw(im) @@ -99,14 +94,6 @@ def helper_line(points): assert_image_equal_tofile(im, "Tests/images/imagedraw_line.png") -def test_line1_pen(): - helper_line(POINTS1) - - -def test_line2_pen(): - helper_line(POINTS2) - - def test_line_pen_as_brush(): # Arrange im = Image.new("RGB", (W, H)) @@ -122,7 +109,8 @@ def test_line_pen_as_brush(): assert_image_equal_tofile(im, "Tests/images/imagedraw_line.png") -def helper_polygon(points): +@pytest.mark.parametrize("points", (POINTS1, POINTS2)) +def test_polygon(points): # Arrange im = Image.new("RGB", (W, H)) draw = ImageDraw2.Draw(im) @@ -136,15 +124,8 @@ def helper_polygon(points): assert_image_equal_tofile(im, "Tests/images/imagedraw_polygon.png") -def test_polygon1(): - helper_polygon(POINTS1) - - -def test_polygon2(): - helper_polygon(POINTS2) - - -def helper_rectangle(bbox): +@pytest.mark.parametrize("bbox", (BBOX1, BBOX2)) +def test_rectangle(bbox): # Arrange im = Image.new("RGB", (W, H)) draw = ImageDraw2.Draw(im) @@ -158,14 +139,6 @@ def helper_rectangle(bbox): assert_image_equal_tofile(im, "Tests/images/imagedraw_rectangle.png") -def test_rectangle1(): - helper_rectangle(BBOX1) - - -def test_rectangle2(): - helper_rectangle(BBOX2) - - def test_big_rectangle(): # Test drawing a rectangle bigger than the image # Arrange @@ -205,7 +178,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 +196,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_imageenhance.py b/Tests/test_imageenhance.py index 8bc94401e80..221ef8cdb26 100644 --- a/Tests/test_imageenhance.py +++ b/Tests/test_imageenhance.py @@ -1,3 +1,5 @@ +import pytest + from PIL import Image, ImageEnhance from .helper import assert_image_equal, hopper @@ -39,17 +41,17 @@ def _check_alpha(im, original, op, amount): ) -def test_alpha(): +@pytest.mark.parametrize("op", ("Color", "Brightness", "Contrast", "Sharpness")) +def test_alpha(op): # Issue https://github.com/python-pillow/Pillow/issues/899 # Is alpha preserved through image enhancement? original = _half_transparent_image() - for op in ["Color", "Brightness", "Contrast", "Sharpness"]: - for amount in [0, 0.5, 1.0]: - _check_alpha( - getattr(ImageEnhance, op)(original).enhance(amount), - original, - op, - amount, - ) + for amount in [0, 0.5, 1.0]: + _check_alpha( + getattr(ImageEnhance, op)(original).enhance(amount), + original, + op, + amount, + ) diff --git a/Tests/test_imagefile.py b/Tests/test_imagefile.py index a5c76700d65..fc0fbfb9bbc 100644 --- a/Tests/test_imagefile.py +++ b/Tests/test_imagefile.py @@ -2,7 +2,15 @@ import pytest -from PIL import BmpImagePlugin, EpsImagePlugin, Image, ImageFile, _binary, features +from PIL import ( + BmpImagePlugin, + EpsImagePlugin, + Image, + ImageFile, + UnidentifiedImageError, + _binary, + features, +) from .helper import ( assert_image, @@ -23,7 +31,7 @@ class TestImageFile: def test_parser(self): def roundtrip(format): - im = hopper("L").resize((1000, 1000), Image.NEAREST) + im = hopper("L").resize((1000, 1000), Image.Resampling.NEAREST) if format in ("MSP", "XBM"): im = im.convert("1") @@ -35,9 +43,9 @@ def roundtrip(format): parser = ImageFile.Parser() parser.feed(data) - imOut = parser.close() + im_out = parser.close() - return im, imOut + return im, im_out assert_image_equal(*roundtrip("BMP")) im1, im2 = roundtrip("GIF") @@ -124,6 +132,23 @@ def test_negative_stride(self): with pytest.raises(OSError): p.close() + def test_no_format(self): + buf = BytesIO(b"\x00" * 255) + + class DummyImageFile(ImageFile.ImageFile): + def _open(self): + self.mode = "RGB" + self._size = (1, 1) + + im = DummyImageFile(buf) + assert im.format is None + assert im.get_format_mimetype() is None + + def test_oserror(self): + im = Image.new("RGB", (1, 1)) + with pytest.raises(OSError): + im.save(BytesIO(), "JPEG2000", num_resolutions=2) + def test_truncated(self): b = BytesIO( b"BM000000000000" # head_data @@ -179,6 +204,14 @@ def decode(self, buffer): return -1, 0 +class MockPyEncoder(ImageFile.PyEncoder): + def encode(self, buffer): + return 1, 1, b"" + + def cleanup(self): + self.cleanup_called = True + + xoff, yoff, xsize, ysize = 10, 20, 100, 100 @@ -190,53 +223,58 @@ def _open(self): self.tile = [("MOCK", (xoff, yoff, xoff + xsize, yoff + ysize), 32, None)] -class TestPyDecoder: - def get_decoder(self): - decoder = MockPyDecoder(None) +class CodecsTest: + @classmethod + def setup_class(cls): + cls.decoder = MockPyDecoder(None) + cls.encoder = MockPyEncoder(None) + + def decoder_closure(mode, *args): + cls.decoder.__init__(mode, *args) + return cls.decoder + + def encoder_closure(mode, *args): + cls.encoder.__init__(mode, *args) + return cls.encoder - def closure(mode, *args): - decoder.__init__(mode, *args) - return decoder + Image.register_decoder("MOCK", decoder_closure) + Image.register_encoder("MOCK", encoder_closure) - Image.register_decoder("MOCK", closure) - return decoder +class TestPyDecoder(CodecsTest): def test_setimage(self): buf = BytesIO(b"\x00" * 255) im = MockImageFile(buf) - d = self.get_decoder() im.load() - assert d.state.xoff == xoff - assert d.state.yoff == yoff - assert d.state.xsize == xsize - assert d.state.ysize == ysize + assert self.decoder.state.xoff == xoff + assert self.decoder.state.yoff == yoff + assert self.decoder.state.xsize == xsize + assert self.decoder.state.ysize == ysize with pytest.raises(ValueError): - d.set_as_raw(b"\x00") + self.decoder.set_as_raw(b"\x00") def test_extents_none(self): buf = BytesIO(b"\x00" * 255) im = MockImageFile(buf) im.tile = [("MOCK", None, 32, None)] - d = self.get_decoder() im.load() - assert d.state.xoff == 0 - assert d.state.yoff == 0 - assert d.state.xsize == 200 - assert d.state.ysize == 200 + assert self.decoder.state.xoff == 0 + assert self.decoder.state.yoff == 0 + assert self.decoder.state.xsize == 200 + assert self.decoder.state.ysize == 200 def test_negsize(self): buf = BytesIO(b"\x00" * 255) im = MockImageFile(buf) im.tile = [("MOCK", (xoff, yoff, -10, yoff + ysize), 32, None)] - self.get_decoder() with pytest.raises(ValueError): im.load() @@ -250,7 +288,6 @@ def test_oversize(self): im = MockImageFile(buf) im.tile = [("MOCK", (xoff, yoff, xoff + xsize + 100, yoff + ysize), 32, None)] - self.get_decoder() with pytest.raises(ValueError): im.load() @@ -259,14 +296,96 @@ def test_oversize(self): with pytest.raises(ValueError): im.load() - def test_no_format(self): + def test_decode(self): + decoder = ImageFile.PyDecoder(None) + with pytest.raises(NotImplementedError): + decoder.decode(None) + + +class TestPyEncoder(CodecsTest): + def test_setimage(self): buf = BytesIO(b"\x00" * 255) im = MockImageFile(buf) - assert im.format is None - assert im.get_format_mimetype() is None - def test_oserror(self): - im = Image.new("RGB", (1, 1)) - with pytest.raises(OSError): - im.save(BytesIO(), "JPEG2000", num_resolutions=2) + fp = BytesIO() + ImageFile._save( + im, fp, [("MOCK", (xoff, yoff, xoff + xsize, yoff + ysize), 0, "RGB")] + ) + + assert self.encoder.state.xoff == xoff + assert self.encoder.state.yoff == yoff + assert self.encoder.state.xsize == xsize + assert self.encoder.state.ysize == ysize + + def test_extents_none(self): + buf = BytesIO(b"\x00" * 255) + + im = MockImageFile(buf) + im.tile = [("MOCK", None, 32, None)] + + fp = BytesIO() + ImageFile._save(im, fp, [("MOCK", None, 0, "RGB")]) + + assert self.encoder.state.xoff == 0 + assert self.encoder.state.yoff == 0 + assert self.encoder.state.xsize == 200 + assert self.encoder.state.ysize == 200 + + def test_negsize(self): + buf = BytesIO(b"\x00" * 255) + + im = MockImageFile(buf) + + fp = BytesIO() + self.encoder.cleanup_called = False + with pytest.raises(ValueError): + ImageFile._save( + im, fp, [("MOCK", (xoff, yoff, -10, yoff + ysize), 0, "RGB")] + ) + assert self.encoder.cleanup_called + + with pytest.raises(ValueError): + ImageFile._save( + im, fp, [("MOCK", (xoff, yoff, xoff + xsize, -10), 0, "RGB")] + ) + + def test_oversize(self): + buf = BytesIO(b"\x00" * 255) + + im = MockImageFile(buf) + + fp = BytesIO() + with pytest.raises(ValueError): + ImageFile._save( + im, + fp, + [("MOCK", (xoff, yoff, xoff + xsize + 100, yoff + ysize), 0, "RGB")], + ) + + with pytest.raises(ValueError): + ImageFile._save( + im, + fp, + [("MOCK", (xoff, yoff, xoff + xsize, yoff + ysize + 100), 0, "RGB")], + ) + + def test_encode(self): + encoder = ImageFile.PyEncoder(None) + with pytest.raises(NotImplementedError): + encoder.encode(None) + + bytes_consumed, errcode = encoder.encode_to_pyfd() + assert bytes_consumed == 0 + assert ImageFile.ERRORS[errcode] == "bad configuration" + + encoder._pushes_fd = True + with pytest.raises(NotImplementedError): + encoder.encode_to_pyfd() + + with pytest.raises(NotImplementedError): + encoder.encode_to_file(None, None) + + def test_zero_height(self): + with pytest.raises(UnidentifiedImageError): + Image.open("Tests/images/zero_height.j2k") diff --git a/Tests/test_imagefont.py b/Tests/test_imagefont.py index 0d423aab7be..306a2f1bff6 100644 --- a/Tests/test_imagefont.py +++ b/Tests/test_imagefont.py @@ -28,446 +28,527 @@ pytestmark = skip_unless_feature("freetype2") -class TestImageFont: - LAYOUT_ENGINE = ImageFont.LAYOUT_BASIC +def test_sanity(): + assert re.search(r"\d+\.\d+\.\d+$", features.version_module("freetype2")) + + +@pytest.fixture( + scope="module", + params=[ + pytest.param(ImageFont.Layout.BASIC), + pytest.param(ImageFont.Layout.RAQM, marks=skip_unless_feature("raqm")), + ], +) +def layout_engine(request): + return request.param + + +@pytest.fixture(scope="module") +def font(layout_engine): + return ImageFont.truetype(FONT_PATH, FONT_SIZE, layout_engine=layout_engine) - def get_font(self): - return ImageFont.truetype( - FONT_PATH, FONT_SIZE, layout_engine=self.LAYOUT_ENGINE - ) - def test_sanity(self): - assert re.search(r"\d+\.\d+\.\d+$", features.version_module("freetype2")) +def test_font_properties(font): + assert font.path == FONT_PATH + assert font.size == FONT_SIZE - def test_font_properties(self): - ttf = self.get_font() - assert ttf.path == FONT_PATH - assert ttf.size == FONT_SIZE + font_copy = font.font_variant() + assert font_copy.path == FONT_PATH + assert font_copy.size == FONT_SIZE - ttf_copy = ttf.font_variant() - assert ttf_copy.path == FONT_PATH - assert ttf_copy.size == FONT_SIZE + font_copy = font.font_variant(size=FONT_SIZE + 1) + assert font_copy.size == FONT_SIZE + 1 - ttf_copy = ttf.font_variant(size=FONT_SIZE + 1) - assert ttf_copy.size == FONT_SIZE + 1 + second_font_path = "Tests/fonts/DejaVuSans/DejaVuSans.ttf" + font_copy = font.font_variant(font=second_font_path) + assert font_copy.path == second_font_path - second_font_path = "Tests/fonts/DejaVuSans/DejaVuSans.ttf" - ttf_copy = ttf.font_variant(font=second_font_path) - assert ttf_copy.path == second_font_path - def test_font_with_name(self): - self.get_font() - self._render(FONT_PATH) +def _render(font, layout_engine): + txt = "Hello World!" + ttf = ImageFont.truetype(font, FONT_SIZE, layout_engine=layout_engine) + ttf.getbbox(txt) - def _font_as_bytes(self): + img = Image.new("RGB", (256, 64), "white") + d = ImageDraw.Draw(img) + d.text((10, 10), txt, font=ttf, fill="black") + + return img + + +def test_font_with_name(layout_engine): + _render(FONT_PATH, layout_engine) + + +def test_font_with_filelike(layout_engine): + def _font_as_bytes(): with open(FONT_PATH, "rb") as f: font_bytes = BytesIO(f.read()) return font_bytes - def test_font_with_filelike(self): - ImageFont.truetype( - self._font_as_bytes(), FONT_SIZE, layout_engine=self.LAYOUT_ENGINE - ) - self._render(self._font_as_bytes()) - # Usage note: making two fonts from the same buffer fails. - # shared_bytes = self._font_as_bytes() - # self._render(shared_bytes) - # with pytest.raises(Exception): - # _render(shared_bytes) - - def test_font_with_open_file(self): - with open(FONT_PATH, "rb") as f: - self._render(f) + ttf = ImageFont.truetype(_font_as_bytes(), FONT_SIZE, layout_engine=layout_engine) + ttf_copy = ttf.font_variant() + assert ttf_copy.font_bytes == ttf.font_bytes - def test_non_ascii_path(self, tmp_path): - tempfile = str(tmp_path / ("temp_" + chr(128) + ".ttf")) - try: - shutil.copy(FONT_PATH, tempfile) - except UnicodeEncodeError: - pytest.skip("Non-ASCII path could not be created") + _render(_font_as_bytes(), layout_engine) + # Usage note: making two fonts from the same buffer fails. + # shared_bytes = _font_as_bytes() + # _render(shared_bytes) + # with pytest.raises(Exception): + # _render(shared_bytes) - ImageFont.truetype(tempfile, FONT_SIZE) - def test_unavailable_layout_engine(self): - have_raqm = ImageFont.core.HAVE_RAQM - ImageFont.core.HAVE_RAQM = False +def test_font_with_open_file(layout_engine): + with open(FONT_PATH, "rb") as f: + _render(f, layout_engine) - try: - ttf = ImageFont.truetype( - FONT_PATH, FONT_SIZE, layout_engine=ImageFont.LAYOUT_RAQM - ) - finally: - ImageFont.core.HAVE_RAQM = have_raqm - assert ttf.layout_engine == ImageFont.LAYOUT_BASIC +def test_render_equal(layout_engine): + img_path = _render(FONT_PATH, layout_engine) + with open(FONT_PATH, "rb") as f: + font_filelike = BytesIO(f.read()) + img_filelike = _render(font_filelike, layout_engine) - def _render(self, font): - txt = "Hello World!" - ttf = ImageFont.truetype(font, FONT_SIZE, layout_engine=self.LAYOUT_ENGINE) - ttf.getsize(txt) + assert_image_equal(img_path, img_filelike) - img = Image.new("RGB", (256, 64), "white") - d = ImageDraw.Draw(img) - d.text((10, 10), txt, font=ttf, fill="black") - return img +def test_non_ascii_path(tmp_path, layout_engine): + tempfile = str(tmp_path / ("temp_" + chr(128) + ".ttf")) + try: + shutil.copy(FONT_PATH, tempfile) + except UnicodeEncodeError: + pytest.skip("Non-ASCII path could not be created") - def test_render_equal(self): - img_path = self._render(FONT_PATH) - with open(FONT_PATH, "rb") as f: - font_filelike = BytesIO(f.read()) - img_filelike = self._render(font_filelike) + ImageFont.truetype(tempfile, FONT_SIZE, layout_engine=layout_engine) - assert_image_equal(img_path, img_filelike) - def test_transparent_background(self): - im = Image.new(mode="RGBA", size=(300, 100)) - draw = ImageDraw.Draw(im) - ttf = self.get_font() +def test_transparent_background(font): + im = Image.new(mode="RGBA", size=(300, 100)) + draw = ImageDraw.Draw(im) - txt = "Hello World!" - draw.text((10, 10), txt, font=ttf) + txt = "Hello World!" + draw.text((10, 10), txt, font=font) - target = "Tests/images/transparent_background_text.png" - assert_image_similar_tofile(im, target, 4.09) + target = "Tests/images/transparent_background_text.png" + assert_image_similar_tofile(im, target, 4.09) - target = "Tests/images/transparent_background_text_L.png" - assert_image_similar_tofile(im.convert("L"), target, 0.01) + target = "Tests/images/transparent_background_text_L.png" + assert_image_similar_tofile(im.convert("L"), target, 0.01) - def test_I16(self): - im = Image.new(mode="I;16", size=(300, 100)) - draw = ImageDraw.Draw(im) - ttf = self.get_font() - txt = "Hello World!" - draw.text((10, 10), txt, font=ttf) +def test_I16(font): + im = Image.new(mode="I;16", size=(300, 100)) + draw = ImageDraw.Draw(im) - target = "Tests/images/transparent_background_text_L.png" - assert_image_similar_tofile(im.convert("L"), target, 0.01) + txt = "Hello World!" + draw.text((10, 10), txt, font=font) - def test_textsize_equal(self): - im = Image.new(mode="RGB", size=(300, 100)) - draw = ImageDraw.Draw(im) - ttf = self.get_font() + target = "Tests/images/transparent_background_text_L.png" + assert_image_similar_tofile(im.convert("L"), target, 0.01) - txt = "Hello World!" - size = draw.textsize(txt, ttf) - draw.text((10, 10), txt, font=ttf) - draw.rectangle((10, 10, 10 + size[0], 10 + size[1])) - assert_image_similar_tofile( - im, "Tests/images/rectangle_surrounding_text.png", 2.5 - ) +def test_textbbox_equal(font): + im = Image.new(mode="RGB", size=(300, 100)) + draw = ImageDraw.Draw(im) + + txt = "Hello World!" + bbox = draw.textbbox((10, 10), txt, font) + draw.text((10, 10), txt, font=font) + draw.rectangle(bbox) + + assert_image_similar_tofile(im, "Tests/images/rectangle_surrounding_text.png", 2.5) - @pytest.mark.parametrize( - "text, mode, font, size, length_basic, length_raqm", - ( - # basic test - ("text", "L", "FreeMono.ttf", 15, 36, 36), - ("text", "1", "FreeMono.ttf", 15, 36, 36), - # issue 4177 - ("rrr", "L", "DejaVuSans/DejaVuSans.ttf", 18, 21, 22.21875), - ("rrr", "1", "DejaVuSans/DejaVuSans.ttf", 18, 24, 22.21875), - # test 'l' not including extra margin - # using exact value 2047 / 64 for raqm, checked with debugger - ("ill", "L", "OpenSansCondensed-LightItalic.ttf", 63, 33, 31.984375), - ("ill", "1", "OpenSansCondensed-LightItalic.ttf", 63, 33, 31.984375), - ), + +@pytest.mark.parametrize( + "text, mode, fontname, size, length_basic, length_raqm", + ( + # basic test + ("text", "L", "FreeMono.ttf", 15, 36, 36), + ("text", "1", "FreeMono.ttf", 15, 36, 36), + # issue 4177 + ("rrr", "L", "DejaVuSans/DejaVuSans.ttf", 18, 21, 22.21875), + ("rrr", "1", "DejaVuSans/DejaVuSans.ttf", 18, 24, 22.21875), + # test 'l' not including extra margin + # using exact value 2047 / 64 for raqm, checked with debugger + ("ill", "L", "OpenSansCondensed-LightItalic.ttf", 63, 33, 31.984375), + ("ill", "1", "OpenSansCondensed-LightItalic.ttf", 63, 33, 31.984375), + ), +) +def test_getlength( + text, mode, fontname, size, layout_engine, length_basic, length_raqm +): + f = ImageFont.truetype("Tests/fonts/" + fontname, size, layout_engine=layout_engine) + + im = Image.new(mode, (1, 1), 0) + d = ImageDraw.Draw(im) + + if layout_engine == ImageFont.Layout.BASIC: + length = d.textlength(text, f) + assert length == length_basic + else: + # disable kerning, kerning metrics changed + length = d.textlength(text, f, features=["-kern"]) + assert length == length_raqm + + +def test_render_multiline(font): + im = Image.new(mode="RGB", size=(300, 100)) + draw = ImageDraw.Draw(im) + line_spacing = font.getbbox("A")[3] + 4 + lines = TEST_TEXT.split("\n") + y = 0 + for line in lines: + draw.text((0, y), line, font=font) + y += line_spacing + + # some versions of freetype have different horizontal spacing. + # setting a tight epsilon, I'm showing the original test failure + # at epsilon = ~38. + assert_image_similar_tofile(im, "Tests/images/multiline_text.png", 6.2) + + +def test_render_multiline_text(font): + # Test that text() correctly connects to multiline_text() + # and that align defaults to left + im = Image.new(mode="RGB", size=(300, 100)) + draw = ImageDraw.Draw(im) + draw.text((0, 0), TEST_TEXT, font=font) + + assert_image_similar_tofile(im, "Tests/images/multiline_text.png", 0.01) + + # Test that text() can pass on additional arguments + # to multiline_text() + draw.text( + (0, 0), TEST_TEXT, fill=None, font=font, anchor=None, spacing=4, align="left" ) - def test_getlength(self, text, mode, font, size, length_basic, length_raqm): - f = ImageFont.truetype( - "Tests/fonts/" + font, size, layout_engine=self.LAYOUT_ENGINE - ) + draw.text((0, 0), TEST_TEXT, None, font, None, 4, "left") - im = Image.new(mode, (1, 1), 0) - d = ImageDraw.Draw(im) - if self.LAYOUT_ENGINE == ImageFont.LAYOUT_BASIC: - length = d.textlength(text, f) - assert length == length_basic - else: - # disable kerning, kerning metrics changed - length = d.textlength(text, f, features=["-kern"]) - assert length == length_raqm - - def test_render_multiline(self): - 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 - lines = TEST_TEXT.split("\n") - y = 0 - for line in lines: - draw.text((0, y), line, font=ttf) - y += line_spacing - - # some versions of freetype have different horizontal spacing. - # setting a tight epsilon, I'm showing the original test failure - # at epsilon = ~38. - assert_image_similar_tofile(im, "Tests/images/multiline_text.png", 6.2) - - def test_render_multiline_text(self): - ttf = self.get_font() - - # Test that text() correctly connects to multiline_text() - # and that align defaults to left - im = Image.new(mode="RGB", size=(300, 100)) - draw = ImageDraw.Draw(im) - draw.text((0, 0), TEST_TEXT, font=ttf) - - assert_image_similar_tofile(im, "Tests/images/multiline_text.png", 0.01) - - # Test that text() can pass on additional arguments - # to multiline_text() - draw.text( - (0, 0), TEST_TEXT, fill=None, font=ttf, anchor=None, spacing=4, align="left" - ) - draw.text((0, 0), TEST_TEXT, None, ttf, None, 4, "left") +@pytest.mark.parametrize( + "align, ext", (("left", ""), ("center", "_center"), ("right", "_right")) +) +def test_render_multiline_text_align(font, align, ext): + im = Image.new(mode="RGB", size=(300, 100)) + draw = ImageDraw.Draw(im) + draw.multiline_text((0, 0), TEST_TEXT, font=font, align=align) - # Test align center and right - for align, ext in {"center": "_center", "right": "_right"}.items(): - im = Image.new(mode="RGB", size=(300, 100)) - draw = ImageDraw.Draw(im) - draw.multiline_text((0, 0), TEST_TEXT, font=ttf, align=align) + assert_image_similar_tofile(im, f"Tests/images/multiline_text{ext}.png", 0.01) - assert_image_similar_tofile( - im, "Tests/images/multiline_text" + ext + ".png", 0.01 - ) - def test_unknown_align(self): - im = Image.new(mode="RGB", size=(300, 100)) - draw = ImageDraw.Draw(im) - ttf = self.get_font() +def test_unknown_align(font): + im = Image.new(mode="RGB", size=(300, 100)) + draw = ImageDraw.Draw(im) + + # Act/Assert + with pytest.raises(ValueError): + draw.multiline_text((0, 0), TEST_TEXT, font=font, align="unknown") - # Act/Assert - with pytest.raises(ValueError): - draw.multiline_text((0, 0), TEST_TEXT, font=ttf, align="unknown") - def test_draw_align(self): - im = Image.new("RGB", (300, 100), "white") - draw = ImageDraw.Draw(im) - ttf = self.get_font() - line = "some text" - draw.text((100, 40), line, (0, 0, 0), font=ttf, align="left") +def test_draw_align(font): + im = Image.new("RGB", (300, 100), "white") + draw = ImageDraw.Draw(im) + line = "some text" + draw.text((100, 40), line, (0, 0, 0), font=font, align="left") + - def test_multiline_size(self): - ttf = self.get_font() - im = Image.new(mode="RGB", size=(300, 100)) - draw = ImageDraw.Draw(im) +def test_multiline_size(font): + im = Image.new(mode="RGB", size=(300, 100)) + draw = ImageDraw.Draw(im) + 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 + assert draw.textsize(TEST_TEXT, font=font) == draw.multiline_textsize( + TEST_TEXT, font=font ) # Test that multiline_textsize corresponds to ImageFont.textsize() # for single line text - assert ttf.getsize("A") == draw.multiline_textsize("A", font=ttf) + assert font.getsize("A") == draw.multiline_textsize("A", font=font) # 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) + draw.textsize(TEST_TEXT, font=font, spacing=4) + draw.textsize(TEST_TEXT, font, 4) + assert len(log) == 6 + + +def test_multiline_bbox(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=font) == draw.multiline_textbbox( + (0, 0), TEST_TEXT, font=font + ) + + # Test that multiline_textbbox corresponds to ImageFont.textbbox() + # for single line text + assert font.getbbox("A") == draw.multiline_textbbox((0, 0), "A", font=font) + + # Test that textbbox() can pass on additional arguments + # to multiline_textbbox() + draw.textbbox((0, 0), TEST_TEXT, font=font, spacing=4) - def test_multiline_width(self): - ttf = self.get_font() - im = Image.new(mode="RGB", size=(300, 100)) - draw = ImageDraw.Draw(im) +def test_multiline_width(font): + im = Image.new(mode="RGB", size=(300, 100)) + draw = ImageDraw.Draw(im) + + assert ( + draw.textbbox((0, 0), "longest line", font=font)[2] + == draw.multiline_textbbox((0, 0), "longest line\nline", font=font)[2] + ) + with pytest.warns(DeprecationWarning) as log: assert ( - draw.textsize("longest line", font=ttf)[0] - == draw.multiline_textsize("longest line\nline", font=ttf)[0] + draw.textsize("longest line", font=font)[0] + == draw.multiline_textsize("longest line\nline", font=font)[0] ) + assert len(log) == 2 - def test_multiline_spacing(self): - ttf = self.get_font() - im = Image.new(mode="RGB", size=(300, 100)) - draw = ImageDraw.Draw(im) - draw.multiline_text((0, 0), TEST_TEXT, font=ttf, spacing=10) +def test_multiline_spacing(font): + im = Image.new(mode="RGB", size=(300, 100)) + draw = ImageDraw.Draw(im) + draw.multiline_text((0, 0), TEST_TEXT, font=font, spacing=10) + + assert_image_similar_tofile(im, "Tests/images/multiline_text_spacing.png", 2.5) - assert_image_similar_tofile(im, "Tests/images/multiline_text_spacing.png", 2.5) - def test_rotated_transposed_font(self): - img_grey = Image.new("L", (100, 100)) - draw = ImageDraw.Draw(img_grey) - word = "testing" - font = self.get_font() +@pytest.mark.parametrize( + "orientation", (Image.Transpose.ROTATE_90, Image.Transpose.ROTATE_270) +) +def test_rotated_transposed_font(font, orientation): + img_grey = Image.new("L", (100, 100)) + draw = ImageDraw.Draw(img_grey) + word = "testing" - orientation = Image.ROTATE_90 - transposed_font = ImageFont.TransposedFont(font, orientation=orientation) + transposed_font = ImageFont.TransposedFont(font, orientation=orientation) - # Original font - draw.font = font + # Original font + draw.font = font + 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 + # Rotated font + draw.font = transposed_font + 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] - # 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] + # 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) - word = "testing" - font = self.get_font() - orientation = None - transposed_font = ImageFont.TransposedFont(font, orientation=orientation) +@pytest.mark.parametrize( + "orientation", + ( + None, + Image.Transpose.ROTATE_180, + Image.Transpose.FLIP_LEFT_RIGHT, + Image.Transpose.FLIP_TOP_BOTTOM, + ), +) +def test_unrotated_transposed_font(font, orientation): + img_grey = Image.new("L", (100, 100)) + draw = ImageDraw.Draw(img_grey) + word = "testing" - # Original font - draw.font = font + transposed_font = ImageFont.TransposedFont(font, orientation=orientation) + + # Original font + draw.font = font + 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 + # Rotated font + draw.font = transposed_font + 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 boxes a and b are same size + assert box_size_a == box_size_b - def test_rotated_transposed_font_get_mask(self): - # Arrange - text = "mask this" - font = self.get_font() - orientation = Image.ROTATE_90 - transposed_font = ImageFont.TransposedFont(font, orientation=orientation) + # 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] - # Act - mask = transposed_font.getmask(text) + assert length_a == length_b - # Assert - assert mask.size == (13, 108) - def test_unrotated_transposed_font_get_mask(self): - # Arrange - text = "mask this" - font = self.get_font() - orientation = None - transposed_font = ImageFont.TransposedFont(font, orientation=orientation) +@pytest.mark.parametrize( + "orientation", (Image.Transpose.ROTATE_90, Image.Transpose.ROTATE_270) +) +def test_rotated_transposed_font_get_mask(font, orientation): + # Arrange + text = "mask this" + transposed_font = ImageFont.TransposedFont(font, orientation=orientation) - # Act - mask = transposed_font.getmask(text) + # Act + mask = transposed_font.getmask(text) - # Assert - assert mask.size == (108, 13) + # Assert + assert mask.size == (13, 108) - def test_free_type_font_get_name(self): - # Arrange - font = self.get_font() - # Act - name = font.getname() +@pytest.mark.parametrize( + "orientation", + ( + None, + Image.Transpose.ROTATE_180, + Image.Transpose.FLIP_LEFT_RIGHT, + Image.Transpose.FLIP_TOP_BOTTOM, + ), +) +def test_unrotated_transposed_font_get_mask(font, orientation): + # Arrange + text = "mask this" + transposed_font = ImageFont.TransposedFont(font, orientation=orientation) - # Assert - assert ("FreeMono", "Regular") == name + # Act + mask = transposed_font.getmask(text) - def test_free_type_font_get_metrics(self): - # Arrange - font = self.get_font() + # Assert + assert mask.size == (108, 13) - # Act - ascent, descent = font.getmetrics() - # Assert - assert isinstance(ascent, int) - assert isinstance(descent, int) - assert (ascent, descent) == (16, 4) # too exact check? +def test_free_type_font_get_name(font): + assert ("FreeMono", "Regular") == font.getname() - def test_free_type_font_get_offset(self): - # Arrange - font = self.get_font() - text = "offset this" - # Act +def test_free_type_font_get_metrics(font): + ascent, descent = font.getmetrics() + + assert isinstance(ascent, int) + assert isinstance(descent, int) + assert (ascent, descent) == (16, 4) + + +def test_free_type_font_get_offset(font): + # Arrange + text = "offset this" + + # Act + with pytest.warns(DeprecationWarning) as log: offset = font.getoffset(text) - # Assert - assert offset == (0, 3) + # Assert + assert len(log) == 1 + assert offset == (0, 3) - def test_free_type_font_get_mask(self): - # Arrange - font = self.get_font() - text = "mask this" - # Act - mask = font.getmask(text) +def test_free_type_font_get_mask(font): + # Arrange + text = "mask this" - # Assert - assert mask.size == (108, 13) + # Act + mask = font.getmask(text) - def test_load_path_not_found(self): - # Arrange - filename = "somefilenamethatdoesntexist.ttf" + # Assert + assert mask.size == (108, 13) - # Act/Assert - with pytest.raises(OSError): - ImageFont.load_path(filename) + +def test_load_path_not_found(): + # Arrange + filename = "somefilenamethatdoesntexist.ttf" + + # Act/Assert + with pytest.raises(OSError): + ImageFont.load_path(filename) + with pytest.raises(OSError): + ImageFont.truetype(filename) + + +def test_load_non_font_bytes(): + with open("Tests/images/hopper.jpg", "rb") as f: with pytest.raises(OSError): - ImageFont.truetype(filename) - - def test_load_non_font_bytes(self): - with open("Tests/images/hopper.jpg", "rb") as f: - with pytest.raises(OSError): - ImageFont.truetype(f) - - def test_default_font(self): - # Arrange - txt = 'This is a "better than nothing" default font.' - im = Image.new(mode="RGB", size=(300, 100)) - draw = ImageDraw.Draw(im) - - # Act - default_font = ImageFont.load_default() - draw.text((10, 10), txt, font=default_font) - - # Assert - assert_image_equal_tofile(im, "Tests/images/default_font.png") - - def test_getsize_empty(self): - # issue #2614 - font = self.get_font() - # should not crash. - assert (0, 0) == font.getsize("") - - def test_render_empty(self): - # issue 2666 - font = self.get_font() - im = Image.new(mode="RGB", size=(300, 100)) - target = im.copy() - draw = ImageDraw.Draw(im) - # should not crash here. - draw.text((10, 10), "", font=font) - assert_image_equal(im, target) - - def test_unicode_pilfont(self): - # should not segfault, should return UnicodeDecodeError - # issue #2826 - font = ImageFont.load_default() - with pytest.raises(UnicodeEncodeError): - font.getsize("’") - - def test_unicode_extended(self): - # issue #3777 - text = "A\u278A\U0001F12B" - target = "Tests/images/unicode_extended.png" - - ttf = ImageFont.truetype( - "Tests/fonts/NotoSansSymbols-Regular.ttf", - FONT_SIZE, - layout_engine=self.LAYOUT_ENGINE, - ) - img = Image.new("RGB", (100, 60)) - d = ImageDraw.Draw(img) - d.text((10, 10), text, font=ttf) + ImageFont.truetype(f) + + +def test_default_font(): + # Arrange + txt = 'This is a "better than nothing" default font.' + im = Image.new(mode="RGB", size=(300, 100)) + draw = ImageDraw.Draw(im) - # fails with 14.7 - assert_image_similar_tofile(img, target, 6.2) + # Act + default_font = ImageFont.load_default() + draw.text((10, 10), txt, font=default_font) + + # Assert + assert_image_equal_tofile(im, "Tests/images/default_font.png") + + +def test_getbbox_empty(font): + # issue #2614, should not crash. + assert (0, 0, 0, 0) == font.getbbox("") + + +def test_render_empty(font): + # issue 2666 + im = Image.new(mode="RGB", size=(300, 100)) + target = im.copy() + draw = ImageDraw.Draw(im) + # should not crash here. + draw.text((10, 10), "", font=font) + assert_image_equal(im, target) - def _test_fake_loading_font(self, monkeypatch, path_to_fake, fontname): + +def test_unicode_pilfont(): + # should not segfault, should return UnicodeDecodeError + # issue #2826 + font = ImageFont.load_default() + with pytest.raises(UnicodeEncodeError): + font.getbbox("’") + + +def test_unicode_extended(layout_engine): + # issue #3777 + text = "A\u278A\U0001F12B" + target = "Tests/images/unicode_extended.png" + + ttf = ImageFont.truetype( + "Tests/fonts/NotoSansSymbols-Regular.ttf", + FONT_SIZE, + layout_engine=layout_engine, + ) + img = Image.new("RGB", (100, 60)) + d = ImageDraw.Draw(img) + d.text((10, 10), text, font=ttf) + + # fails with 14.7 + assert_image_similar_tofile(img, target, 6.2) + + +@pytest.mark.parametrize( + "platform, font_directory", + (("linux", "/usr/local/share/fonts"), ("darwin", "/System/Library/Fonts")), +) +@pytest.mark.skipif(is_win32(), reason="requires Unix or macOS") +def test_find_font(monkeypatch, platform, font_directory): + def _test_fake_loading_font(path_to_fake, fontname): # Make a copy of FreeTypeFont so we can patch the original free_type_font = copy.deepcopy(ImageFont.FreeTypeFont) with monkeypatch.context() as m: @@ -488,512 +569,527 @@ def loadable_font(filepath, size, index, encoding, *args, **kwargs): name = font.getname() assert ("FreeMono", "Regular") == name - @pytest.mark.skipif(is_win32(), reason="requires Unix or macOS") - def test_find_linux_font(self, monkeypatch): - # A lot of mocking here - this is more for hitting code and - # catching syntax like errors - font_directory = "/usr/local/share/fonts" - monkeypatch.setattr(sys, "platform", "linux") + # A lot of mocking here - this is more for hitting code and + # catching syntax like errors + monkeypatch.setattr(sys, "platform", platform) + if platform == "linux": monkeypatch.setenv("XDG_DATA_DIRS", "/usr/share/:/usr/local/share/") - def fake_walker(path): - if path == font_directory: - return [ - ( - path, - [], - ["Arial.ttf", "Single.otf", "Duplicate.otf", "Duplicate.ttf"], - ) - ] - return [(path, [], ["some_random_font.ttf"])] - - monkeypatch.setattr(os, "walk", fake_walker) - # Test that the font loads both with and without the - # extension - self._test_fake_loading_font( - monkeypatch, font_directory + "/Arial.ttf", "Arial.ttf" + def fake_walker(path): + if path == font_directory: + return [ + ( + path, + [], + ["Arial.ttf", "Single.otf", "Duplicate.otf", "Duplicate.ttf"], + ) + ] + return [(path, [], ["some_random_font.ttf"])] + + monkeypatch.setattr(os, "walk", fake_walker) + + # Test that the font loads both with and without the extension + _test_fake_loading_font(font_directory + "/Arial.ttf", "Arial.ttf") + _test_fake_loading_font(font_directory + "/Arial.ttf", "Arial") + + # Test that non-ttf fonts can be found without the extension + _test_fake_loading_font(font_directory + "/Single.otf", "Single") + + # Test that ttf fonts are preferred if the extension is not specified + _test_fake_loading_font(font_directory + "/Duplicate.ttf", "Duplicate") + + +def test_imagefont_getters(font): + assert font.getmetrics() == (16, 4) + assert font.font.ascent == 16 + assert font.font.descent == 4 + assert font.font.height == 20 + assert font.font.x_ppem == 20 + assert font.font.y_ppem == 20 + assert font.font.glyphs == 4177 + assert font.getbbox("A") == (0, 4, 12, 16) + assert font.getbbox("AB") == (0, 4, 24, 16) + assert font.getbbox("M") == (0, 4, 12, 16) + assert font.getbbox("y") == (0, 7, 12, 20) + assert font.getbbox("a") == (0, 7, 12, 16) + assert font.getlength("A") == 12 + assert font.getlength("AB") == 24 + assert font.getlength("M") == 12 + assert font.getlength("y") == 12 + assert font.getlength("a") == 12 + with pytest.warns(DeprecationWarning) as log: + assert font.getsize("A") == (12, 16) + assert font.getsize("AB") == (24, 16) + assert font.getsize("M") == (12, 16) + assert font.getsize("y") == (12, 20) + assert font.getsize("a") == (12, 16) + assert font.getsize_multiline("A") == (12, 16) + assert font.getsize_multiline("AB") == (24, 16) + assert font.getsize_multiline("a") == (12, 16) + assert font.getsize_multiline("ABC\n") == (36, 36) + assert font.getsize_multiline("ABC\nA") == (36, 36) + assert font.getsize_multiline("ABC\nAaaa") == (48, 36) + assert len(log) == 11 + + +@pytest.mark.parametrize("stroke_width", (0, 2)) +def test_getsize_stroke(font, stroke_width): + assert font.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 font.getsize("A", stroke_width=stroke_width) == ( + 12 + stroke_width * 2, + 16 + stroke_width * 2, ) - self._test_fake_loading_font( - monkeypatch, font_directory + "/Arial.ttf", "Arial" + assert font.getsize_multiline("ABC\nAaaa", stroke_width=stroke_width) == ( + 48 + stroke_width * 2, + 36 + stroke_width * 4, ) + assert len(log) == 2 - # Test that non-ttf fonts can be found without the - # extension - self._test_fake_loading_font( - monkeypatch, font_directory + "/Single.otf", "Single" - ) - # Test that ttf fonts are preferred if the extension is - # not specified - self._test_fake_loading_font( - monkeypatch, font_directory + "/Duplicate.ttf", "Duplicate" - ) +def test_complex_font_settings(): + t = ImageFont.truetype(FONT_PATH, FONT_SIZE, layout_engine=ImageFont.Layout.BASIC) + with pytest.raises(KeyError): + t.getmask("абвг", direction="rtl") + with pytest.raises(KeyError): + t.getmask("абвг", features=["-kern"]) + with pytest.raises(KeyError): + t.getmask("абвг", language="sr") - @pytest.mark.skipif(is_win32(), reason="requires Unix or macOS") - def test_find_macos_font(self, monkeypatch): - # Like the linux test, more cover hitting code rather than testing - # correctness. - font_directory = "/System/Library/Fonts" - monkeypatch.setattr(sys, "platform", "darwin") - - def fake_walker(path): - if path == font_directory: - return [ - ( - path, - [], - ["Arial.ttf", "Single.otf", "Duplicate.otf", "Duplicate.ttf"], - ) - ] - return [(path, [], ["some_random_font.ttf"])] - monkeypatch.setattr(os, "walk", fake_walker) - self._test_fake_loading_font( - monkeypatch, font_directory + "/Arial.ttf", "Arial.ttf" - ) - self._test_fake_loading_font( - monkeypatch, font_directory + "/Arial.ttf", "Arial" - ) - self._test_fake_loading_font( - monkeypatch, font_directory + "/Single.otf", "Single" - ) - self._test_fake_loading_font( - monkeypatch, font_directory + "/Duplicate.ttf", "Duplicate" - ) +def test_variation_get(font): + freetype = parse_version(features.version_module("freetype2")) + if freetype < parse_version("2.9.1"): + with pytest.raises(NotImplementedError): + font.get_variation_names() + with pytest.raises(NotImplementedError): + font.get_variation_axes() + return + + with pytest.raises(OSError): + font.get_variation_names() + with pytest.raises(OSError): + font.get_variation_axes() + + font = ImageFont.truetype("Tests/fonts/AdobeVFPrototype.ttf") + assert font.get_variation_names(), [ + b"ExtraLight", + b"Light", + b"Regular", + b"Semibold", + b"Bold", + b"Black", + b"Black Medium Contrast", + b"Black High Contrast", + b"Default", + ] + assert font.get_variation_axes() == [ + {"name": b"Weight", "minimum": 200, "maximum": 900, "default": 389}, + {"name": b"Contrast", "minimum": 0, "maximum": 100, "default": 0}, + ] + + font = ImageFont.truetype("Tests/fonts/TINY5x3GX.ttf") + assert font.get_variation_names() == [ + b"20", + b"40", + b"60", + b"80", + b"100", + b"120", + b"140", + b"160", + b"180", + b"200", + b"220", + b"240", + b"260", + b"280", + b"300", + b"Regular", + ] + assert font.get_variation_axes() == [ + {"name": b"Size", "minimum": 0, "maximum": 300, "default": 0} + ] + + +def _check_text(font, path, epsilon): + im = Image.new("RGB", (100, 75), "white") + d = ImageDraw.Draw(im) + d.text((10, 10), "Text", font=font, fill="black") + + try: + assert_image_similar_tofile(im, path, epsilon) + except AssertionError: + if "_adobe" in path: + path = path.replace("_adobe", "_adobe_older_harfbuzz") + assert_image_similar_tofile(im, path, epsilon) + else: + raise - def test_imagefont_getters(self): - # Arrange - t = self.get_font() - - # Act / Assert - assert t.getmetrics() == (16, 4) - assert t.font.ascent == 16 - assert t.font.descent == 4 - assert t.font.height == 20 - 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) - - def test_getsize_stroke(self): - # Arrange - t = self.get_font() - - # 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, - ) - def test_complex_font_settings(self): - # Arrange - t = self.get_font() - # Act / Assert - if t.layout_engine == ImageFont.LAYOUT_BASIC: - with pytest.raises(KeyError): - t.getmask("абвг", direction="rtl") - with pytest.raises(KeyError): - t.getmask("абвг", features=["-kern"]) - with pytest.raises(KeyError): - t.getmask("абвг", language="sr") - - def test_variation_get(self): - font = self.get_font() - - freetype = parse_version(features.version_module("freetype2")) - if freetype < parse_version("2.9.1"): - with pytest.raises(NotImplementedError): - font.get_variation_names() - with pytest.raises(NotImplementedError): - font.get_variation_axes() - return +def test_variation_set_by_name(font): + freetype = parse_version(features.version_module("freetype2")) + if freetype < parse_version("2.9.1"): + with pytest.raises(NotImplementedError): + font.set_variation_by_name("Bold") + return + + with pytest.raises(OSError): + font.set_variation_by_name("Bold") + + font = ImageFont.truetype("Tests/fonts/AdobeVFPrototype.ttf", 36) + _check_text(font, "Tests/images/variation_adobe.png", 11) + for name in ["Bold", b"Bold"]: + font.set_variation_by_name(name) + assert font.getname()[1] == "Bold" + _check_text(font, "Tests/images/variation_adobe_name.png", 16) + + font = ImageFont.truetype("Tests/fonts/TINY5x3GX.ttf", 36) + _check_text(font, "Tests/images/variation_tiny.png", 40) + for name in ["200", b"200"]: + font.set_variation_by_name(name) + assert font.getname()[1] == "200" + _check_text(font, "Tests/images/variation_tiny_name.png", 40) + + +def test_variation_set_by_axes(font): + freetype = parse_version(features.version_module("freetype2")) + if freetype < parse_version("2.9.1"): + with pytest.raises(NotImplementedError): + font.set_variation_by_axes([100]) + return + + with pytest.raises(OSError): + font.set_variation_by_axes([500, 50]) - with pytest.raises(OSError): - font.get_variation_names() - with pytest.raises(OSError): - font.get_variation_axes() + font = ImageFont.truetype("Tests/fonts/AdobeVFPrototype.ttf", 36) + font.set_variation_by_axes([500, 50]) + _check_text(font, "Tests/images/variation_adobe_axes.png", 11.05) - font = ImageFont.truetype("Tests/fonts/AdobeVFPrototype.ttf") - assert font.get_variation_names(), [ - b"ExtraLight", - b"Light", - b"Regular", - b"Semibold", - b"Bold", - b"Black", - b"Black Medium Contrast", - b"Black High Contrast", - b"Default", - ] - assert font.get_variation_axes() == [ - {"name": b"Weight", "minimum": 200, "maximum": 900, "default": 389}, - {"name": b"Contrast", "minimum": 0, "maximum": 100, "default": 0}, - ] - - font = ImageFont.truetype("Tests/fonts/TINY5x3GX.ttf") - assert font.get_variation_names() == [ - b"20", - b"40", - b"60", - b"80", - b"100", - b"120", - b"140", - b"160", - b"180", - b"200", - b"220", - b"240", - b"260", - b"280", - b"300", - b"Regular", - ] - assert font.get_variation_axes() == [ - {"name": b"Size", "minimum": 0, "maximum": 300, "default": 0} - ] - - def _check_text(self, font, path, epsilon): - im = Image.new("RGB", (100, 75), "white") - d = ImageDraw.Draw(im) - d.text((10, 10), "Text", font=font, fill="black") + font = ImageFont.truetype("Tests/fonts/TINY5x3GX.ttf", 36) + font.set_variation_by_axes([100]) + _check_text(font, "Tests/images/variation_tiny_axes.png", 32.5) - try: - assert_image_similar_tofile(im, path, epsilon) - except AssertionError: - if "_adobe" in path: - path = path.replace("_adobe", "_adobe_older_harfbuzz") - assert_image_similar_tofile(im, path, epsilon) - else: - raise - - def test_variation_set_by_name(self): - font = self.get_font() - - freetype = parse_version(features.version_module("freetype2")) - if freetype < parse_version("2.9.1"): - with pytest.raises(NotImplementedError): - font.set_variation_by_name("Bold") - return - with pytest.raises(OSError): - font.set_variation_by_name("Bold") +def test_textbbox_non_freetypefont(): + im = Image.new("RGB", (200, 200)) + d = ImageDraw.Draw(im) + default_font = ImageFont.load_default() + 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) - font = ImageFont.truetype("Tests/fonts/AdobeVFPrototype.ttf", 36) - self._check_text(font, "Tests/images/variation_adobe.png", 11) - for name in ["Bold", b"Bold"]: - font.set_variation_by_name(name) - self._check_text(font, "Tests/images/variation_adobe_name.png", 11) - font = ImageFont.truetype("Tests/fonts/TINY5x3GX.ttf", 36) - self._check_text(font, "Tests/images/variation_tiny.png", 40) - for name in ["200", b"200"]: - font.set_variation_by_name(name) - self._check_text(font, "Tests/images/variation_tiny_name.png", 40) +@pytest.mark.parametrize( + "anchor, left, top", + ( + # test horizontal anchors + ("ls", 0, -36), + ("ms", -64, -36), + ("rs", -128, -36), + # test vertical anchors + ("ma", -64, 16), + ("mt", -64, 0), + ("mm", -64, -17), + ("mb", -64, -44), + ("md", -64, -51), + ), + ids=("ls", "ms", "rs", "ma", "mt", "mm", "mb", "md"), +) +def test_anchor(layout_engine, anchor, left, top): + name, text = "quick", "Quick" + path = f"Tests/images/test_anchor_{name}_{anchor}.png" - def test_variation_set_by_axes(self): - font = self.get_font() + if layout_engine == ImageFont.Layout.RAQM: + width, height = (129, 44) + else: + width, height = (128, 44) - freetype = parse_version(features.version_module("freetype2")) - if freetype < parse_version("2.9.1"): - with pytest.raises(NotImplementedError): - font.set_variation_by_axes([100]) - return + bbox_expected = (left, top, left + width, top + height) - with pytest.raises(OSError): - font.set_variation_by_axes([500, 50]) + f = ImageFont.truetype( + "Tests/fonts/NotoSans-Regular.ttf", 48, layout_engine=layout_engine + ) - font = ImageFont.truetype("Tests/fonts/AdobeVFPrototype.ttf", 36) - font.set_variation_by_axes([500, 50]) - self._check_text(font, "Tests/images/variation_adobe_axes.png", 11.05) + im = Image.new("RGB", (200, 200), "white") + d = ImageDraw.Draw(im) + d.line(((0, 100), (200, 100)), "gray") + d.line(((100, 0), (100, 200)), "gray") + d.text((100, 100), text, fill="black", anchor=anchor, font=f) - font = ImageFont.truetype("Tests/fonts/TINY5x3GX.ttf", 36) - font.set_variation_by_axes([100]) - self._check_text(font, "Tests/images/variation_tiny_axes.png", 32.5) + assert d.textbbox((0, 0), text, f, anchor=anchor) == bbox_expected - def test_textbbox_non_freetypefont(self): - 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) - - @pytest.mark.parametrize( - "anchor, left, top", - ( - # test horizontal anchors - ("ls", 0, -36), - ("ms", -64, -36), - ("rs", -128, -36), - # test vertical anchors - ("ma", -64, 16), - ("mt", -64, 0), - ("mm", -64, -17), - ("mb", -64, -44), - ("md", -64, -51), - ), - ids=("ls", "ms", "rs", "ma", "mt", "mm", "mb", "md"), + assert_image_similar_tofile(im, path, 7) + + +@pytest.mark.parametrize( + "anchor, align", + ( + # test horizontal anchors + ("lm", "left"), + ("lm", "center"), + ("lm", "right"), + ("mm", "left"), + ("mm", "center"), + ("mm", "right"), + ("rm", "left"), + ("rm", "center"), + ("rm", "right"), + # test vertical anchors + ("ma", "center"), + # ("mm", "center"), # duplicate + ("md", "center"), + ), +) +def test_anchor_multiline(layout_engine, anchor, align): + target = f"Tests/images/test_anchor_multiline_{anchor}_{align}.png" + text = "a\nlong\ntext sample" + + f = ImageFont.truetype( + "Tests/fonts/NotoSans-Regular.ttf", 48, layout_engine=layout_engine ) - def test_anchor(self, anchor, left, top): - name, text = "quick", "Quick" - path = f"Tests/images/test_anchor_{name}_{anchor}.png" - if self.LAYOUT_ENGINE == ImageFont.LAYOUT_RAQM: - width, height = (129, 44) - else: - width, height = (128, 44) + # test render + im = Image.new("RGB", (600, 400), "white") + d = ImageDraw.Draw(im) + d.line(((0, 200), (600, 200)), "gray") + d.line(((300, 0), (300, 400)), "gray") + d.multiline_text((300, 200), text, fill="black", anchor=anchor, font=f, align=align) + + assert_image_similar_tofile(im, target, 4) + - bbox_expected = (left, top, left + width, top + height) +def test_anchor_invalid(font): + im = Image.new("RGB", (100, 100), "white") + d = ImageDraw.Draw(im) + d.font = font - f = ImageFont.truetype( - "Tests/fonts/NotoSans-Regular.ttf", 48, layout_engine=self.LAYOUT_ENGINE + for anchor in ["", "l", "a", "lax", "sa", "xa", "lx"]: + pytest.raises(ValueError, lambda: font.getmask2("hello", anchor=anchor)) + pytest.raises(ValueError, lambda: font.getbbox("hello", anchor=anchor)) + pytest.raises(ValueError, lambda: d.text((0, 0), "hello", anchor=anchor)) + pytest.raises(ValueError, lambda: d.textbbox((0, 0), "hello", anchor=anchor)) + pytest.raises( + ValueError, lambda: d.multiline_text((0, 0), "foo\nbar", anchor=anchor) + ) + pytest.raises( + ValueError, + lambda: d.multiline_textbbox((0, 0), "foo\nbar", anchor=anchor), + ) + for anchor in ["lt", "lb"]: + pytest.raises( + ValueError, lambda: d.multiline_text((0, 0), "foo\nbar", anchor=anchor) + ) + pytest.raises( + ValueError, + lambda: d.multiline_textbbox((0, 0), "foo\nbar", anchor=anchor), ) - im = Image.new("RGB", (200, 200), "white") - d = ImageDraw.Draw(im) - d.line(((0, 100), (200, 100)), "gray") - d.line(((100, 0), (100, 200)), "gray") - d.text((100, 100), text, fill="black", anchor=anchor, font=f) - - assert d.textbbox((0, 0), text, f, anchor=anchor) == bbox_expected - - assert_image_similar_tofile(im, path, 7) - - @pytest.mark.parametrize( - "anchor, align", - ( - # test horizontal anchors - ("lm", "left"), - ("lm", "center"), - ("lm", "right"), - ("mm", "left"), - ("mm", "center"), - ("mm", "right"), - ("rm", "left"), - ("rm", "center"), - ("rm", "right"), - # test vertical anchors - ("ma", "center"), - # ("mm", "center"), # duplicate - ("md", "center"), - ), + +@pytest.mark.parametrize("bpp", (1, 2, 4, 8)) +def test_bitmap_font(layout_engine, bpp): + text = "Bitmap Font" + layout_name = ["basic", "raqm"][layout_engine] + target = f"Tests/images/bitmap_font_{bpp}_{layout_name}.png" + font = ImageFont.truetype( + f"Tests/fonts/DejaVuSans/DejaVuSans-24-{bpp}-stripped.ttf", + 24, + layout_engine=layout_engine, ) - def test_anchor_multiline(self, anchor, align): - target = f"Tests/images/test_anchor_multiline_{anchor}_{align}.png" - text = "a\nlong\ntext sample" - f = ImageFont.truetype( - "Tests/fonts/NotoSans-Regular.ttf", 48, layout_engine=self.LAYOUT_ENGINE - ) + im = Image.new("RGB", (160, 35), "white") + draw = ImageDraw.Draw(im) + draw.text((2, 2), text, "black", font) - # test render - im = Image.new("RGB", (600, 400), "white") - d = ImageDraw.Draw(im) - d.line(((0, 200), (600, 200)), "gray") - d.line(((300, 0), (300, 400)), "gray") - d.multiline_text( - (300, 200), text, fill="black", anchor=anchor, font=f, align=align - ) + assert_image_equal_tofile(im, target) - assert_image_similar_tofile(im, target, 4) - def test_anchor_invalid(self): - font = self.get_font() - im = Image.new("RGB", (100, 100), "white") - d = ImageDraw.Draw(im) - d.font = font - - for anchor in ["", "l", "a", "lax", "sa", "xa", "lx"]: - pytest.raises(ValueError, lambda: font.getmask2("hello", anchor=anchor)) - pytest.raises(ValueError, lambda: font.getbbox("hello", anchor=anchor)) - pytest.raises(ValueError, lambda: d.text((0, 0), "hello", anchor=anchor)) - pytest.raises( - ValueError, lambda: d.textbbox((0, 0), "hello", anchor=anchor) - ) - pytest.raises( - ValueError, lambda: d.multiline_text((0, 0), "foo\nbar", anchor=anchor) - ) - pytest.raises( - ValueError, - lambda: d.multiline_textbbox((0, 0), "foo\nbar", anchor=anchor), - ) - for anchor in ["lt", "lb"]: - pytest.raises( - ValueError, lambda: d.multiline_text((0, 0), "foo\nbar", anchor=anchor) - ) - pytest.raises( - ValueError, - lambda: d.multiline_textbbox((0, 0), "foo\nbar", anchor=anchor), +def test_bitmap_font_stroke(layout_engine): + text = "Bitmap Font" + layout_name = ["basic", "raqm"][layout_engine] + target = f"Tests/images/bitmap_font_stroke_{layout_name}.png" + font = ImageFont.truetype( + "Tests/fonts/DejaVuSans/DejaVuSans-24-8-stripped.ttf", + 24, + layout_engine=layout_engine, + ) + + im = Image.new("RGB", (160, 35), "white") + draw = ImageDraw.Draw(im) + draw.text((2, 2), text, "black", font, stroke_width=2, stroke_fill="red") + + assert_image_similar_tofile(im, target, 0.03) + + +def test_standard_embedded_color(layout_engine): + txt = "Hello World!" + ttf = ImageFont.truetype(FONT_PATH, 40, layout_engine=layout_engine) + ttf.getbbox(txt) + + im = Image.new("RGB", (300, 64), "white") + d = ImageDraw.Draw(im) + d.text((10, 10), txt, font=ttf, fill="#fa6", embedded_color=True) + + assert_image_similar_tofile(im, "Tests/images/standard_embedded.png", 3.1) + + +@pytest.mark.parametrize("fontmode", ("1", "L", "RGBA")) +def test_float_coord(layout_engine, fontmode): + txt = "Hello World!" + ttf = ImageFont.truetype(FONT_PATH, 40, layout_engine=layout_engine) + + im = Image.new("RGB", (300, 64), "white") + d = ImageDraw.Draw(im) + if fontmode == "1": + d.fontmode = "1" + + embedded_color = fontmode == "RGBA" + d.text((9.5, 9.5), txt, font=ttf, fill="#fa6", embedded_color=embedded_color) + try: + assert_image_similar_tofile(im, "Tests/images/text_float_coord.png", 3.9) + except AssertionError: + if fontmode == "1" and layout_engine == ImageFont.Layout.BASIC: + assert_image_similar_tofile( + im, "Tests/images/text_float_coord_1_alt.png", 1 ) + else: + raise - @skip_unless_feature("freetype2") - @pytest.mark.parametrize("bpp", (1, 2, 4, 8)) - def test_bitmap_font(self, bpp): - text = "Bitmap Font" - layout_name = ["basic", "raqm"][self.LAYOUT_ENGINE] - target = f"Tests/images/bitmap_font_{bpp}_{layout_name}.png" + +def test_cbdt(layout_engine): + try: font = ImageFont.truetype( - f"Tests/fonts/DejaVuSans/DejaVuSans-24-{bpp}-stripped.ttf", - 24, - layout_engine=self.LAYOUT_ENGINE, + "Tests/fonts/NotoColorEmoji.ttf", size=109, layout_engine=layout_engine ) - im = Image.new("RGB", (160, 35), "white") - draw = ImageDraw.Draw(im) - draw.text((2, 2), text, "black", font) + im = Image.new("RGB", (150, 150), "white") + d = ImageDraw.Draw(im) + + d.text((10, 10), "\U0001f469", font=font, embedded_color=True) - assert_image_equal_tofile(im, target) + assert_image_similar_tofile(im, "Tests/images/cbdt_notocoloremoji.png", 6.2) + except OSError as e: # pragma: no cover + assert str(e) in ("unimplemented feature", "unknown file format") + pytest.skip("freetype compiled without libpng or CBDT support") - def test_bitmap_font_stroke(self): - text = "Bitmap Font" - layout_name = ["basic", "raqm"][self.LAYOUT_ENGINE] - target = f"Tests/images/bitmap_font_stroke_{layout_name}.png" + +def test_cbdt_mask(layout_engine): + try: font = ImageFont.truetype( - "Tests/fonts/DejaVuSans/DejaVuSans-24-8-stripped.ttf", - 24, - layout_engine=self.LAYOUT_ENGINE, + "Tests/fonts/NotoColorEmoji.ttf", size=109, layout_engine=layout_engine ) - im = Image.new("RGB", (160, 35), "white") - draw = ImageDraw.Draw(im) - draw.text((2, 2), text, "black", font, stroke_width=2, stroke_fill="red") + im = Image.new("RGB", (150, 150), "white") + d = ImageDraw.Draw(im) - assert_image_similar_tofile(im, target, 0.03) + d.text((10, 10), "\U0001f469", "black", font=font) - def test_standard_embedded_color(self): - txt = "Hello World!" - ttf = ImageFont.truetype(FONT_PATH, 40, layout_engine=self.LAYOUT_ENGINE) - ttf.getsize(txt) + assert_image_similar_tofile( + im, "Tests/images/cbdt_notocoloremoji_mask.png", 6.2 + ) + except OSError as e: # pragma: no cover + assert str(e) in ("unimplemented feature", "unknown file format") + pytest.skip("freetype compiled without libpng or CBDT support") - im = Image.new("RGB", (300, 64), "white") - d = ImageDraw.Draw(im) - d.text((10, 10), txt, font=ttf, fill="#fa6", embedded_color=True) - assert_image_similar_tofile(im, "Tests/images/standard_embedded.png", 6.2) +def test_sbix(layout_engine): + try: + font = ImageFont.truetype( + "Tests/fonts/chromacheck-sbix.woff", size=300, layout_engine=layout_engine + ) - def test_cbdt(self): - try: - font = ImageFont.truetype( - "Tests/fonts/NotoColorEmoji.ttf", - size=109, - layout_engine=self.LAYOUT_ENGINE, - ) + im = Image.new("RGB", (400, 400), "white") + d = ImageDraw.Draw(im) - im = Image.new("RGB", (150, 150), "white") - d = ImageDraw.Draw(im) + d.text((50, 50), "\uE901", font=font, embedded_color=True) - d.text((10, 10), "\U0001f469", font=font, embedded_color=True) + assert_image_similar_tofile(im, "Tests/images/chromacheck-sbix.png", 1) + except OSError as e: # pragma: no cover + assert str(e) in ("unimplemented feature", "unknown file format") + pytest.skip("freetype compiled without libpng or SBIX support") - assert_image_similar_tofile(im, "Tests/images/cbdt_notocoloremoji.png", 6.2) - except OSError as e: # pragma: no cover - assert str(e) in ("unimplemented feature", "unknown file format") - pytest.skip("freetype compiled without libpng or CBDT support") - def test_cbdt_mask(self): - try: - font = ImageFont.truetype( - "Tests/fonts/NotoColorEmoji.ttf", - size=109, - layout_engine=self.LAYOUT_ENGINE, - ) +def test_sbix_mask(layout_engine): + try: + font = ImageFont.truetype( + "Tests/fonts/chromacheck-sbix.woff", size=300, layout_engine=layout_engine + ) - im = Image.new("RGB", (150, 150), "white") - d = ImageDraw.Draw(im) + im = Image.new("RGB", (400, 400), "white") + d = ImageDraw.Draw(im) - d.text((10, 10), "\U0001f469", "black", font=font) + d.text((50, 50), "\uE901", (100, 0, 0), font=font) - assert_image_similar_tofile( - im, "Tests/images/cbdt_notocoloremoji_mask.png", 6.2 - ) - except OSError as e: # pragma: no cover - assert str(e) in ("unimplemented feature", "unknown file format") - pytest.skip("freetype compiled without libpng or CBDT support") - - def test_sbix(self): - try: - font = ImageFont.truetype( - "Tests/fonts/chromacheck-sbix.woff", - size=300, - layout_engine=self.LAYOUT_ENGINE, - ) + assert_image_similar_tofile(im, "Tests/images/chromacheck-sbix_mask.png", 1) + except OSError as e: # pragma: no cover + assert str(e) in ("unimplemented feature", "unknown file format") + pytest.skip("freetype compiled without libpng or SBIX support") - im = Image.new("RGB", (400, 400), "white") - d = ImageDraw.Draw(im) - d.text((50, 50), "\uE901", font=font, embedded_color=True) +@skip_unless_feature_version("freetype2", "2.10.0") +def test_colr(layout_engine): + font = ImageFont.truetype( + "Tests/fonts/BungeeColor-Regular_colr_Windows.ttf", + size=64, + layout_engine=layout_engine, + ) - assert_image_similar_tofile(im, "Tests/images/chromacheck-sbix.png", 1) - except OSError as e: # pragma: no cover - assert str(e) in ("unimplemented feature", "unknown file format") - pytest.skip("freetype compiled without libpng or SBIX support") + im = Image.new("RGB", (300, 75), "white") + d = ImageDraw.Draw(im) - def test_sbix_mask(self): - try: - font = ImageFont.truetype( - "Tests/fonts/chromacheck-sbix.woff", - size=300, - layout_engine=self.LAYOUT_ENGINE, - ) + d.text((15, 5), "Bungee", font=font, embedded_color=True) - im = Image.new("RGB", (400, 400), "white") - d = ImageDraw.Draw(im) + assert_image_similar_tofile(im, "Tests/images/colr_bungee.png", 21) - d.text((50, 50), "\uE901", (100, 0, 0), font=font) - assert_image_similar_tofile(im, "Tests/images/chromacheck-sbix_mask.png", 1) - except OSError as e: # pragma: no cover - assert str(e) in ("unimplemented feature", "unknown file format") - pytest.skip("freetype compiled without libpng or SBIX support") +@skip_unless_feature_version("freetype2", "2.10.0") +def test_colr_mask(layout_engine): + font = ImageFont.truetype( + "Tests/fonts/BungeeColor-Regular_colr_Windows.ttf", + size=64, + layout_engine=layout_engine, + ) - @skip_unless_feature_version("freetype2", "2.10.0") - def test_colr(self): - font = ImageFont.truetype( - "Tests/fonts/BungeeColor-Regular_colr_Windows.ttf", - size=64, - layout_engine=self.LAYOUT_ENGINE, - ) + im = Image.new("RGB", (300, 75), "white") + d = ImageDraw.Draw(im) - im = Image.new("RGB", (300, 75), "white") - d = ImageDraw.Draw(im) + d.text((15, 5), "Bungee", "black", font=font) - d.text((15, 5), "Bungee", font=font, embedded_color=True) + assert_image_similar_tofile(im, "Tests/images/colr_bungee_mask.png", 22) - assert_image_similar_tofile(im, "Tests/images/colr_bungee.png", 21) - @skip_unless_feature_version("freetype2", "2.10.0") - def test_colr_mask(self): +def test_woff2(layout_engine): + try: font = ImageFont.truetype( - "Tests/fonts/BungeeColor-Regular_colr_Windows.ttf", + "Tests/fonts/OpenSans.woff2", size=64, - layout_engine=self.LAYOUT_ENGINE, + layout_engine=layout_engine, ) + except OSError as e: + assert str(e) in ("unimplemented feature", "unknown file format") + pytest.skip("FreeType compiled without brotli or WOFF2 support") - im = Image.new("RGB", (300, 75), "white") - d = ImageDraw.Draw(im) + im = Image.new("RGB", (350, 100), "white") + d = ImageDraw.Draw(im) - d.text((15, 5), "Bungee", "black", font=font) + d.text((15, 5), "OpenSans", "black", font=font) - assert_image_similar_tofile(im, "Tests/images/colr_bungee_mask.png", 22) + assert_image_similar_tofile(im, "Tests/images/test_woff2.png", 5) -@skip_unless_feature("raqm") -class TestImageFont_RaqmLayout(TestImageFont): - LAYOUT_ENGINE = ImageFont.LAYOUT_RAQM +def test_fill_deprecation(font): + with pytest.warns(DeprecationWarning): + font.getmask2("Hello world", fill=Image.core.fill) + with pytest.warns(DeprecationWarning): + with pytest.raises(TypeError): + font.getmask2("Hello world", fill=None) def test_render_mono_size(): @@ -1004,7 +1100,7 @@ def test_render_mono_size(): ttf = ImageFont.truetype( "Tests/fonts/DejaVuSans/DejaVuSans.ttf", 18, - layout_engine=ImageFont.LAYOUT_BASIC, + layout_engine=ImageFont.Layout.BASIC, ) draw.text((10, 10), "r" * 10, "black", ttf) @@ -1022,3 +1118,25 @@ def test_oom(test_file): font = ImageFont.truetype(BytesIO(f.read())) with pytest.raises(Image.DecompressionBombError): font.getmask("Test Text") + + +def test_raqm_missing_warning(monkeypatch): + monkeypatch.setattr(ImageFont.core, "HAVE_RAQM", False) + with pytest.warns(UserWarning) as record: + font = ImageFont.truetype( + FONT_PATH, FONT_SIZE, layout_engine=ImageFont.Layout.RAQM + ) + assert font.layout_engine == ImageFont.Layout.BASIC + assert str(record[-1].message) == ( + "Raqm layout was requested, but Raqm is not available. " + "Falling back to basic layout." + ) + + +def test_constants_deprecation(): + for enum, prefix in { + ImageFont.Layout: "LAYOUT_", + }.items(): + for name in enum.__members__: + with pytest.warns(DeprecationWarning): + assert getattr(ImageFont, prefix + name) == enum[name] diff --git a/Tests/test_imagefontctl.py b/Tests/test_imagefontctl.py index ffb70cf1799..cf039e86e61 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_imagegrab.py b/Tests/test_imagegrab.py index fa2291582d4..317db4c0120 100644 --- a/Tests/test_imagegrab.py +++ b/Tests/test_imagegrab.py @@ -1,4 +1,5 @@ import os +import shutil import subprocess import sys @@ -33,7 +34,9 @@ def test_grab_x11(self): @pytest.mark.skipif(Image.core.HAVE_XCB, reason="tests missing XCB") def test_grab_no_xcb(self): - if sys.platform not in ("win32", "darwin"): + if sys.platform not in ("win32", "darwin") and not shutil.which( + "gnome-screenshot" + ): with pytest.raises(OSError) as e: ImageGrab.grab() assert str(e.value).startswith("Pillow was built without XCB support") @@ -61,9 +64,13 @@ def test_grabclipboard(self): ) p.communicate() else: - with pytest.raises(NotImplementedError) as e: - ImageGrab.grabclipboard() - assert str(e.value) == "ImageGrab.grabclipboard() is macOS and Windows only" + if not shutil.which("wl-paste"): + with pytest.raises( + NotImplementedError, + match="wl-paste or xclip is required for" + r" ImageGrab.grabclipboard\(\) on Linux", + ): + ImageGrab.grabclipboard() return ImageGrab.grabclipboard() diff --git a/Tests/test_imagemath.py b/Tests/test_imagemath.py index 25811aa89d7..fe7ac9a7a93 100644 --- a/Tests/test_imagemath.py +++ b/Tests/test_imagemath.py @@ -6,10 +6,8 @@ def pixel(im): if hasattr(im, "im"): return f"{im.mode} {repr(im.getpixel((0, 0)))}" - else: - if isinstance(im, int): - return int(im) # hack to deal with booleans - print(im) + if isinstance(im, int): + return int(im) # hack to deal with booleans A = Image.new("L", (1, 1), 1) @@ -52,9 +50,17 @@ def test_ops(): assert pixel(ImageMath.eval("float(B)**33", images)) == "F 8589934592.0" -def test_prevent_exec(): +@pytest.mark.parametrize( + "expression", + ( + "exec('pass')", + "(lambda: exec('pass'))()", + "(lambda: (lambda: exec('pass'))())()", + ), +) +def test_prevent_exec(expression): with pytest.raises(ValueError): - ImageMath.eval("exec('pass')") + ImageMath.eval(expression) def test_logical(): diff --git a/Tests/test_imagemorph.py b/Tests/test_imagemorph.py index 368c2bba140..29c71f917c4 100644 --- a/Tests/test_imagemorph.py +++ b/Tests/test_imagemorph.py @@ -48,12 +48,8 @@ def img_string_normalize(im): return img_to_string(string_to_img(im)) -def assert_img_equal(A, B): - assert img_to_string(A) == img_to_string(B) - - -def assert_img_equal_img_string(A, Bstring): - assert img_to_string(A) == img_string_normalize(Bstring) +def assert_img_equal_img_string(a, b_string): + assert img_to_string(a) == img_string_normalize(b_string) def test_str_to_img(): @@ -69,14 +65,16 @@ def create_lut(): # create_lut() -def test_lut(): - for op in ("corner", "dilation4", "dilation8", "erosion4", "erosion8", "edge"): - lb = ImageMorph.LutBuilder(op_name=op) - assert lb.get_lut() is None +@pytest.mark.parametrize( + "op", ("corner", "dilation4", "dilation8", "erosion4", "erosion8", "edge") +) +def test_lut(op): + lb = ImageMorph.LutBuilder(op_name=op) + assert lb.get_lut() is None - lut = lb.build_lut() - with open(f"Tests/images/{op}.lut", "rb") as f: - assert lut == bytearray(f.read()) + lut = lb.build_lut() + with open(f"Tests/images/{op}.lut", "rb") as f: + assert lut == bytearray(f.read()) def test_no_operator_loaded(): diff --git a/Tests/test_imageops.py b/Tests/test_imageops.py index 6aa1cf35edf..c9b2fd865b8 100644 --- a/Tests/test_imageops.py +++ b/Tests/test_imageops.py @@ -63,6 +63,7 @@ def test_sanity(): ImageOps.grayscale(hopper("L")) ImageOps.grayscale(hopper("RGB")) + ImageOps.invert(hopper("1")) ImageOps.invert(hopper("L")) ImageOps.invert(hopper("RGB")) @@ -109,6 +110,16 @@ def test_contain(new_size): assert new_im.size == (256, 256) +def test_contain_round(): + im = Image.new("1", (43, 63), 1) + new_im = ImageOps.contain(im, (5, 7)) + assert new_im.width == 5 + + im = Image.new("1", (63, 43), 1) + new_im = ImageOps.contain(im, (7, 5)) + assert new_im.height == 5 + + def test_pad(): # Same ratio im = hopper() @@ -129,6 +140,30 @@ def test_pad(): ) +def test_pad_round(): + im = Image.new("1", (1, 1), 1) + new_im = ImageOps.pad(im, (4, 1)) + assert new_im.load()[2, 0] == 1 + + new_im = ImageOps.pad(im, (1, 4)) + assert new_im.load()[0, 2] == 1 + + +@pytest.mark.parametrize("mode", ("P", "PA")) +def test_palette(mode): + im = hopper(mode) + + # Expand + expanded_im = ImageOps.expand(im) + assert_image_equal(im.convert("RGB"), expanded_im.convert("RGB")) + + # Pad + padded_im = ImageOps.pad(im, (256, 128), centering=(0, 0)) + assert_image_equal( + im.convert("RGB"), padded_im.convert("RGB").crop((0, 0, 128, 128)) + ) + + def test_pil163(): # Division by zero in equalize if < 255 pixels in image (@PIL163) @@ -344,11 +379,15 @@ def check(orientation_im): 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_imagepalette.py b/Tests/test_imagepalette.py index 475d249ed09..5bda2811717 100644 --- a/Tests/test_imagepalette.py +++ b/Tests/test_imagepalette.py @@ -50,6 +50,16 @@ def test_getcolor(): palette.getcolor("unknown") +def test_getcolor_rgba_color_rgb_palette(): + palette = ImagePalette.ImagePalette("RGB") + + # Opaque RGBA colors are converted + assert palette.getcolor((0, 0, 0, 255)) == palette.getcolor((0, 0, 0)) + + with pytest.raises(ValueError): + palette.getcolor((0, 0, 0, 128)) + + @pytest.mark.parametrize( "index, palette", [ diff --git a/Tests/test_imagepath.py b/Tests/test_imagepath.py index b18271cc5a1..de3920cf5eb 100644 --- a/Tests/test_imagepath.py +++ b/Tests/test_imagepath.py @@ -70,9 +70,11 @@ def test_invalid_coords(): coords = ["a", "b"] # Act / Assert - with pytest.raises(SystemError): + with pytest.raises(ValueError) as e: ImagePath.Path(coords) + assert str(e.value) == "incorrect coordinate type" + def test_path_odd_number_of_coordinates(): # Arrange @@ -172,7 +174,7 @@ def test_overflow_segfault(): # through to the sequence. Seeing this on 32-bit Windows. with pytest.raises((TypeError, MemoryError)): # post patch, this fails with a memory error - x = evil() + x = Evil() # This fails due to the invalid malloc above, # and segfaults @@ -180,7 +182,7 @@ def test_overflow_segfault(): x[i] = b"0" * 16 -class evil: +class Evil: def __init__(self): self.corrupt = Image.core.path(0x4000000000000000) diff --git a/Tests/test_imageqt.py b/Tests/test_imageqt.py index 589cb5a210a..2f2b0791853 100644 --- a/Tests/test_imageqt.py +++ b/Tests/test_imageqt.py @@ -1,9 +1,14 @@ -import pytest +import warnings -from PIL import ImageQt +import pytest from .helper import assert_image_similar, hopper +with warnings.catch_warnings() as w: + warnings.simplefilter("ignore", category=DeprecationWarning) + from PIL import ImageQt + + pytestmark = pytest.mark.skipif( not ImageQt.qt_is_installed, reason="Qt bindings are not installed" ) @@ -30,10 +35,10 @@ def test_rgb(): def checkrgb(r, g, b): val = ImageQt.rgb(r, g, b) - val = val % 2 ** 24 # drop the alpha + val = val % 2**24 # drop the alpha assert val >> 16 == r - assert ((val >> 8) % 2 ** 8) == g - assert val % 2 ** 8 == b + assert ((val >> 8) % 2**8) == g + assert val % 2**8 == b checkrgb(0, 0, 0) checkrgb(255, 0, 0) @@ -56,7 +61,5 @@ def test_image(): def test_closed_file(): - with pytest.warns(None) as record: + with warnings.catch_warnings(): ImageQt.ImageQt("Tests/images/hopper.gif") - - assert not record diff --git a/Tests/test_imagesequence.py b/Tests/test_imagesequence.py index 7cf237b4654..6af7e760204 100644 --- a/Tests/test_imagesequence.py +++ b/Tests/test_imagesequence.py @@ -65,21 +65,21 @@ def test_libtiff(): def test_consecutive(): with Image.open("Tests/images/multipage.tiff") as im: - firstFrame = None + first_frame = None for frame in ImageSequence.Iterator(im): - if firstFrame is None: - firstFrame = frame.copy() + if first_frame is None: + first_frame = frame.copy() for frame in ImageSequence.Iterator(im): - assert_image_equal(frame, firstFrame) + assert_image_equal(frame, first_frame) break def test_palette_mmap(): # Using mmap in ImageFile can require to reload the palette. with Image.open("Tests/images/multipage-mmap.tiff") as im: - color1 = im.getpalette()[0:3] + color1 = im.getpalette()[:3] im.seek(0) - color2 = im.getpalette()[0:3] + color2 = im.getpalette()[:3] assert color1 == color2 diff --git a/Tests/test_imageshow.py b/Tests/test_imageshow.py index 5981e22c012..3e147a9efec 100644 --- a/Tests/test_imageshow.py +++ b/Tests/test_imageshow.py @@ -45,10 +45,20 @@ def show_image(self, image, **options): not on_ci() or is_win32(), reason="Only run on CIs; hangs on Windows CIs", ) -def test_show(): - for mode in ("1", "I;16", "LA", "RGB", "RGBA"): - im = hopper(mode) - assert ImageShow.show(im) +@pytest.mark.parametrize("mode", ("1", "I;16", "LA", "RGB", "RGBA")) +def test_show(mode): + im = hopper(mode) + assert ImageShow.show(im) + + +def test_show_without_viewers(): + viewers = ImageShow._viewers + ImageShow._viewers = [] + + im = hopper() + assert not ImageShow.show(im) + + ImageShow._viewers = viewers def test_viewer(): @@ -60,12 +70,12 @@ def test_viewer(): viewer.get_command(None) -def test_viewers(): - for viewer in ImageShow._viewers: - try: - viewer.get_command("test.jpg") - except NotImplementedError: - pass +@pytest.mark.parametrize("viewer", ImageShow._viewers) +def test_viewers(viewer): + try: + viewer.get_command("test.jpg") + except NotImplementedError: + pass def test_ipythonviewer(): @@ -79,3 +89,20 @@ def test_ipythonviewer(): im = hopper() assert test_viewer.show(im) == 1 + + +@pytest.mark.skipif( + not on_ci() or is_win32(), + reason="Only run on CIs; hangs on Windows CIs", +) +@pytest.mark.parametrize("viewer", ImageShow._viewers) +def test_file_deprecated(tmp_path, viewer): + f = str(tmp_path / "temp.jpg") + hopper().save(f) + with pytest.warns(DeprecationWarning): + try: + viewer.show_file(file=f) + except NotImplementedError: + pass + with pytest.raises(TypeError): + viewer.show_file() diff --git a/Tests/test_imagestat.py b/Tests/test_imagestat.py index 9474ff6f9ba..5717fe15036 100644 --- a/Tests/test_imagestat.py +++ b/Tests/test_imagestat.py @@ -51,8 +51,8 @@ def test_constant(): st = ImageStat.Stat(im) assert st.extrema[0] == (128, 128) - assert st.sum[0] == 128 ** 3 - assert st.sum2[0] == 128 ** 4 + assert st.sum[0] == 128**3 + assert st.sum2[0] == 128**4 assert st.mean[0] == 128 assert st.median[0] == 128 assert st.rms[0] == 128 diff --git a/Tests/test_imagetk.py b/Tests/test_imagetk.py index 928b8cbd188..995d0ee1f38 100644 --- a/Tests/test_imagetk.py +++ b/Tests/test_imagetk.py @@ -26,6 +26,8 @@ def setup_module(): # setup tk tk.Frame() # root = tk.Tk() + except RuntimeError as v: + pytest.skip(f"RuntimeError: {v}") except tk.TclError as v: pytest.skip(f"TCL Error: {v}") @@ -52,31 +54,46 @@ def test_kw(): assert im is None -def test_photoimage(): - for mode in TK_MODES: - # test as image: - im = hopper(mode) +@pytest.mark.parametrize("mode", TK_MODES) +def test_photoimage(mode): + # test as image: + im = hopper(mode) - # this should not crash - im_tk = ImageTk.PhotoImage(im) + # this should not crash + im_tk = ImageTk.PhotoImage(im) + + assert im_tk.width() == im.width + assert im_tk.height() == im.height - assert im_tk.width() == im.width - assert im_tk.height() == im.height + reloaded = ImageTk.getimage(im_tk) + assert_image_equal(reloaded, im.convert("RGBA")) + +def test_photoimage_apply_transparency(): + with Image.open("Tests/images/pil123p.png") as im: + im_tk = ImageTk.PhotoImage(im) reloaded = ImageTk.getimage(im_tk) assert_image_equal(reloaded, im.convert("RGBA")) -def test_photoimage_blank(): +@pytest.mark.parametrize("mode", TK_MODES) +def test_photoimage_blank(mode): # test a image using mode/size: - for mode in TK_MODES: - im_tk = ImageTk.PhotoImage(mode, (100, 100)) + im_tk = ImageTk.PhotoImage(mode, (100, 100)) + + assert im_tk.width() == 100 + assert im_tk.height() == 100 + + im = Image.new(mode, (100, 100)) + reloaded = ImageTk.getimage(im_tk) + assert_image_equal(reloaded.convert(mode), im) - assert im_tk.width() == 100 - assert im_tk.height() == 100 - # reloaded = ImageTk.getimage(im_tk) - # assert_image_equal(reloaded, im) +def test_box_deprecation(): + im = hopper() + im_tk = ImageTk.PhotoImage(im) + with pytest.warns(DeprecationWarning): + im_tk.paste(im, (0, 0, 128, 128)) def test_bitmapimage(): diff --git a/Tests/test_imagewin_pointers.py b/Tests/test_imagewin_pointers.py index c51a66089c8..df130565575 100644 --- a/Tests/test_imagewin_pointers.py +++ b/Tests/test_imagewin_pointers.py @@ -1,4 +1,3 @@ -import ctypes from io import BytesIO from PIL import Image, ImageWin @@ -8,6 +7,7 @@ # see https://github.com/python-pillow/Pillow/pull/1431#issuecomment-144692652 if is_win32(): + import ctypes import ctypes.wintypes class BITMAPFILEHEADER(ctypes.Structure): diff --git a/Tests/test_lib_pack.py b/Tests/test_lib_pack.py index af7eae935f6..979806cae99 100644 --- a/Tests/test_lib_pack.py +++ b/Tests/test_lib_pack.py @@ -444,6 +444,8 @@ def test_RGBA(self): self.assert_unpack("RGBA", "RGBA;4B", 2, (17, 0, 34, 0), (51, 0, 68, 0)) self.assert_unpack("RGBA", "RGBA;16L", 8, (2, 4, 6, 8), (10, 12, 14, 16)) self.assert_unpack("RGBA", "RGBA;16B", 8, (1, 3, 5, 7), (9, 11, 13, 15)) + self.assert_unpack("RGBA", "BGRA;16L", 8, (6, 4, 2, 8), (14, 12, 10, 16)) + self.assert_unpack("RGBA", "BGRA;16B", 8, (5, 3, 1, 7), (13, 11, 9, 15)) self.assert_unpack( "RGBA", "BGRA", 4, (3, 2, 1, 4), (7, 6, 5, 8), (11, 10, 9, 12) ) diff --git a/Tests/test_map.py b/Tests/test_map.py index 42f3447ebfd..d816bddaf3d 100644 --- a/Tests/test_map.py +++ b/Tests/test_map.py @@ -36,7 +36,7 @@ def test_tobytes(): Image.MAX_IMAGE_PIXELS = max_pixels -@pytest.mark.skipif(sys.maxsize <= 2 ** 32, reason="Requires 64-bit system") +@pytest.mark.skipif(sys.maxsize <= 2**32, reason="Requires 64-bit system") def test_ysize(): numpy = pytest.importorskip("numpy", reason="NumPy not installed") diff --git a/Tests/test_mode_i16.py b/Tests/test_mode_i16.py index 0571aabf495..efcdab9ec43 100644 --- a/Tests/test_mode_i16.py +++ b/Tests/test_mode_i16.py @@ -1,3 +1,5 @@ +import pytest + from PIL import Image from .helper import hopper @@ -20,65 +22,56 @@ def verify(im1): ), f"got {repr(p1)} from mode {im1.mode} at {xy}, expected {repr(p2)}" -def test_basic(tmp_path): +@pytest.mark.parametrize("mode", ("L", "I;16", "I;16B", "I;16L", "I")) +def test_basic(tmp_path, mode): # PIL 1.1 has limited support for 16-bit image data. Check that # create/copy/transform and save works as expected. - def basic(mode): - - imIn = original.convert(mode) - verify(imIn) - - w, h = imIn.size - - imOut = imIn.copy() - verify(imOut) # copy - - imOut = imIn.transform((w, h), Image.EXTENT, (0, 0, w, h)) - verify(imOut) # transform + im_in = original.convert(mode) + verify(im_in) - filename = str(tmp_path / "temp.im") - imIn.save(filename) + w, h = im_in.size - with Image.open(filename) as imOut: + im_out = im_in.copy() + verify(im_out) # copy - verify(imIn) - verify(imOut) + im_out = im_in.transform((w, h), Image.Transform.EXTENT, (0, 0, w, h)) + verify(im_out) # transform - imOut = imIn.crop((0, 0, w, h)) - verify(imOut) + filename = str(tmp_path / "temp.im") + im_in.save(filename) - imOut = Image.new(mode, (w, h), None) - imOut.paste(imIn.crop((0, 0, w // 2, h)), (0, 0)) - imOut.paste(imIn.crop((w // 2, 0, w, h)), (w // 2, 0)) + with Image.open(filename) as im_out: - verify(imIn) - verify(imOut) + verify(im_in) + verify(im_out) - imIn = Image.new(mode, (1, 1), 1) - assert imIn.getpixel((0, 0)) == 1 + im_out = im_in.crop((0, 0, w, h)) + verify(im_out) - imIn.putpixel((0, 0), 2) - assert imIn.getpixel((0, 0)) == 2 + im_out = Image.new(mode, (w, h), None) + im_out.paste(im_in.crop((0, 0, w // 2, h)), (0, 0)) + im_out.paste(im_in.crop((w // 2, 0, w, h)), (w // 2, 0)) - if mode == "L": - maximum = 255 - else: - maximum = 32767 + verify(im_in) + verify(im_out) - imIn = Image.new(mode, (1, 1), 256) - assert imIn.getpixel((0, 0)) == min(256, maximum) + im_in = Image.new(mode, (1, 1), 1) + assert im_in.getpixel((0, 0)) == 1 - imIn.putpixel((0, 0), 512) - assert imIn.getpixel((0, 0)) == min(512, maximum) + im_in.putpixel((0, 0), 2) + assert im_in.getpixel((0, 0)) == 2 - basic("L") + if mode == "L": + maximum = 255 + else: + maximum = 32767 - basic("I;16") - basic("I;16B") - basic("I;16L") + im_in = Image.new(mode, (1, 1), 256) + assert im_in.getpixel((0, 0)) == min(256, maximum) - basic("I") + im_in.putpixel((0, 0), 512) + assert im_in.getpixel((0, 0)) == min(512, maximum) def test_tobytes(): diff --git a/Tests/test_numpy.py b/Tests/test_numpy.py index def7adf3f02..3de7ec30f5c 100644 --- a/Tests/test_numpy.py +++ b/Tests/test_numpy.py @@ -1,3 +1,5 @@ +import warnings + import pytest from PIL import Image @@ -32,7 +34,7 @@ def to_image(dtype, bands=1, boolean=0): # Check supported 1-bit integer formats assert_image(to_image(bool, 1, 1), "1", TEST_IMAGE_SIZE) - assert_image(to_image(numpy.bool8, 1, 1), "1", TEST_IMAGE_SIZE) + assert_image(to_image(numpy.bool_, 1, 1), "1", TEST_IMAGE_SIZE) # Check supported 8-bit integer formats assert_image(to_image(numpy.uint8), "L", TEST_IMAGE_SIZE) @@ -135,19 +137,9 @@ def test_save_tiff_uint16(): assert img_px[0, 0] == pixel_value -def test_to_array(): - def _to_array(mode, dtype): - img = hopper(mode) - - # Resize to non-square - img = img.crop((3, 0, 124, 127)) - assert img.size == (121, 127) - - np_img = numpy.array(img) - _test_img_equals_nparray(img, np_img) - assert np_img.dtype == dtype - - modes = [ +@pytest.mark.parametrize( + "mode, dtype", + ( ("L", numpy.uint8), ("I", numpy.int32), ("F", numpy.float32), @@ -161,10 +153,18 @@ def _to_array(mode, dtype): ("I;16B", ">u2"), ("I;16L", "> ]" assert pdf_repr(PdfBinary(b"\x90\x1F\xA0")) == b"<901FA0>" diff --git a/Tests/test_pickle.py b/Tests/test_pickle.py index 5fd04585563..23eb9e39f41 100644 --- a/Tests/test_pickle.py +++ b/Tests/test_pickle.py @@ -60,11 +60,11 @@ def helper_pickle_string(pickle, protocol, test_file, mode): ("Tests/images/itxt_chunks.png", None), ], ) -def test_pickle_image(tmp_path, test_file, test_mode): +@pytest.mark.parametrize("protocol", range(0, pickle.HIGHEST_PROTOCOL + 1)) +def test_pickle_image(tmp_path, test_file, test_mode, protocol): # Act / Assert - for protocol in range(0, pickle.HIGHEST_PROTOCOL + 1): - helper_pickle_string(pickle, protocol, test_file, test_mode) - helper_pickle_file(tmp_path, pickle, protocol, test_file, test_mode) + helper_pickle_string(pickle, protocol, test_file, test_mode) + helper_pickle_file(tmp_path, pickle, protocol, test_file, test_mode) def test_pickle_la_mode_with_palette(tmp_path): diff --git a/Tests/test_qt_image_qapplication.py b/Tests/test_qt_image_qapplication.py index dec790c5069..1fc8161467b 100644 --- a/Tests/test_qt_image_qapplication.py +++ b/Tests/test_qt_image_qapplication.py @@ -1,6 +1,10 @@ +import warnings + import pytest -from PIL import ImageQt +with warnings.catch_warnings(): + warnings.simplefilter("ignore", category=DeprecationWarning) + from PIL import ImageQt from .helper import assert_image_equal, assert_image_equal_tofile, hopper diff --git a/Tests/test_qt_image_toqimage.py b/Tests/test_qt_image_toqimage.py index 2a6b29abebc..c1983031a14 100644 --- a/Tests/test_qt_image_toqimage.py +++ b/Tests/test_qt_image_toqimage.py @@ -1,6 +1,10 @@ +import warnings + import pytest -from PIL import ImageQt +with warnings.catch_warnings(): + warnings.simplefilter("ignore", category=DeprecationWarning) + from PIL import ImageQt from .helper import assert_image_equal, assert_image_equal_tofile, hopper @@ -12,32 +16,32 @@ 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/Tests/test_util.py b/Tests/test_util.py index b5bfca0126f..9efbdd1f380 100644 --- a/Tests/test_util.py +++ b/Tests/test_util.py @@ -8,7 +8,7 @@ def test_is_path(): fp = "filename.ext" # Act - it_is = _util.isPath(fp) + it_is = _util.is_path(fp) # Assert assert it_is @@ -21,7 +21,7 @@ def test_path_obj_is_path(): test_path = Path("filename.ext") # Act - it_is = _util.isPath(test_path) + it_is = _util.is_path(test_path) # Assert assert it_is @@ -33,7 +33,7 @@ def test_is_not_path(tmp_path): pass # Act - it_is_not = _util.isPath(fp) + it_is_not = _util.is_path(fp) # Assert assert not it_is_not @@ -44,7 +44,7 @@ def test_is_directory(): directory = "Tests" # Act - it_is = _util.isDirectory(directory) + it_is = _util.is_directory(directory) # Assert assert it_is @@ -55,7 +55,7 @@ def test_is_not_directory(): text = "abc" # Act - it_is_not = _util.isDirectory(text) + it_is_not = _util.is_directory(text) # Assert assert not it_is_not @@ -65,7 +65,7 @@ def test_deferred_error(): # Arrange # Act - thing = _util.deferred_error(ValueError("Some error text")) + thing = _util.DeferredError(ValueError("Some error text")) # Assert with pytest.raises(ValueError): diff --git a/depends/install_imagequant.sh b/depends/install_imagequant.sh index 774f2676750..64dd024bd7f 100755 --- a/depends/install_imagequant.sh +++ b/depends/install_imagequant.sh @@ -1,14 +1,15 @@ #!/bin/bash # install libimagequant -archive=libimagequant-2.17.0 +archive=libimagequant-4.0.4 ./download-and-extract.sh $archive https://raw.githubusercontent.com/python-pillow/pillow-depends/main/$archive.tar.gz -pushd $archive +pushd $archive/imagequant-sys -make shared -sudo cp libimagequant.so* /usr/lib/ -sudo cp libimagequant.h /usr/include/ +cargo install cargo-c +cargo cinstall --prefix=/usr --destdir=. +sudo cp usr/lib/libimagequant.so* /usr/lib/ +sudo cp usr/include/libimagequant.h /usr/include/ popd diff --git a/depends/install_openjpeg.sh b/depends/install_openjpeg.sh index 914e71e5396..4f4b81a628b 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_raqm.sh b/depends/install_raqm.sh index 3105465ec40..99250365065 100755 --- a/depends/install_raqm.sh +++ b/depends/install_raqm.sh @@ -2,13 +2,13 @@ # install raqm -archive=raqm-0.7.1 +archive=libraqm-0.9.0 ./download-and-extract.sh $archive https://raw.githubusercontent.com/python-pillow/pillow-depends/main/$archive.tar.gz pushd $archive -./configure --prefix=/usr && make -j4 && sudo make -j4 install +meson build --prefix=/usr && sudo ninja -C build install popd diff --git a/depends/install_webp.sh b/depends/install_webp.sh index 8a9c968045c..05867b7d448 100755 --- a/depends/install_webp.sh +++ b/depends/install_webp.sh @@ -1,7 +1,7 @@ #!/bin/bash # install webp -archive=libwebp-1.2.1 +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/COPYING b/docs/COPYING index 25f03b34312..b400381d310 100644 --- a/docs/COPYING +++ b/docs/COPYING @@ -5,7 +5,7 @@ The Python Imaging Library (PIL) is Pillow is the friendly PIL fork. It is - Copyright © 2010-2022 by Alex Clark and contributors + Copyright © 2010-2023 by Alex Clark and contributors Like PIL, Pillow is licensed under the open source PIL Software License: diff --git a/docs/Makefile b/docs/Makefile index 686f0119e37..d32d25a3c49 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -2,8 +2,9 @@ # # You can set these variables from the command line. +PYTHON = python3 SPHINXOPTS = -SPHINXBUILD = sphinx-build +SPHINXBUILD = $(PYTHON) -m sphinx.cmd.build PAPER = BUILDDIR = _build @@ -14,11 +15,12 @@ ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . # the i18n builder cannot share the environment and doctrees with the others I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . -.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext - +.PHONY: help help: @echo "Please use \`make ' where is one of" @echo " html to make standalone HTML files" + @echo " serve to start a local server for viewing docs" + @echo " livehtml to start a local server for viewing docs and auto-reload on change" @echo " dirhtml to make HTML files named index.html in directories" @echo " singlehtml to make a single large HTML file" @echo " pickle to make pickle files" @@ -38,41 +40,59 @@ help: @echo " linkcheck to check all external links for integrity" @echo " doctest to run all doctests embedded in the documentation (if enabled)" +.PHONY: clean clean: -rm -rf $(BUILDDIR)/* +install-sphinx: + $(PYTHON) -m pip install --quiet furo olefile sphinx sphinx-copybutton sphinx-inline-tabs sphinx-issues sphinx-removed-in sphinxext-opengraph + +.PHONY: html html: + $(MAKE) install-sphinx $(SPHINXBUILD) -b html -W --keep-going $(ALLSPHINXOPTS) $(BUILDDIR)/html @echo @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." +.PHONY: dirhtml dirhtml: + $(MAKE) install-sphinx $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml @echo @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." +.PHONY: singlehtml singlehtml: + $(MAKE) install-sphinx $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml @echo @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." +.PHONY: pickle pickle: + $(MAKE) install-sphinx $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle @echo @echo "Build finished; now you can process the pickle files." +.PHONY: json json: + $(MAKE) install-sphinx $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json @echo @echo "Build finished; now you can process the JSON files." +.PHONY: htmlhelp htmlhelp: + $(MAKE) install-sphinx $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp @echo @echo "Build finished; now you can run HTML Help Workshop with the" \ ".hhp project file in $(BUILDDIR)/htmlhelp." +.PHONY: qthelp qthelp: + $(MAKE) install-sphinx $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp @echo @echo "Build finished; now you can run "qcollectiongenerator" with the" \ @@ -81,7 +101,9 @@ qthelp: @echo "To view the help file:" @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/PillowPILfork.qhc" +.PHONY: devhelp devhelp: + $(MAKE) install-sphinx $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp @echo @echo "Build finished." @@ -90,70 +112,94 @@ devhelp: @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/PillowPILfork" @echo "# devhelp" +.PHONY: epub epub: + $(MAKE) install-sphinx $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub @echo @echo "Build finished. The epub file is in $(BUILDDIR)/epub." +.PHONY: latex latex: + $(MAKE) install-sphinx $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex @echo @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." @echo "Run \`make' in that directory to run these through (pdf)latex" \ "(use \`make latexpdf' here to do that automatically)." +.PHONY: latexpdf latexpdf: + $(MAKE) install-sphinx $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex @echo "Running LaTeX files through pdflatex..." $(MAKE) -C $(BUILDDIR)/latex all-pdf @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." +.PHONY: text text: + $(MAKE) install-sphinx $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text @echo @echo "Build finished. The text files are in $(BUILDDIR)/text." +.PHONY: man man: + $(MAKE) install-sphinx $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man @echo @echo "Build finished. The manual pages are in $(BUILDDIR)/man." +.PHONY: texinfo texinfo: + $(MAKE) install-sphinx $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo @echo @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." @echo "Run \`make' in that directory to run these through makeinfo" \ "(use \`make info' here to do that automatically)." +.PHONY: info info: + $(MAKE) install-sphinx $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo @echo "Running Texinfo files through makeinfo..." make -C $(BUILDDIR)/texinfo info @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." +.PHONY: gettext gettext: + $(MAKE) install-sphinx $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale @echo @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." +.PHONY: changes changes: + $(MAKE) install-sphinx $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes @echo @echo "The overview file is in $(BUILDDIR)/changes." +.PHONY: linkcheck linkcheck: + $(MAKE) install-sphinx $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck -j auto @echo @echo "Link check complete; look for any errors in the above output " \ "or in $(BUILDDIR)/linkcheck/output.txt." +.PHONY: doctest doctest: + $(MAKE) install-sphinx $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest @echo "Testing of doctests in the sources finished, look at the " \ "results in $(BUILDDIR)/doctest/output.txt." +.PHONY: livehtml livehtml: html livereload $(BUILDDIR)/html -p 33233 +.PHONY: serve serve: - cd $(BUILDDIR)/html; python3 -m http.server + cd $(BUILDDIR)/html; $(PYTHON) -m http.server diff --git a/docs/about.rst b/docs/about.rst index 96885d08db0..03829c133f5 100644 --- a/docs/about.rst +++ b/docs/about.rst @@ -12,7 +12,7 @@ The fork author's goal is to foster and support active development of PIL throug .. _GitHub Actions: https://github.com/python-pillow/Pillow/actions .. _AppVeyor: https://ci.appveyor.com/project/Python-pillow/pillow -.. _Travis CI: https://travis-ci.com/github/python-pillow/pillow-wheels +.. _Travis CI: https://app.travis-ci.com/github/python-pillow/pillow-wheels .. _GitHub: https://github.com/python-pillow/Pillow .. _Python Package Index: https://pypi.org/project/Pillow/ diff --git a/docs/conf.py b/docs/conf.py index 7bbe8c4c96f..fb58d25edb4 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -16,8 +16,6 @@ # documentation root, use os.path.abspath to make it absolute, like shown here. # sys.path.insert(0, os.path.abspath('.')) -import sphinx_rtd_theme - import PIL # -- General configuration ------------------------------------------------ @@ -29,12 +27,13 @@ # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. extensions = [ - "sphinx_copybutton", - "sphinx_issues", - "sphinx_removed_in", "sphinx.ext.autodoc", "sphinx.ext.intersphinx", "sphinx.ext.viewcode", + "sphinx_copybutton", + "sphinx_inline_tabs", + "sphinx_issues", + "sphinx_removed_in", "sphinxext.opengraph", ] @@ -53,7 +52,7 @@ # General information about the project. project = "Pillow (PIL Fork)" -copyright = "1995-2011 Fredrik Lundh, 2010-2022 Alex Clark and Contributors" +copyright = "1995-2011 Fredrik Lundh, 2010-2023 Alex Clark and Contributors" author = "Fredrik Lundh, Alex Clark and Contributors" # The version info for the project you're documenting, acts as replacement for @@ -70,7 +69,7 @@ # # 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: @@ -126,13 +125,15 @@ # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. -html_theme = "sphinx_rtd_theme" -html_theme_path = [sphinx_rtd_theme.get_html_theme_path()] +html_theme = "furo" # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the # documentation. -# html_theme_options = {} +html_theme_options = { + "light_logo": "pillow-logo-dark-text.png", + "dark_logo": "pillow-logo.png", +} # Add any paths that contain custom themes here, relative to this directory. # html_theme_path = [] @@ -146,7 +147,7 @@ # The name of an image file (relative to this directory) to place at the top # of the sidebar. -html_logo = "resources/pillow-logo.png" +# html_logo = "resources/pillow-logo.png" # The name of an image file (within the static path) to use as favicon of the # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 @@ -311,10 +312,7 @@ def setup(app): - app.add_js_file("js/script.js") - app.add_css_file("css/styles.css") app.add_css_file("css/dark.css") - app.add_css_file("css/light.css") # GitHub repo for sphinx-issues diff --git a/docs/deprecations.rst b/docs/deprecations.rst index ce30fdf3b92..4d48b822a85 100644 --- a/docs/deprecations.rst +++ b/docs/deprecations.rst @@ -53,6 +53,164 @@ Before Pillow 8.3.0, ``ImagePalette`` required palette data of particular length default, and the size parameter could be used to override that. Pillow 8.3.0 removed the default required length, also removing the need for the size parameter. +ImageShow.Viewer.show_file file argument +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. deprecated:: 9.1.0 + +The ``file`` argument in :py:meth:`~PIL.ImageShow.Viewer.show_file()` has been +deprecated and will be removed in Pillow 10.0.0 (2023-07-01). It has been replaced by +``path``. + +In effect, ``viewer.show_file("test.jpg")`` will continue to work unchanged. +``viewer.show_file(file="test.jpg")`` will raise a deprecation warning, and suggest +``viewer.show_file(path="test.jpg")`` instead. + +Constants +~~~~~~~~~ + +.. deprecated:: 9.1.0 + +A number of constants have been deprecated and will be removed in Pillow 10.0.0 +(2023-07-01). Instead, ``enum.IntEnum`` classes have been added. + +.. note:: + + Additional ``Image`` constants were deprecated in Pillow 9.1.0, but that + was reversed in Pillow 9.4.0 and those constants will now remain available. + See :ref:`restored-image-constants` + +===================================================== ============================================================ +Deprecated Use instead +===================================================== ============================================================ +``Image.LINEAR`` ``Image.BILINEAR`` or ``Image.Resampling.BILINEAR`` +``Image.CUBIC`` ``Image.BICUBIC`` or ``Image.Resampling.BICUBIC`` +``Image.ANTIALIAS`` ``Image.LANCZOS`` or ``Image.Resampling.LANCZOS`` +``ImageCms.INTENT_PERCEPTUAL`` ``ImageCms.Intent.PERCEPTUAL`` +``ImageCms.INTENT_RELATIVE_COLORMETRIC`` ``ImageCms.Intent.RELATIVE_COLORMETRIC`` +``ImageCms.INTENT_SATURATION`` ``ImageCms.Intent.SATURATION`` +``ImageCms.INTENT_ABSOLUTE_COLORIMETRIC`` ``ImageCms.Intent.ABSOLUTE_COLORIMETRIC`` +``ImageCms.DIRECTION_INPUT`` ``ImageCms.Direction.INPUT`` +``ImageCms.DIRECTION_OUTPUT`` ``ImageCms.Direction.OUTPUT`` +``ImageCms.DIRECTION_PROOF`` ``ImageCms.Direction.PROOF`` +``ImageFont.LAYOUT_BASIC`` ``ImageFont.Layout.BASIC`` +``ImageFont.LAYOUT_RAQM`` ``ImageFont.Layout.RAQM`` +``BlpImagePlugin.BLP_FORMAT_JPEG`` ``BlpImagePlugin.Format.JPEG`` +``BlpImagePlugin.BLP_ENCODING_UNCOMPRESSED`` ``BlpImagePlugin.Encoding.UNCOMPRESSED`` +``BlpImagePlugin.BLP_ENCODING_DXT`` ``BlpImagePlugin.Encoding.DXT`` +``BlpImagePlugin.BLP_ENCODING_UNCOMPRESSED_RAW_RGBA`` ``BlpImagePlugin.Encoding.UNCOMPRESSED_RAW_RGBA`` +``BlpImagePlugin.BLP_ALPHA_ENCODING_DXT1`` ``BlpImagePlugin.AlphaEncoding.DXT1`` +``BlpImagePlugin.BLP_ALPHA_ENCODING_DXT3`` ``BlpImagePlugin.AlphaEncoding.DXT3`` +``BlpImagePlugin.BLP_ALPHA_ENCODING_DXT5`` ``BlpImagePlugin.AlphaEncoding.DXT5`` +``FtexImagePlugin.FORMAT_DXT1`` ``FtexImagePlugin.Format.DXT1`` +``FtexImagePlugin.FORMAT_UNCOMPRESSED`` ``FtexImagePlugin.Format.UNCOMPRESSED`` +``PngImagePlugin.APNG_DISPOSE_OP_NONE`` ``PngImagePlugin.Disposal.OP_NONE`` +``PngImagePlugin.APNG_DISPOSE_OP_BACKGROUND`` ``PngImagePlugin.Disposal.OP_BACKGROUND`` +``PngImagePlugin.APNG_DISPOSE_OP_PREVIOUS`` ``PngImagePlugin.Disposal.OP_PREVIOUS`` +``PngImagePlugin.APNG_BLEND_OP_SOURCE`` ``PngImagePlugin.Blend.OP_SOURCE`` +``PngImagePlugin.APNG_BLEND_OP_OVER`` ``PngImagePlugin.Blend.OP_OVER`` +===================================================== ============================================================ + +FitsStubImagePlugin +~~~~~~~~~~~~~~~~~~~ + +.. deprecated:: 9.1.0 + +The stub image plugin ``FitsStubImagePlugin`` has been deprecated and will be removed in +Pillow 10.0.0 (2023-07-01). FITS images can be read without a handler through +:mod:`~PIL.FitsImagePlugin` instead. + +FreeTypeFont.getmask2 fill parameter +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. deprecated:: 9.2.0 + +The undocumented ``fill`` parameter of :py:meth:`.FreeTypeFont.getmask2` has been +deprecated and will be removed in Pillow 10 (2023-07-01). + +PhotoImage.paste box parameter +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. deprecated:: 9.2.0 + +The ``box`` parameter is unused. It will be removed in Pillow 10.0.0 (2023-07-01). + +PyQt5 and PySide2 +~~~~~~~~~~~~~~~~~ + +.. deprecated:: 9.2.0 + +`Qt 5 reached end-of-life `_ on 2020-12-08 for +open-source users (and will reach EOL on 2023-12-08 for commercial licence holders). + +Support for PyQt5 and PySide2 has been deprecated from ``ImageQt`` and will be removed +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: + +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` +=========================================================================== ============================================================================================================= + +Previous code: + +.. code-block:: python + + from PIL import Image, ImageDraw, ImageFont + + font = ImageFont.truetype("Tests/fonts/FreeMono.ttf") + width, height = font.getsize("Hello world") + left, top = font.getoffset("Hello world") + + im = Image.new("RGB", (100, 100)) + draw = ImageDraw.Draw(im) + width, height = draw.textsize("Hello world") + + width, height = font.getsize_multiline("Hello\nworld") + width, height = draw.multiline_textsize("Hello\nworld") + +Use instead: + +.. code-block:: python + + from PIL import Image, ImageDraw, ImageFont + + font = ImageFont.truetype("Tests/fonts/FreeMono.ttf") + left, top, right, bottom = font.getbbox("Hello world") + width, height = right - left, bottom - top + + im = Image.new("RGB", (100, 100)) + draw = ImageDraw.Draw(im) + width = draw.textlength("Hello world") + + left, top, right, bottom = draw.multiline_textbbox((0, 0), "Hello\nworld") + width, height = right - left, bottom - top + Removed features ---------------- @@ -109,7 +267,7 @@ Support for FreeType 2.7 has been removed. 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/ im.offset ~~~~~~~~~ diff --git a/docs/example/DdsImagePlugin.py b/docs/example/DdsImagePlugin.py index 272409416cc..26451533eee 100644 --- a/docs/example/DdsImagePlugin.py +++ b/docs/example/DdsImagePlugin.py @@ -210,12 +210,17 @@ class DdsImageFile(ImageFile.ImageFile): format_description = "DirectDraw Surface" def _open(self): - magic, header_size = struct.unpack("= 2.1.0 no longer automatically imports any file in the Python path with a name ending in @@ -79,7 +78,8 @@ true color. elif bits == 24: self.mode = "RGB" else: - raise SyntaxError("unknown number of bits") + msg = "unknown number of bits" + raise SyntaxError(msg) # data descriptor self.tile = [("raw", (0, 0) + self.size, 128, (self.mode, 0, 1))] @@ -124,8 +124,12 @@ The ``tile`` attribute To be able to read the file as well as just identifying it, the ``tile`` attribute must also be set. This attribute consists of a list of tile descriptors, where each descriptor specifies how data should be loaded to a -given region in the image. In most cases, only a single descriptor is used, -covering the full image. +given region in the image. + +In most cases, only a single descriptor is used, covering the full image. +:py:class:`.PsdImagePlugin.PsdImageFile` uses multiple tiles to combine +channels within a single layer, given that the channels are stored separately, +one after the other. The tile descriptor is a 4-tuple with the following contents:: @@ -138,6 +142,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. @@ -325,42 +333,42 @@ The fields are used as follows: Whether the first line in the image is the top line on the screen (1), or the bottom line (-1). If omitted, the orientation defaults to 1. -.. _file-decoders: +.. _file-codecs: -Writing Your Own File Decoder in C -================================== +Writing Your Own File Codec in C +================================ -There are 3 stages in a file decoder's lifetime: +There are 3 stages in a file codec's lifetime: -1. Setup: Pillow looks for a function in the decoder registry, falling - back to a function named ``[decodername]_decoder`` on the internal - core image object. That function is called with the ``args`` tuple - from the ``tile`` setup in the ``_open`` method. +1. Setup: Pillow looks for a function in the decoder or encoder registry, + falling back to a function named ``[codecname]_decoder`` or + ``[codecname]_encoder`` on the internal core image object. That function is + called with the ``args`` tuple from the ``tile``. -2. Decoding: The decoder's decode function is repeatedly called with - chunks of image data. +2. Transforming: The codec's ``decode`` or ``encode`` function is repeatedly + called with chunks of image data. -3. Cleanup: If the decoder has registered a cleanup function, it will - be called at the end of the decoding process, even if there was an +3. Cleanup: If the codec has registered a cleanup function, it will + be called at the end of the transformation process, even if there was an exception raised. Setup ----- -The current conventions are that the decoder setup function is named -``PyImaging_[Decodername]DecoderNew`` and defined in ``decode.c``. The -python binding for it is named ``[decodername]_decoder`` and is setup -from within the ``_imaging.c`` file in the codecs section of the -function array. +The current conventions are that the codec setup function is named +``PyImaging_[codecname]DecoderNew`` or ``PyImaging_[codecname]EncoderNew`` +and defined in ``decode.c`` or ``encode.c``. The Python binding for it is +named ``[codecname]_decoder`` or ``[codecname]_encoder`` and is set up from +within the ``_imaging.c`` file in the codecs section of the function array. -The setup function needs to call ``PyImaging_DecoderNew`` and at the -very least, set the ``decode`` function pointer. The fields of -interest in this object are: +The setup function needs to call ``PyImaging_DecoderNew`` or +``PyImaging_EncoderNew`` and at the very least, set the ``decode`` or +``encode`` function pointer. The fields of interest in this object are: -**decode** - Function pointer to the decode function, which has access to - ``im``, ``state``, and the buffer of data to be added to the image. +**decode**/**encode** + Function pointer to the decode or encode function, which has access to + ``im``, ``state``, and the buffer of data to be transformed. **cleanup** Function pointer to the cleanup function, has access to ``state``. @@ -370,36 +378,34 @@ interest in this object are: **state** An ImagingCodecStateInstance, will be set by Pillow. The ``context`` - member is an opaque struct that can be used by the decoder to store + member is an opaque struct that can be used by the codec to store any format specific state or options. -**pulls_fd** - **EXPERIMENTAL** -- **WARNING**, interface may change. If set to 1, - ``state->fd`` will be a pointer to the Python file like object. The - decoder may use the functions in ``codec_fd.c`` to read directly - from the file like object rather than have the data pushed through a - buffer. Note that this implementation may be refactored until this - warning is removed. +**pulls_fd**/**pushes_fd** + If the decoder has ``pulls_fd`` or the encoder has ``pushes_fd`` set to 1, + ``state->fd`` will be a pointer to the Python file like object. The codec may + use the functions in ``codec_fd.c`` to read or write directly with the file + like object rather than have the data pushed through a buffer. .. versionadded:: 3.3.0 -Decoding --------- +Transforming +------------ -The decode function is called with the target (core) image, the -decoder state structure, and a buffer of data to be decoded. +The decode or encode function is called with the target (core) image, the codec +state structure, and a buffer of data to be transformed. -**Experimental** -- If ``pulls_fd`` is set, then the decode function -is called once, with an empty buffer. It is the decoder's -responsibility to decode the entire tile in that one call. The rest of -this section only applies if ``pulls_fd`` is not set. +It is the codec's responsibility to pull as much data as possible out of the +buffer and return the number of bytes consumed. The next call to the codec will +include the previous unconsumed tail. The codec function will be called +multiple times as the data processed. -It is the decoder's responsibility to pull as much data as possible -out of the buffer and return the number of bytes consumed. The next -call to the decoder will include the previous unconsumed tail. The -decoder function will be called multiple times as the data is read -from the file like object. +Alternatively, if ``pulls_fd`` or ``pushes_fd`` is set, then the decode or +encode function is called once, with an empty buffer. It is the codec's +responsibility to transform the entire tile in that one call. Using this will +provide a codec with more freedom, but that freedom may mean increased memory +usage if the entire tile is held in memory at once by the codec. If an error occurs, set ``state->errcode`` and return -1. @@ -408,28 +414,49 @@ Return -1 on success, without setting the errcode. Cleanup ------- -The cleanup function is called after the decoder returns a negative -value, or if there is a read error from the file. This function should -free any allocated memory and release any resources from external -libraries. +The cleanup function is called after the codec returns a negative +value, or if there is an error. This function should free any allocated +memory and release any resources from external libraries. -.. _file-decoders-py: +.. _file-codecs-py: -Writing Your Own File Decoder in Python -======================================= +Writing Your Own File Codec in Python +===================================== -Python file decoders should derive from -:py:class:`PIL.ImageFile.PyDecoder` and should at least override the -decode method. File decoders should be registered using -:py:meth:`PIL.Image.register_decoder`. As in the C implementation of -the file decoders, there are three stages in the lifetime of a -Python-based file decoder: +Python file decoders and encoders should derive from +:py:class:`PIL.ImageFile.PyDecoder` and :py:class:`PIL.ImageFile.PyEncoder` +respectively, and should at least override the decode or encode method. +They should be registered using :py:meth:`PIL.Image.register_decoder` and +:py:meth:`PIL.Image.register_encoder`. As in the C implementation of +the file codecs, there are three stages in the lifetime of a +Python-based file codec: -1. Setup: Pillow looks for the decoder in the registry, then +1. Setup: Pillow looks for the codec in the decoder or encoder registry, then instantiates the class. -2. Decoding: The decoder instance's ``decode`` method is repeatedly - called with a buffer of data to be interpreted. +2. Transforming: The instance's ``decode`` method is repeatedly called with + a buffer of data to be interpreted, or the ``encode`` method is repeatedly + called with the size of data to be output. + + Alternatively, if the decoder's ``_pulls_fd`` property (or the encoder's + ``_pushes_fd`` property) is set to ``True``, then ``decode`` and ``encode`` + will only be called once. In the decoder, ``self.fd`` can be used to access + the file-like object. Using this will provide a codec with more freedom, but + that freedom may mean increased memory usage if entire file is held in + memory at once by the codec. + + In ``decode``, once the data has been interpreted, ``set_as_raw`` can be + used to populate the image. + +3. Cleanup: The instance's ``cleanup`` method is called once the transformation + is complete. This can be used to clean up any resources used by the codec. -3. Cleanup: The decoder instance's ``cleanup`` method is called. + If you set ``_pulls_fd`` or ``_pushes_fd`` to ``True`` however, then you + probably chose to perform any cleanup tasks at the end of ``decode`` or + ``encode``. +For an example :py:class:`PIL.ImageFile.PyDecoder`, see `DdsImagePlugin +`_. +For a plugin that uses both :py:class:`PIL.ImageFile.PyDecoder` and +:py:class:`PIL.ImageFile.PyEncoder`, see `BlpImagePlugin +`_ diff --git a/docs/index.rst b/docs/index.rst index 0e16259f309..5bcd5afa5b4 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -10,21 +10,29 @@ 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 | -+----------------------+-----+-----+-----+-----+-----+-----+-----+-----+ - -+------------------+-----+-----+-----+-----+-----+-----+-----+-----+-----+ -| 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:: Newer versions + :file: newer-versions.csv + :header-rows: 1 + +.. csv-table:: Older versions + :file: older-versions.csv + :header-rows: 1 + +.. _Linux Installation: +.. _macOS Installation: +.. _Windows Installation: +.. _FreeBSD Installation: Basic Installation ------------------ @@ -60,75 +43,73 @@ Install Pillow with :command:`pip`:: python3 -m pip install --upgrade Pillow -Windows Installation -^^^^^^^^^^^^^^^^^^^^ +.. tab:: Linux -We provide Pillow binaries for Windows compiled for the matrix of -supported Pythons in both 32 and 64-bit versions in the wheel format. -These binaries include support for all optional libraries except -libimagequant and libxcb. Raqm support requires -FriBiDi to be installed separately:: + We provide binaries for Linux for each of the supported Python + versions in the manylinux wheel format. These include support for all + optional libraries except libimagequant. Raqm support requires + FriBiDi to be installed separately:: - python3 -m pip install --upgrade pip - python3 -m pip install --upgrade Pillow + python3 -m pip install --upgrade pip + python3 -m pip install --upgrade Pillow -To install Pillow in MSYS2, see `Building on Windows using MSYS2/MinGW`_. + Most major Linux distributions, including Fedora, Ubuntu and ArchLinux + also include Pillow in packages that previously contained PIL e.g. + ``python-imaging``. Debian splits it into two packages, ``python3-pil`` + and ``python3-pil.imagetk``. +.. tab:: macOS -macOS Installation -^^^^^^^^^^^^^^^^^^ + We provide binaries for macOS for each of the supported Python + versions in the wheel format. These include support for all optional + libraries except libimagequant. Raqm support requires + FriBiDi to be installed separately:: -We provide binaries for macOS for each of the supported Python -versions in the wheel format. These include support for all optional -libraries except libimagequant. Raqm support requires -FriBiDi to be installed separately:: + python3 -m pip install --upgrade pip + python3 -m pip install --upgrade Pillow - python3 -m pip install --upgrade pip - python3 -m pip install --upgrade Pillow +.. tab:: Windows -Linux Installation -^^^^^^^^^^^^^^^^^^ + We provide Pillow binaries for Windows compiled for the matrix of + supported Pythons in both 32 and 64-bit versions in the wheel format. + These binaries include support for all optional libraries except + libimagequant and libxcb. Raqm support requires + FriBiDi to be installed separately:: -We provide binaries for Linux for each of the supported Python -versions in the manylinux wheel format. These include support for all -optional libraries except libimagequant. Raqm support requires -FriBiDi to be installed separately:: + python3 -m pip install --upgrade pip + python3 -m pip install --upgrade Pillow - python3 -m pip install --upgrade pip - python3 -m pip install --upgrade Pillow + To install Pillow in MSYS2, see `Building on Windows using MSYS2/MinGW`_. -Most major Linux distributions, including Fedora, Ubuntu and ArchLinux -also include Pillow in packages that previously contained PIL e.g. -``python-imaging``. Debian splits it into two packages, ``python3-pil`` -and ``python3-pil.imagetk``. +.. tab:: FreeBSD -FreeBSD Installation -^^^^^^^^^^^^^^^^^^^^ + Pillow can be installed on FreeBSD via the official Ports or Packages systems: -Pillow can be installed on FreeBSD via the official Ports or Packages systems: + **Ports**:: -**Ports**:: + cd /usr/ports/graphics/py-pillow && make install clean - cd /usr/ports/graphics/py-pillow && make install clean + **Packages**:: -**Packages**:: + pkg install py38-pillow - pkg install py38-pillow + .. note:: -.. note:: + The `Pillow FreeBSD port + `_ and packages + are tested by the ports team with all supported FreeBSD versions. - The `Pillow FreeBSD port - `_ and packages - are tested by the ports team with all supported FreeBSD versions. +.. _Building on Linux: +.. _Building on macOS: +.. _Building on Windows: +.. _Building on Windows using MSYS2/MinGW: +.. _Building on FreeBSD: +.. _Building on Android: Building From Source -------------------- -Download and extract the `compressed archive from PyPI`_. - -.. _compressed archive from PyPI: https://pypi.org/project/Pillow/ - .. _external-libraries: External Libraries @@ -162,14 +143,14 @@ 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.5** * **libfreetype** provides type related services * **littlecms** provides color management * Pillow version 2.2.1 and below uses liblcms1, Pillow 2.3.0 and - above uses liblcms2. Tested with **1.19** and **2.7-2.12**. + above uses liblcms2. Tested with **1.19** and **2.7-2.14**. * **libwebp** provides the WebP format. @@ -181,13 +162,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-2.17.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. @@ -205,227 +187,221 @@ Many of Pillow's features require external libraries: loads libfribidi at runtime if it is installed. On Windows this requires compiling FriBiDi and installing ``fribidi.dll`` into a directory listed in the `Dynamic-Link Library Search Order (Microsoft Docs) - `_ + `_ (``fribidi-0.dll`` or ``libfribidi-0.dll`` are also detected). See `Build Options`_ to see how to build this version. * Previous versions of Pillow (5.0.0 to 8.1.2) linked libraqm dynamically at runtime. * **libxcb** provides X11 screengrab support. -Once you have installed the prerequisites, run:: - - python3 -m pip install --upgrade pip - python3 -m pip install --upgrade Pillow - -If the prerequisites are installed in the standard library locations -for your machine (e.g. :file:`/usr` or :file:`/usr/local`), no -additional configuration should be required. If they are installed in -a non-standard location, you may need to configure setuptools to use -those locations by editing :file:`setup.py` or -:file:`setup.cfg`, or by adding environment variables on the command -line:: - - CFLAGS="-I/usr/pkg/include" python3 -m pip install --upgrade Pillow - -If Pillow has been previously built without the required -prerequisites, it may be necessary to manually clear the pip cache or -build without cache using the ``--no-cache-dir`` option to force a -build with newly installed external libraries. - +.. tab:: Linux -Build Options -^^^^^^^^^^^^^ + If you didn't build Python from source, make sure you have Python's + development libraries installed. -* Environment variable: ``MAX_CONCURRENCY=n``. Pillow can use - multiprocessing to build the extension. Setting ``MAX_CONCURRENCY`` - sets the number of CPUs to use, or can disable parallel building by - using a setting of 1. By default, it uses 4 CPUs, or if 4 are not - available, as many as are present. + In Debian or Ubuntu:: -* Build flags: ``--disable-zlib``, ``--disable-jpeg``, - ``--disable-tiff``, ``--disable-freetype``, ``--disable-lcms``, - ``--disable-webp``, ``--disable-webpmux``, ``--disable-jpeg2000``, - ``--disable-imagequant``, ``--disable-xcb``. - Disable building the corresponding feature even if the development - libraries are present on the building machine. + sudo apt-get install python3-dev python3-setuptools -* Build flags: ``--enable-zlib``, ``--enable-jpeg``, - ``--enable-tiff``, ``--enable-freetype``, ``--enable-lcms``, - ``--enable-webp``, ``--enable-webpmux``, ``--enable-jpeg2000``, - ``--enable-imagequant``, ``--enable-xcb``. - Require that the corresponding feature is built. The build will raise - an exception if the libraries are not found. Webpmux (WebP metadata) - relies on WebP support. Tcl and Tk also must be used together. + In Fedora, the command is:: -* Build flags: ``--vendor-raqm --vendor-fribidi`` - These flags are used to compile a modified version of libraqm and - a shim that dynamically loads libfribidi at runtime. These are - used to compile the standard Pillow wheels. Compiling libraqm requires - a C99-compliant compiler. + sudo dnf install python3-devel redhat-rpm-config -* Build flag: ``--disable-platform-guessing``. Skips all of the - platform dependent guessing of include and library directories for - automated build systems that configure the proper paths in the - environment variables (e.g. Buildroot). + In Alpine, the command is:: -* Build flag: ``--debug``. Adds a debugging flag to the include and - library search process to dump all paths searched for and found to - stdout. + sudo apk add python3-dev py3-setuptools + .. Note:: ``redhat-rpm-config`` is required on Fedora 23, but not earlier versions. -Sample usage:: + Prerequisites for **Ubuntu 16.04 LTS - 22.04 LTS** are installed with:: - python3 -m pip install --upgrade Pillow --global-option="build_ext" --global-option="--enable-[feature]" + sudo apt-get install libtiff5-dev libjpeg8-dev libopenjp2-7-dev zlib1g-dev \ + libfreetype6-dev liblcms2-dev libwebp-dev tcl8.6-dev tk8.6-dev python3-tk \ + libharfbuzz-dev libfribidi-dev libxcb1-dev + To install libraqm, ``sudo apt-get install meson`` and then see + ``depends/install_raqm.sh``. -Building on macOS -^^^^^^^^^^^^^^^^^ + Prerequisites are installed on recent **Red Hat**, **CentOS** or **Fedora** with:: -The Xcode command line tools are required to compile portions of -Pillow. The tools are installed by running ``xcode-select --install`` -from the command line. The command line tools are required even if you -have the full Xcode package installed. It may be necessary to run -``sudo xcodebuild -license`` to accept the license prior to using the -tools. + sudo dnf install libtiff-devel libjpeg-devel openjpeg2-devel zlib-devel \ + freetype-devel lcms2-devel libwebp-devel tcl-devel tk-devel \ + harfbuzz-devel fribidi-devel libraqm-devel libimagequant-devel libxcb-devel -The easiest way to install external libraries is via `Homebrew -`_. After you install Homebrew, run:: + Note that the package manager may be yum or DNF, depending on the + exact distribution. - brew install libtiff libjpeg webp little-cms2 + Prerequisites are installed for **Alpine** with:: -To install libraqm on macOS use Homebrew to install its dependencies:: + sudo apk add tiff-dev jpeg-dev openjpeg-dev zlib-dev freetype-dev lcms2-dev \ + libwebp-dev tcl-dev tk-dev harfbuzz-dev fribidi-dev libimagequant-dev \ + libxcb-dev libpng-dev - brew install freetype harfbuzz fribidi + See also the ``Dockerfile``\s in the Test Infrastructure repo + (https://github.com/python-pillow/docker-images) for a known working + install process for other tested distros. -Then see ``depends/install_raqm_cmake.sh`` to install libraqm. +.. tab:: macOS -Now install Pillow with:: + The Xcode command line tools are required to compile portions of + Pillow. The tools are installed by running ``xcode-select --install`` + from the command line. The command line tools are required even if you + have the full Xcode package installed. It may be necessary to run + ``sudo xcodebuild -license`` to accept the license prior to using the + tools. - python3 -m pip install --upgrade pip - python3 -m pip install --upgrade Pillow + The easiest way to install external libraries is via `Homebrew + `_. After you install Homebrew, run:: -or from within the uncompressed source directory:: + brew install libjpeg libtiff little-cms2 openjpeg webp - python3 -m pip install . + To install libraqm on macOS use Homebrew to install its dependencies:: -Building on Windows -^^^^^^^^^^^^^^^^^^^ + brew install freetype harfbuzz fribidi -We recommend you use prebuilt wheels from PyPI. -If you wish to compile Pillow manually, you can use the build scripts -in the ``winbuild`` directory used for CI testing and development. -These scripts require Visual Studio 2017 or newer and NASM. + Then see ``depends/install_raqm_cmake.sh`` to install libraqm. -Building on Windows using MSYS2/MinGW -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +.. tab:: Windows -To build Pillow using MSYS2, make sure you run the **MSYS2 MinGW 32-bit** or -**MSYS2 MinGW 64-bit** console, *not* **MSYS2** directly. + We recommend you use prebuilt wheels from PyPI. + If you wish to compile Pillow manually, you can use the build scripts + in the ``winbuild`` directory used for CI testing and development. + These scripts require Visual Studio 2017 or newer and NASM. -The following instructions target the 64-bit build, for 32-bit -replace all occurrences of ``mingw-w64-x86_64-`` with ``mingw-w64-i686-``. + The scripts also install Pillow from the local copy of the source code, so the + `Installing`_ instructions will not be necessary afterwards. -Make sure you have Python and GCC installed:: +.. tab:: Windows using MSYS2/MinGW - pacman -S \ - mingw-w64-x86_64-gcc \ - mingw-w64-x86_64-python3 \ - mingw-w64-x86_64-python3-pip \ - mingw-w64-x86_64-python3-setuptools + To build Pillow using MSYS2, make sure you run the **MSYS2 MinGW 32-bit** or + **MSYS2 MinGW 64-bit** console, *not* **MSYS2** directly. -Prerequisites are installed on **MSYS2 MinGW 64-bit** with:: + The following instructions target the 64-bit build, for 32-bit + replace all occurrences of ``mingw-w64-x86_64-`` with ``mingw-w64-i686-``. - pacman -S \ - mingw-w64-x86_64-libjpeg-turbo \ - mingw-w64-x86_64-zlib \ - mingw-w64-x86_64-libtiff \ - mingw-w64-x86_64-freetype \ - mingw-w64-x86_64-lcms2 \ - mingw-w64-x86_64-libwebp \ - mingw-w64-x86_64-openjpeg2 \ - mingw-w64-x86_64-libimagequant \ - mingw-w64-x86_64-libraqm + Make sure you have Python and GCC installed:: -Now install Pillow with:: + pacman -S \ + mingw-w64-x86_64-gcc \ + mingw-w64-x86_64-python3 \ + mingw-w64-x86_64-python3-pip \ + mingw-w64-x86_64-python3-setuptools - python3 -m pip install --upgrade pip - python3 -m pip install --upgrade Pillow + Prerequisites are installed on **MSYS2 MinGW 64-bit** with:: + pacman -S \ + mingw-w64-x86_64-libjpeg-turbo \ + mingw-w64-x86_64-zlib \ + mingw-w64-x86_64-libtiff \ + mingw-w64-x86_64-freetype \ + mingw-w64-x86_64-lcms2 \ + mingw-w64-x86_64-libwebp \ + mingw-w64-x86_64-openjpeg2 \ + mingw-w64-x86_64-libimagequant \ + mingw-w64-x86_64-libraqm -Building on FreeBSD -^^^^^^^^^^^^^^^^^^^ +.. tab:: FreeBSD -.. Note:: Only FreeBSD 10 and 11 tested + .. Note:: Only FreeBSD 10 and 11 tested -Make sure you have Python's development libraries installed:: + Make sure you have Python's development libraries installed:: - sudo pkg install python3 + sudo pkg install python3 -Prerequisites are installed on **FreeBSD 10 or 11** with:: + Prerequisites are installed on **FreeBSD 10 or 11** with:: - sudo pkg install jpeg-turbo tiff webp lcms2 freetype2 openjpeg harfbuzz fribidi libxcb + sudo pkg install jpeg-turbo tiff webp lcms2 freetype2 openjpeg harfbuzz fribidi libxcb -Then see ``depends/install_raqm_cmake.sh`` to install libraqm. + Then see ``depends/install_raqm_cmake.sh`` to install libraqm. +.. tab:: Android -Building on Linux -^^^^^^^^^^^^^^^^^ + Basic Android support has been added for compilation within the Termux + environment. The dependencies can be installed by:: -If you didn't build Python from source, make sure you have Python's -development libraries installed. + pkg install -y python ndk-sysroot clang make \ + libjpeg-turbo -In Debian or Ubuntu:: + This has been tested within the Termux app on ChromeOS, on x86. - sudo apt-get install python3-dev python3-setuptools +Installing +^^^^^^^^^^ -In Fedora, the command is:: +Once you have installed the prerequisites, to install Pillow from the source +code on PyPI, run:: - sudo dnf install python3-devel redhat-rpm-config + python3 -m pip install --upgrade pip + python3 -m pip install --upgrade Pillow --no-binary :all: -In Alpine, the command is:: +If the prerequisites are installed in the standard library locations +for your machine (e.g. :file:`/usr` or :file:`/usr/local`), no +additional configuration should be required. If they are installed in +a non-standard location, you may need to configure setuptools to use +those locations by editing :file:`setup.py` or +:file:`setup.cfg`, or by adding environment variables on the command +line:: - sudo apk add python3-dev py3-setuptools + CFLAGS="-I/usr/pkg/include" python3 -m pip install --upgrade Pillow --no-binary :all: -.. Note:: ``redhat-rpm-config`` is required on Fedora 23, but not earlier versions. +If Pillow has been previously built without the required +prerequisites, it may be necessary to manually clear the pip cache or +build without cache using the ``--no-cache-dir`` option to force a +build with newly installed external libraries. -Prerequisites for **Ubuntu 16.04 LTS - 20.04 LTS** are installed with:: +If you would like to install from a local copy of the source code instead, you +can clone from GitHub with ``git clone https://github.com/python-pillow/Pillow`` +or download and extract the `compressed archive from PyPI`_. - sudo apt-get install libtiff5-dev libjpeg8-dev libopenjp2-7-dev zlib1g-dev \ - libfreetype6-dev liblcms2-dev libwebp-dev tcl8.6-dev tk8.6-dev python3-tk \ - libharfbuzz-dev libfribidi-dev libxcb1-dev +After navigating to the Pillow directory, run:: -Then see ``depends/install_raqm.sh`` to install libraqm. + python3 -m pip install --upgrade pip + python3 -m pip install . -Prerequisites are installed on recent **Red Hat**, **CentOS** or **Fedora** with:: +.. _compressed archive from PyPI: https://pypi.org/project/Pillow/#files - sudo dnf install libtiff-devel libjpeg-devel openjpeg2-devel zlib-devel \ - freetype-devel lcms2-devel libwebp-devel tcl-devel tk-devel \ - harfbuzz-devel fribidi-devel libraqm-devel libimagequant-devel libxcb-devel +Build Options +""""""""""""" -Note that the package manager may be yum or DNF, depending on the -exact distribution. +* Environment variable: ``MAX_CONCURRENCY=n``. Pillow can use + multiprocessing to build the extension. Setting ``MAX_CONCURRENCY`` + sets the number of CPUs to use, or can disable parallel building by + using a setting of 1. By default, it uses 4 CPUs, or if 4 are not + available, as many as are present. -Prerequisites are installed for **Alpine** with:: +* Build flags: ``--disable-zlib``, ``--disable-jpeg``, + ``--disable-tiff``, ``--disable-freetype``, ``--disable-lcms``, + ``--disable-webp``, ``--disable-webpmux``, ``--disable-jpeg2000``, + ``--disable-imagequant``, ``--disable-xcb``. + Disable building the corresponding feature even if the development + libraries are present on the building machine. - sudo apk add tiff-dev jpeg-dev openjpeg-dev zlib-dev freetype-dev lcms2-dev \ - libwebp-dev tcl-dev tk-dev harfbuzz-dev fribidi-dev libimagequant-dev \ - libxcb-dev libpng-dev +* Build flags: ``--enable-zlib``, ``--enable-jpeg``, + ``--enable-tiff``, ``--enable-freetype``, ``--enable-lcms``, + ``--enable-webp``, ``--enable-webpmux``, ``--enable-jpeg2000``, + ``--enable-imagequant``, ``--enable-xcb``. + Require that the corresponding feature is built. The build will raise + an exception if the libraries are not found. Webpmux (WebP metadata) + relies on WebP support. Tcl and Tk also must be used together. -See also the ``Dockerfile``\s in the Test Infrastructure repo -(https://github.com/python-pillow/docker-images) for a known working -install process for other tested distros. +* Build flags: ``--vendor-raqm --vendor-fribidi`` + These flags are used to compile a modified version of libraqm and + a shim that dynamically loads libfribidi at runtime. These are + used to compile the standard Pillow wheels. Compiling libraqm requires + a C99-compliant compiler. -Building on Android -^^^^^^^^^^^^^^^^^^^ +* Build flag: ``--disable-platform-guessing``. Skips all of the + platform dependent guessing of include and library directories for + automated build systems that configure the proper paths in the + environment variables (e.g. Buildroot). -Basic Android support has been added for compilation within the Termux -environment. The dependencies can be installed by:: +* Build flag: ``--debug``. Adds a debugging flag to the include and + library search process to dump all paths searched for and found to + stdout. - pkg install -y python ndk-sysroot clang make \ - libjpeg-turbo -This has been tested within the Termux app on ChromeOS, on x86. +Sample usage:: + python3 -m pip install --upgrade Pillow --global-option="build_ext" --global-option="--enable-[feature]" Platform Support ---------------- @@ -452,30 +428,39 @@ These platforms are built and tested for every change. +----------------------------------+----------------------------+---------------------+ | CentOS 7 | 3.9 | x86-64 | +----------------------------------+----------------------------+---------------------+ -| CentOS 8 | 3.9 | x86-64 | -+----------------------------------+----------------------------+---------------------+ | CentOS Stream 8 | 3.9 | x86-64 | +----------------------------------+----------------------------+---------------------+ +| CentOS Stream 9 | 3.9 | x86-64 | ++----------------------------------+----------------------------+---------------------+ | Debian 10 Buster | 3.7 | x86 | +----------------------------------+----------------------------+---------------------+ -| Fedora 34 | 3.9 | x86-64 | +| Debian 11 Bullseye | 3.9 | x86 | ++----------------------------------+----------------------------+---------------------+ +| Fedora 36 | 3.10 | x86-64 | ++----------------------------------+----------------------------+---------------------+ +| Fedora 37 | 3.11 | x86-64 | +----------------------------------+----------------------------+---------------------+ -| Fedora 35 | 3.10 | x86-64 | +| Gentoo | 3.9 | x86-64 | +----------------------------------+----------------------------+---------------------+ -| macOS 10.15 Catalina | 3.7, 3.8, 3.9, 3.10, PyPy3 | x86-64 | +| macOS 11 Big Sur | 3.7, 3.8, 3.9, 3.10, 3.11, | x86-64 | +| | PyPy3 | | +----------------------------------+----------------------------+---------------------+ | Ubuntu Linux 18.04 LTS (Bionic) | 3.9 | x86-64 | +----------------------------------+----------------------------+---------------------+ -| Ubuntu Linux 20.04 LTS (Focal) | 3.7, 3.8, 3.9, 3.10, PyPy3 | x86-64 | -| +----------------------------+---------------------+ -| | 3.8 | arm64v8, ppc64le, | -| | | s390x | +| Ubuntu Linux 20.04 LTS (Focal) | 3.7, 3.8, 3.9, 3.10, 3.11, | x86-64 | +| | PyPy3 | | ++----------------------------------+----------------------------+---------------------+ +| Ubuntu Linux 22.04 LTS (Jammy) | 3.10 | arm64v8, ppc64le, | +| | | s390x, x86-64 | +----------------------------------+----------------------------+---------------------+ | Windows Server 2016 | 3.7 | x86-64 | +----------------------------------+----------------------------+---------------------+ -| Windows Server 2019 | 3.7, 3.8, 3.9, 3.10, PyPy3 | x86, 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.8, 3.9 (Cygwin) | x86-64 | +----------------------------------+----------------------------+---------------------+ @@ -493,9 +478,15 @@ These platforms have been reported to work at the versions mentioned. | Operating system | | Tested Python | | Latest tested | | Tested | | | | versions | | Pillow version | | processors | +==================================+===========================+==================+==============+ -| macOS 11.0 Big Sur | 3.7, 3.8, 3.9, 3.10 | 8.4.0 |arm | +| macOS 13 Ventura | 3.7, 3.8, 3.9, 3.10, 3.11 | 9.3.0 |arm | ++----------------------------------+---------------------------+------------------+--------------+ +| macOS 12 Big Sur | 3.7, 3.8, 3.9, 3.10, 3.11 | 9.3.0 |arm | ++----------------------------------+---------------------------+------------------+--------------+ +| macOS 11 Big Sur | 3.7, 3.8, 3.9, 3.10 | 8.4.0 |arm | | +---------------------------+------------------+--------------+ -| | 3.6, 3.7, 3.8, 3.9, 3.10 | 8.4.0 |x86-64 | +| | 3.7, 3.8, 3.9, 3.10, 3.11 | 9.3.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 | | +---------------------------+------------------+ | @@ -523,6 +514,8 @@ These platforms have been reported to work at the versions mentioned. +----------------------------------+---------------------------+------------------+--------------+ | CentOS 6.3 | 2.7, 3.3 | |x86 | +----------------------------------+---------------------------+------------------+--------------+ +| CentOS 8 | 3.9 | 9.0.0 |x86-64 | ++----------------------------------+---------------------------+------------------+--------------+ | Fedora 23 | 2.7, 3.4 | 3.1.0 |x86-64 | +----------------------------------+---------------------------+------------------+--------------+ | Ubuntu Linux 12.04 LTS (Precise) | | 2.6, 3.2, 3.3, 3.4, 3.5 | 3.4.1 |x86,x86-64 | @@ -554,6 +547,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 00000000000..ed2369259d4 --- /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 00000000000..6058f0524ad --- /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/ExifTags.rst b/docs/reference/ExifTags.rst index 4567d4d3e79..464ab77ea35 100644 --- a/docs/reference/ExifTags.rst +++ b/docs/reference/ExifTags.rst @@ -4,14 +4,56 @@ :py:mod:`~PIL.ExifTags` Module ============================== -The :py:mod:`~PIL.ExifTags` module exposes two dictionaries which -provide constants and clear-text names for various well-known EXIF tags. +The :py:mod:`~PIL.ExifTags` module exposes several ``enum.IntEnum`` classes +which provide constants and clear-text names for various well-known EXIF tags. + +.. py:data:: Base + + >>> from PIL.ExifTags import Base + >>> Base.ImageDescription.value + 270 + >>> Base(270).name + 'ImageDescription' + +.. py:data:: GPS + + >>> from PIL.ExifTags import GPS + >>> GPS.GPSDestLatitude.value + 20 + >>> GPS(20).name + 'GPSDestLatitude' + +.. py:data:: Interop + + >>> from PIL.ExifTags import Interop + >>> Interop.RelatedImageFileFormat.value + 4096 + >>> Interop(4096).name + 'RelatedImageFileFormat' + +.. py:data:: IFD + + >>> from PIL.ExifTags import IFD + >>> IFD.Exif.value + 34665 + >>> IFD(34665).name + 'Exif + +.. py:data:: LightSource + + >>> from PIL.ExifTags import LightSource + >>> LightSource.Unknown.value + 0 + >>> LightSource(0).name + 'Unknown' + +Two of these values are also exposed as dictionaries. .. py:data:: TAGS :type: dict - The TAG dictionary maps 16-bit integer EXIF tag enumerations to - descriptive string names. For instance: + The TAGS dictionary maps 16-bit integer EXIF tag enumerations to + descriptive string names. For instance: >>> from PIL.ExifTags import TAGS >>> TAGS[0x010e] @@ -20,8 +62,8 @@ provide constants and clear-text names for various well-known EXIF tags. .. py:data:: GPSTAGS :type: dict - The GPSTAGS dictionary maps 8-bit integer EXIF gps enumerations to - descriptive string names. For instance: + The GPSTAGS dictionary maps 8-bit integer EXIF GPS enumerations to + descriptive string names. For instance: >>> from PIL.ExifTags import GPSTAGS >>> GPSTAGS[20] diff --git a/docs/reference/Image.rst b/docs/reference/Image.rst index c80b28a984b..7f6f666c33c 100644 --- a/docs/reference/Image.rst +++ b/docs/reference/Image.rst @@ -53,9 +53,9 @@ Functions To protect against potential DOS attacks caused by "`decompression bombs`_" (i.e. malicious files which decompress into a huge amount of data and are designed to crash or cause disruption by using up a lot of memory), Pillow will issue a ``DecompressionBombWarning`` if the number of pixels in an - image is over a certain limit, :py:data:`PIL.Image.MAX_IMAGE_PIXELS`. + image is over a certain limit, :py:data:`MAX_IMAGE_PIXELS`. - This threshold can be changed by setting :py:data:`PIL.Image.MAX_IMAGE_PIXELS`. It can be disabled + This threshold can be changed by setting :py:data:`MAX_IMAGE_PIXELS`. It can be disabled by setting ``Image.MAX_IMAGE_PIXELS = None``. If desired, the warning can be turned into an error with @@ -63,7 +63,7 @@ Functions ``warnings.simplefilter('ignore', Image.DecompressionBombWarning)``. See also `the logging documentation`_ to have warnings output to the logging facility instead of stderr. - If the number of pixels is greater than twice :py:data:`PIL.Image.MAX_IMAGE_PIXELS`, then a + If the number of pixels is greater than twice :py:data:`MAX_IMAGE_PIXELS`, then a ``DecompressionBombError`` will be raised instead. .. _decompression bombs: https://en.wikipedia.org/wiki/Zip_bomb @@ -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 @@ -254,7 +255,8 @@ This rotates the input image by ``theta`` degrees counter clockwise: .. automethod:: PIL.Image.Image.transform .. automethod:: PIL.Image.Image.transpose -This flips the input image by using the :data:`FLIP_LEFT_RIGHT` method. +This flips the input image by using the :data:`Transpose.FLIP_LEFT_RIGHT` +method. .. code-block:: python @@ -263,9 +265,9 @@ This flips the input image by using the :data:`FLIP_LEFT_RIGHT` method. with Image.open("hopper.jpg") as im: # Flip the image from left to right - im_flipped = im.transpose(method=Image.FLIP_LEFT_RIGHT) + im_flipped = im.transpose(method=Image.Transpose.FLIP_LEFT_RIGHT) # To flip the image from top to bottom, - # use the method "Image.FLIP_TOP_BOTTOM" + # use the method "Image.Transpose.FLIP_TOP_BOTTOM" .. automethod:: PIL.Image.Image.verify @@ -389,68 +391,57 @@ Transpose methods Used to specify the :meth:`Image.transpose` method to use. -.. data:: FLIP_LEFT_RIGHT -.. data:: FLIP_TOP_BOTTOM -.. data:: ROTATE_90 -.. data:: ROTATE_180 -.. data:: ROTATE_270 -.. data:: TRANSPOSE -.. data:: TRANSVERSE +.. autoclass:: Transpose + :members: + :undoc-members: Transform methods ^^^^^^^^^^^^^^^^^ Used to specify the :meth:`Image.transform` method to use. -.. data:: AFFINE +.. py:class:: Transform + + .. py:attribute:: AFFINE - Affine transform + Affine transform -.. data:: EXTENT + .. py:attribute:: EXTENT - Cut out a rectangular subregion + Cut out a rectangular subregion -.. data:: PERSPECTIVE + .. py:attribute:: PERSPECTIVE - Perspective transform + Perspective transform -.. data:: QUAD + .. py:attribute:: QUAD - Map a quadrilateral to a rectangle + Map a quadrilateral to a rectangle -.. data:: MESH + .. py:attribute:: MESH - Map a number of source quadrilaterals in one operation + Map a number of source quadrilaterals in one operation Resampling filters ^^^^^^^^^^^^^^^^^^ See :ref:`concept-filters` for details. -.. data:: NEAREST - :noindex: -.. data:: BOX - :noindex: -.. data:: BILINEAR - :noindex: -.. data:: HAMMING - :noindex: -.. data:: BICUBIC - :noindex: -.. data:: LANCZOS - :noindex: +.. autoclass:: Resampling + :members: + :undoc-members: -Some filters are also available under the following names for backwards compatibility: +Some deprecated filters are also available under the following names: .. data:: NONE :noindex: - :value: NEAREST + :value: Resampling.NEAREST .. data:: LINEAR - :value: BILINEAR + :value: Resampling.BILINEAR .. data:: CUBIC - :value: BICUBIC + :value: Resampling.BICUBIC .. data:: ANTIALIAS - :value: LANCZOS + :value: Resampling.LANCZOS Dither modes ^^^^^^^^^^^^ @@ -458,48 +449,56 @@ Dither modes Used to specify the dithering method to use for the :meth:`~Image.convert` and :meth:`~Image.quantize` methods. -.. data:: NONE - :noindex: +.. py:class:: Dither + + .. py:attribute:: NONE + + No dither - No dither + .. py:attribute:: ORDERED -.. comment: (not implemented) - .. data:: ORDERED - .. data:: RASTERIZE + Not implemented -.. data:: FLOYDSTEINBERG + .. py:attribute:: RASTERIZE - Floyd-Steinberg dither + Not implemented + + .. py:attribute:: FLOYDSTEINBERG + + Floyd-Steinberg dither Palettes ^^^^^^^^ Used to specify the pallete to use for the :meth:`~Image.convert` method. -.. data:: WEB -.. data:: ADAPTIVE +.. autoclass:: Palette + :members: + :undoc-members: Quantization methods ^^^^^^^^^^^^^^^^^^^^ Used to specify the quantization method to use for the :meth:`~Image.quantize` method. -.. data:: MEDIANCUT +.. py:class:: Quantize + + .. py:attribute:: MEDIANCUT - Median cut. Default method, except for RGBA images. This method does not support - RGBA images. + Median cut. Default method, except for RGBA images. This method does not support + RGBA images. -.. data:: MAXCOVERAGE + .. py:attribute:: MAXCOVERAGE - Maximum coverage. This method does not support RGBA images. + Maximum coverage. This method does not support RGBA images. -.. data:: FASTOCTREE + .. py:attribute:: FASTOCTREE - Fast octree. Default method for RGBA images. + Fast octree. Default method for RGBA images. -.. data:: LIBIMAGEQUANT + .. py:attribute:: LIBIMAGEQUANT - libimagequant + libimagequant - Check support using :py:func:`PIL.features.check_feature` - with ``feature="libimagequant"``. + Check support using :py:func:`PIL.features.check_feature` with + ``feature="libimagequant"``. diff --git a/docs/reference/ImageCms.rst b/docs/reference/ImageCms.rst index f938e63a0bc..9b9b5e7b29e 100644 --- a/docs/reference/ImageCms.rst +++ b/docs/reference/ImageCms.rst @@ -118,8 +118,8 @@ can be easily displayed in a chromaticity diagram, for example). another profile (usually overridden at run-time, but provided here for DeviceLink and embedded source profiles, see 7.2.15 of ICC.1:2010). - One of ``ImageCms.INTENT_ABSOLUTE_COLORIMETRIC``, ``ImageCms.INTENT_PERCEPTUAL``, - ``ImageCms.INTENT_RELATIVE_COLORIMETRIC`` and ``ImageCms.INTENT_SATURATION``. + One of ``ImageCms.Intent.ABSOLUTE_COLORIMETRIC``, ``ImageCms.Intent.PERCEPTUAL``, + ``ImageCms.Intent.RELATIVE_COLORIMETRIC`` and ``ImageCms.Intent.SATURATION``. .. py:attribute:: profile_id :type: bytes @@ -313,14 +313,14 @@ can be easily displayed in a chromaticity diagram, for example). the CLUT model. The dictionary is indexed by intents - (``ImageCms.INTENT_ABSOLUTE_COLORIMETRIC``, - ``ImageCms.INTENT_PERCEPTUAL``, - ``ImageCms.INTENT_RELATIVE_COLORIMETRIC`` and - ``ImageCms.INTENT_SATURATION``). + (``ImageCms.Intent.ABSOLUTE_COLORIMETRIC``, + ``ImageCms.Intent.PERCEPTUAL``, + ``ImageCms.Intent.RELATIVE_COLORIMETRIC`` and + ``ImageCms.Intent.SATURATION``). The values are 3-tuples indexed by directions - (``ImageCms.DIRECTION_INPUT``, ``ImageCms.DIRECTION_OUTPUT``, - ``ImageCms.DIRECTION_PROOF``). + (``ImageCms.Direction.INPUT``, ``ImageCms.Direction.OUTPUT``, + ``ImageCms.Direction.PROOF``). The elements of the tuple are booleans. If the value is ``True``, that intent is supported for that direction. @@ -331,14 +331,14 @@ can be easily displayed in a chromaticity diagram, for example). Returns a dictionary of all supported intents and directions. The dictionary is indexed by intents - (``ImageCms.INTENT_ABSOLUTE_COLORIMETRIC``, - ``ImageCms.INTENT_PERCEPTUAL``, - ``ImageCms.INTENT_RELATIVE_COLORIMETRIC`` and - ``ImageCms.INTENT_SATURATION``). + (``ImageCms.Intent.ABSOLUTE_COLORIMETRIC``, + ``ImageCms.Intent.PERCEPTUAL``, + ``ImageCms.Intent.RELATIVE_COLORIMETRIC`` and + ``ImageCms.Intent.SATURATION``). The values are 3-tuples indexed by directions - (``ImageCms.DIRECTION_INPUT``, ``ImageCms.DIRECTION_OUTPUT``, - ``ImageCms.DIRECTION_PROOF``). + (``ImageCms.Direction.INPUT``, ``ImageCms.Direction.OUTPUT``, + ``ImageCms.Direction.PROOF``). The elements of the tuple are booleans. If the value is ``True``, that intent is supported for that direction. @@ -352,11 +352,11 @@ can be easily displayed in a chromaticity diagram, for example). Note that you can also get this information for all intents and directions with :py:attr:`.intent_supported`. - :param intent: One of ``ImageCms.INTENT_ABSOLUTE_COLORIMETRIC``, - ``ImageCms.INTENT_PERCEPTUAL``, - ``ImageCms.INTENT_RELATIVE_COLORIMETRIC`` - and ``ImageCms.INTENT_SATURATION``. - :param direction: One of ``ImageCms.DIRECTION_INPUT``, - ``ImageCms.DIRECTION_OUTPUT`` - and ``ImageCms.DIRECTION_PROOF`` + :param intent: One of ``ImageCms.Intent.ABSOLUTE_COLORIMETRIC``, + ``ImageCms.Intent.PERCEPTUAL``, + ``ImageCms.Intent.RELATIVE_COLORIMETRIC`` + and ``ImageCms.Intent.SATURATION``. + :param direction: One of ``ImageCms.Direction.INPUT``, + ``ImageCms.Direction.OUTPUT`` + and ``ImageCms.Direction.PROOF`` :return: Boolean if the intent and direction is supported. diff --git a/docs/reference/ImageDraw.rst b/docs/reference/ImageDraw.rst index b95d8d591a7..9aa26916a90 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. @@ -139,12 +139,50 @@ Functions must be the same as the image mode. If omitted, the mode defaults to the mode of the image. +Attributes +---------- + +.. py:attribute:: ImageDraw.fill + :type: bool + :value: False + + Selects whether :py:attr:`ImageDraw.ink` should be used as a fill or outline color. + +.. py:attribute:: ImageDraw.font + + The current default font. + + Can be set per instance:: + + from PIL import ImageDraw, ImageFont + draw = ImageDraw.Draw(image) + draw.font = ImageFont.truetype("Tests/fonts/FreeMono.ttf") + + Or globally for all future ImageDraw instances:: + + from PIL import ImageDraw, ImageFont + ImageDraw.ImageDraw.font = ImageFont.truetype("Tests/fonts/FreeMono.ttf") + +.. py:attribute:: ImageDraw.fontmode + + The current font drawing mode. + + Set to ``"1"`` to disable antialiasing or ``"L"`` to enable it. + +.. py:attribute:: ImageDraw.ink + :type: int + + The internal representation of the current default color. + Methods ------- .. py:method:: ImageDraw.getfont() - Get the current default font. + Get the current default font, :py:attr:`ImageDraw.font`. + + If the current default font is ``None``, + it is initialized with :py:func:`.ImageFont.load_default`. :returns: An image font. @@ -280,8 +318,8 @@ Methods Draws a rectangle. :param xy: Two points to define the bounding box. Sequence of either - ``[(x0, y0), (x1, y1)]`` or ``[x0, y0, x1, y1]``. The second point - is just outside the drawn rectangle. + ``[(x0, y0), (x1, y1)]`` or ``[x0, y0, x1, y1]``. The bounding box + is inclusive of both endpoints. :param outline: Color to use for the outline. :param fill: Color to use for the fill. :param width: The line width, in pixels. @@ -293,8 +331,8 @@ Methods Draws a rounded rectangle. :param xy: Two points to define the bounding box. Sequence of either - ``[(x0, y0), (x1, y1)]`` or ``[x0, y0, x1, y1]``. The second point - is just outside the drawn rectangle. + ``[(x0, y0), (x1, y1)]`` or ``[x0, y0, x1, y1]``. The bounding box + is inclusive of both endpoints. :param radius: Radius of the corners. :param outline: Color to use for the outline. :param fill: Color to use for the fill. @@ -436,12 +474,16 @@ 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 + + See :ref:`deprecations ` for more information. 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 @@ -482,8 +524,16 @@ Methods .. versionadded:: 6.2.0 + :return: (width, height) + .. py:method:: ImageDraw.multiline_textsize(text, font=None, spacing=4, direction=None, features=None, language=None, stroke_width=0) + .. deprecated:: 9.2.0 + + See :ref:`deprecations ` for more information. + + 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 @@ -530,6 +580,8 @@ Methods .. versionadded:: 6.2.0 + :return: (width, height) + .. py:method:: ImageDraw.textlength(text, font=None, direction=None, features=None, language=None, embedded_color=False) Returns length (in pixels with 1/64 precision) of given text when rendered @@ -597,6 +649,7 @@ Methods It should be a `BCP 47 language code`_. Requires libraqm. :param embedded_color: Whether to use font embedded color glyphs (COLR, CBDT, SBIX). + :return: Width for horizontal, height for vertical text. .. py:method:: ImageDraw.textbbox(xy, text, font=None, anchor=None, spacing=4, align="left", direction=None, features=None, language=None, stroke_width=0, embedded_color=False) @@ -646,6 +699,7 @@ Methods Requires libraqm. :param stroke_width: The width of the text stroke. :param embedded_color: Whether to use font embedded color glyphs (COLR, CBDT, SBIX). + :return: ``(left, top, right, bottom)`` bounding box .. py:method:: ImageDraw.multiline_textbbox(xy, text, font=None, anchor=None, spacing=4, align="left", direction=None, features=None, language=None, stroke_width=0, embedded_color=False) @@ -689,6 +743,7 @@ Methods Requires libraqm. :param stroke_width: The width of the text stroke. :param embedded_color: Whether to use font embedded color glyphs (COLR, CBDT, SBIX). + :return: ``(left, top, right, bottom)`` bounding box .. py:method:: getdraw(im=None, hints=None) @@ -720,4 +775,4 @@ Methods homogeneous, but similar, colors. .. _BCP 47 language code: https://www.w3.org/International/articles/language-tags/ -.. _OpenType docs: https://docs.microsoft.com/en-us/typography/opentype/spec/featurelist +.. _OpenType docs: https://learn.microsoft.com/en-us/typography/opentype/spec/featurelist diff --git a/docs/reference/ImageFile.rst b/docs/reference/ImageFile.rst index e0ce389e862..3cf59c610c8 100644 --- a/docs/reference/ImageFile.rst +++ b/docs/reference/ImageFile.rst @@ -40,8 +40,16 @@ Classes .. autoclass:: PIL.ImageFile.Parser() :members: +.. autoclass:: PIL.ImageFile.PyCodec() + :members: + .. autoclass:: PIL.ImageFile.PyDecoder() :members: + :show-inheritance: + +.. autoclass:: PIL.ImageFile.PyEncoder() + :members: + :show-inheritance: .. autoclass:: PIL.ImageFile.ImageFile() :member-order: bysource diff --git a/docs/reference/ImageFont.rst b/docs/reference/ImageFont.rst index 5f718ce19e4..516fa63a783 100644 --- a/docs/reference/ImageFont.rst +++ b/docs/reference/ImageFont.rst @@ -56,16 +56,17 @@ Methods .. autoclass:: PIL.ImageFont.TransposedFont :members: + :undoc-members: Constants --------- -.. data:: PIL.ImageFont.LAYOUT_BASIC +.. data:: PIL.ImageFont.Layout.BASIC Use basic text layout for TrueType font. Advanced features such as text direction are not supported. -.. data:: PIL.ImageFont.LAYOUT_RAQM +.. data:: PIL.ImageFont.Layout.RAQM Use Raqm text layout for TrueType font. Advanced features are supported. diff --git a/docs/reference/ImageGrab.rst b/docs/reference/ImageGrab.rst index ac83b225522..3086ba8c311 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/reference/ImageQt.rst b/docs/reference/ImageQt.rst index 66f5880a37e..15d052d1c4e 100644 --- a/docs/reference/ImageQt.rst +++ b/docs/reference/ImageQt.rst @@ -7,6 +7,14 @@ The :py:mod:`~PIL.ImageQt` module contains support for creating PyQt6, PySide6, PyQt5 or PySide2 QImage objects from PIL images. +`Qt 5 reached end-of-life `_ on 2020-12-08 for +open-source users (and will reach EOL on 2023-12-08 for commercial licence holders). + +Support for PyQt5 and PySide2 has been deprecated from ``ImageQt`` and will be removed +in Pillow 10 (2023-07-01). Upgrade to +`PyQt6 `_ or +`PySide6 `_ instead. + .. versionadded:: 1.1.6 .. py:class:: ImageQt(image) diff --git a/docs/reference/ImageSequence.rst b/docs/reference/ImageSequence.rst index 1bfb554b653..f2e7d9edd28 100644 --- a/docs/reference/ImageSequence.rst +++ b/docs/reference/ImageSequence.rst @@ -25,3 +25,8 @@ The :py:class:`~PIL.ImageSequence.Iterator` class .. autoclass:: PIL.ImageSequence.Iterator :members: + +Functions +--------- + +.. autofunction:: PIL.ImageSequence.all_frames diff --git a/docs/reference/ImageShow.rst b/docs/reference/ImageShow.rst index 45b50c8469b..5cedede69e6 100644 --- a/docs/reference/ImageShow.rst +++ b/docs/reference/ImageShow.rst @@ -23,6 +23,9 @@ All default viewers convert the image to be shown to PNG format. .. autoclass:: PIL.ImageShow.EogViewer .. autoclass:: PIL.ImageShow.XVViewer + To provide maximum functionality on Unix-based systems, temporary files created + from images will not be automatically removed by Pillow. + .. autofunction:: PIL.ImageShow.register .. autoclass:: PIL.ImageShow.Viewer :member-order: bysource diff --git a/docs/reference/ImageStat.rst b/docs/reference/ImageStat.rst index 5bb73529635..f61d123131a 100644 --- a/docs/reference/ImageStat.rst +++ b/docs/reference/ImageStat.rst @@ -14,6 +14,16 @@ for a region of an image. statistics. You can also pass in a previously calculated histogram. :param image: A PIL image, or a precalculated histogram. + + .. note:: + + For a PIL image, calculations rely on the + :py:meth:`~PIL.Image.Image.histogram` method. The pixel counts are + grouped into 256 bins, even if the image has more than 8 bits per + channel. So ``I`` and ``F`` mode images have a maximum ``mean``, + ``median`` and ``rms`` of 255, and cannot have an ``extrema`` maximum + of more than 255. + :param mask: An optional mask. .. py:attribute:: extrema diff --git a/docs/reference/PixelAccess.rst b/docs/reference/PixelAccess.rst index 173a0bcc0e6..b234b7b4efb 100644 --- a/docs/reference/PixelAccess.rst +++ b/docs/reference/PixelAccess.rst @@ -6,7 +6,13 @@ The PixelAccess class provides read and write access to :py:class:`PIL.Image` data at a pixel level. -.. note:: Accessing individual pixels is fairly slow. If you are looping over all of the pixels in an image, there is likely a faster way using other parts of the Pillow API. +.. note:: Accessing individual pixels is fairly slow. If you are + looping over all of the pixels in an image, there is likely + a faster way using other parts of the Pillow API. + + :mod:`~PIL.Image`, :mod:`~PIL.ImageChops` and :mod:`~PIL.ImageOps` + have methods for many standard operations. If you wish to perform + a custom mapping, check out :py:meth:`~PIL.Image.Image.point`. Example ------- @@ -39,7 +45,7 @@ Access using negative indexes is also possible. :py:class:`PixelAccess` Class ------------------------------------ +----------------------------- .. class:: PixelAccess @@ -67,7 +73,7 @@ Access using negative indexes is also possible. Modifies the pixel at x,y. The color is given as a single numerical value for single band images, and a tuple for multi-band images. In addition to this, RGB and RGBA tuples - are accepted for P images. + are accepted for P and PA images. :param xy: The pixel coordinate, given as (x, y). :param color: The pixel value according to its mode. e.g. tuple (r, g, b) for RGB mode) diff --git a/docs/reference/PyAccess.rst b/docs/reference/PyAccess.rst index e77944d2001..f9eb9b52418 100644 --- a/docs/reference/PyAccess.rst +++ b/docs/reference/PyAccess.rst @@ -7,8 +7,12 @@ The :py:mod:`~PIL.PyAccess` module provides a CFFI/Python implementation of the :ref:`PixelAccess`. This implementation is far faster on PyPy than the PixelAccess version. .. note:: Accessing individual pixels is fairly slow. If you are - looping over all of the pixels in an image, there is likely - a faster way using other parts of the Pillow API. + looping over all of the pixels in an image, there is likely + a faster way using other parts of the Pillow API. + + :mod:`~PIL.Image`, :mod:`~PIL.ImageChops` and :mod:`~PIL.ImageOps` + have methods for many standard operations. If you wish to perform + a custom mapping, check out :py:meth:`~PIL.Image.Image.point`. Example ------- diff --git a/docs/reference/TiffTags.rst b/docs/reference/TiffTags.rst index 1441185dd14..7cb7d16ae47 100644 --- a/docs/reference/TiffTags.rst +++ b/docs/reference/TiffTags.rst @@ -10,6 +10,10 @@ metadata tag numbers, names, and type information. .. method:: lookup(tag) :param tag: Integer tag number + :param group: Which :py:data:`~PIL.TiffTags.TAGS_V2_GROUPS` to look in + + .. versionadded:: 8.3.0 + :returns: Taginfo namedtuple, From the :py:data:`~PIL.TiffTags.TAGS_V2` info if possible, otherwise just populating the value and name from :py:data:`~PIL.TiffTags.TAGS`. If the tag is not recognized, "unknown" is returned for the name @@ -42,6 +46,16 @@ metadata tag numbers, names, and type information. .. versionadded:: 3.0.0 +.. py:data:: PIL.TiffTags.TAGS_V2_GROUPS + :type: dict + + :py:data:`~PIL.TiffTags.TAGS_V2` is one dimensional and + doesn't account for the fact that tags actually exist in + `different groups `_. + This dictionary is used when the tag in question is part of a group. + +.. versionadded:: 8.3.0 + .. py:data:: PIL.TiffTags.TAGS :type: dict diff --git a/docs/reference/c_extension_debugging.rst b/docs/reference/c_extension_debugging.rst index 2ba95b8a6bc..dc4c2bf94d0 100644 --- a/docs/reference/c_extension_debugging.rst +++ b/docs/reference/c_extension_debugging.rst @@ -53,7 +53,7 @@ Then ``sudo apt-get update && sudo apt-get install libtiff5-dbgsym`` virtualenv -p python3.8-dbg ~/vpy38-dbg source ~/vpy38-dbg/bin/activate - cd ~/Pillow && pip install -r requirements.txt && make install + cd ~/Pillow && make install Test Case --------- diff --git a/docs/reference/features.rst b/docs/reference/features.rst index 0a6381098da..c6619306186 100644 --- a/docs/reference/features.rst +++ b/docs/reference/features.rst @@ -57,7 +57,7 @@ Support for the following features can be checked: * ``transp_webp``: Support for transparency in WebP images. * ``webp_mux``: (compile time) Support for EXIF data in WebP images. * ``webp_anim``: (compile time) Support for animated WebP images. -* ``raqm``: Raqm library, required for ``ImageFont.LAYOUT_RAQM`` in :py:func:`PIL.ImageFont.truetype`. Run-time version number is available for Raqm 0.7.0 or newer. +* ``raqm``: Raqm library, required for ``ImageFont.Layout.RAQM`` in :py:func:`PIL.ImageFont.truetype`. Run-time version number is available for Raqm 0.7.0 or newer. * ``libimagequant``: (compile time) ImageQuant quantization support in :py:func:`PIL.Image.Image.quantize`. Run-time version number is available. * ``xcb``: (compile time) Support for X11 in :py:func:`PIL.ImageGrab.grab` via the XCB library. diff --git a/docs/reference/internal_modules.rst b/docs/reference/internal_modules.rst index 1105ff76e1f..363a67d9b02 100644 --- a/docs/reference/internal_modules.rst +++ b/docs/reference/internal_modules.rst @@ -9,6 +9,14 @@ Internal Modules :undoc-members: :show-inheritance: +:mod:`~PIL._deprecate` Module +----------------------------- + +.. automodule:: PIL._deprecate + :members: + :undoc-members: + :show-inheritance: + :mod:`~PIL._tkinter_finder` Module ---------------------------------- diff --git a/docs/reference/plugins.rst b/docs/reference/plugins.rst index 7094f87846c..fcf4514a84d 100644 --- a/docs/reference/plugins.rst +++ b/docs/reference/plugins.rst @@ -41,10 +41,10 @@ Plugin reference :undoc-members: :show-inheritance: -:mod:`~PIL.FitsStubImagePlugin` Module +:mod:`~PIL.FitsImagePlugin` Module -------------------------------------- -.. automodule:: PIL.FitsStubImagePlugin +.. automodule:: PIL.FitsImagePlugin :members: :undoc-members: :show-inheritance: @@ -230,8 +230,7 @@ Plugin reference .. automodule:: PIL.PngImagePlugin :members: ChunkStream, PngImageFile, PngStream, getchunks, is_cid, putchunk, - MAX_TEXT_CHUNK, MAX_TEXT_MEMORY, APNG_BLEND_OP_SOURCE, APNG_BLEND_OP_OVER, - APNG_DISPOSE_OP_NONE, APNG_DISPOSE_OP_BACKGROUND, APNG_DISPOSE_OP_PREVIOUS + Blend, Disposal, MAX_TEXT_CHUNK, MAX_TEXT_MEMORY :undoc-members: :show-inheritance: :member-order: groupwise diff --git a/docs/releasenotes/2.7.0.rst b/docs/releasenotes/2.7.0.rst index 660d331640c..dda814c1f7d 100644 --- a/docs/releasenotes/2.7.0.rst +++ b/docs/releasenotes/2.7.0.rst @@ -111,16 +111,14 @@ downscaling with libjpeg, which uses supersampling internally, not convolutions. Image transposition ------------------- -A new method :py:data:`PIL.Image.TRANSPOSE` has been added for the +A new method ``TRANSPOSE`` has been added for the :py:meth:`~PIL.Image.Image.transpose` operation in addition to -:py:data:`~PIL.Image.FLIP_LEFT_RIGHT`, :py:data:`~PIL.Image.FLIP_TOP_BOTTOM`, -:py:data:`~PIL.Image.ROTATE_90`, :py:data:`~PIL.Image.ROTATE_180`, -:py:data:`~PIL.Image.ROTATE_270`. :py:data:`~PIL.Image.TRANSPOSE` is an algebra -transpose, with an image reflected across its main diagonal. - -The speed of :py:data:`~PIL.Image.ROTATE_90`, :py:data:`~PIL.Image.ROTATE_270` -and :py:data:`~PIL.Image.TRANSPOSE` has been significantly improved for large -images which don't fit in the processor cache. +``FLIP_LEFT_RIGHT``, ``FLIP_TOP_BOTTOM``, ``ROTATE_90``, ``ROTATE_180``, +``ROTATE_270``. ``TRANSPOSE`` is an algebra transpose, with an image reflected +across its main diagonal. + +The speed of ``ROTATE_90``, ``ROTATE_270`` and ``TRANSPOSE`` has been significantly +improved for large images which don't fit in the processor cache. Gaussian blur and unsharp mask ------------------------------ diff --git a/docs/releasenotes/5.2.0.rst b/docs/releasenotes/5.2.0.rst index 75e8da6554d..d9b8f0fb7c8 100644 --- a/docs/releasenotes/5.2.0.rst +++ b/docs/releasenotes/5.2.0.rst @@ -105,7 +105,7 @@ Resolve confusion getting PIL / Pillow version string Re: "version constants deprecated" listed above, as user gnbl notes in #3082: - it's confusing that PIL.VERSION returns the version string of the former PIL instead of Pillow's -- there does not seem to be documentation on this version number (why this, will it ever change, ..) e.g. at https://pillow.readthedocs.io/en/5.1.x/about.html#why-a-fork +- ReadTheDocs documentation is missing for some version branches (why is this, will it ever change, ...) - it's confusing that PIL.version is a module and does not return the version information directly or hints on how to get it - the package information header is essentially useless (placeholder, does not even mention Pillow, nor the version) - PIL._version module documentation comment could explain how to access the version information diff --git a/docs/releasenotes/8.0.0.rst b/docs/releasenotes/8.0.0.rst index 2ff9b3799ba..fe26580474d 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 f2be128bb90..a19da361aaa 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 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -119,15 +119,16 @@ Google's `OSS-Fuzz`_ project for finding this issue. Restrict builtins available to ImageMath.eval ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -To limit :py:class:`PIL.ImageMath` to working with images, Pillow will now restrict the -builtins available to :py:meth:`PIL.ImageMath.eval`. This will help prevent problems -arising if users evaluate arbitrary expressions, such as -``ImageMath.eval("exec(exit())")``. CVE TBD +:cve:`CVE-2022-22817`: To limit :py:class:`PIL.ImageMath` to working with images, Pillow +will now restrict the builtins available to :py:meth:`PIL.ImageMath.eval`. This will +help prevent problems arising if users evaluate arbitrary expressions, such as +``ImageMath.eval("exec(exit())")``. Fixed ImagePath.Path array handling ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -CWE-126 and CWE-665 were found when initializing ``ImagePath.Path``. CVEs TBD +:cve:`CVE-2022-22815` (:cwe:`CWE-126`) and :cve:`CVE-2022-22816` (:cwe:`CWE-665`) were +found when initializing ``ImagePath.Path``. .. _OSS-Fuzz: https://github.com/google/oss-fuzz @@ -148,6 +149,9 @@ Switched to libjpeg-turbo in macOS and Linux wheels The Pillow wheels from PyPI for macOS and Linux have switched from libjpeg to libjpeg-turbo. It is a fork of libjpeg, popular for its speed. +Because different JPEG decoders load images differently, JPEG pixels may be +altered slightly with this change. + Added support for pickling TrueType fonts ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/docs/releasenotes/9.0.1.rst b/docs/releasenotes/9.0.1.rst new file mode 100644 index 00000000000..c1feee088b6 --- /dev/null +++ b/docs/releasenotes/9.0.1.rst @@ -0,0 +1,23 @@ +9.0.1 +----- + +Security +======== + +This release addresses several security problems. + +:cve:`CVE-2022-24303`: If the path to the temporary directory on Linux or macOS +contained a space, this would break removal of the temporary image file after +``im.show()`` (and related actions), and potentially remove an unrelated file. This +has been present since PIL. + +:cve:`CVE-2022-22817`: While Pillow 9.0 restricted top-level builtins available to +:py:meth:`PIL.ImageMath.eval`, it did not prevent builtins available to lambda +expressions. These are now also restricted. + +Other Changes +============= + +Pillow 9.0 added support for ``xdg-open`` as an image viewer, but there have been +reports that the temporary image file was removed too quickly to be loaded into the +final application. A delay has been added. diff --git a/docs/releasenotes/9.1.0.rst b/docs/releasenotes/9.1.0.rst new file mode 100644 index 00000000000..e97b58a41cd --- /dev/null +++ b/docs/releasenotes/9.1.0.rst @@ -0,0 +1,233 @@ +9.1.0 +----- + +API Changes +=========== + +Raise an error when performing a negative crop +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Performing a negative crop on an image previously just returned a ``(0, 0)`` image. Now +it will raise a ``ValueError``, to help reduce confusion if a user has unintentionally +provided the wrong arguments. + +Added specific error if path coordinate type is incorrect +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Rather than returning a ``SystemError``, passing the incorrect types of coordinates into +a path will now raise a more specific ``ValueError``, with the message "incorrect +coordinate type". + +Replace requirements.txt with extras +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Rather than installing all dependencies for docs and tests via ``requirements.txt``, +``extras_require`` is used instead. This installs only those needed and at the same +time as installing Pillow. + +For example: + +.. code-block:: bash + + # Install with dependencies for tests: + python3 -m pip install .[tests] + + # Or for building docs: + python3 -m pip install .[docs] + + # Or for all: + python3 -m pip install .[docs,tests] + +On macOS, the last argument may need to be wrapped in quotes, e.g. +``python3 -m pip install ".[tests]"`` + +Therefore ``requirements.txt`` has been removed along with the ``make install-req`` +command for installing its contents. + +Deprecations +============ + +Constants +^^^^^^^^^ + +A number of constants have been deprecated and will be removed in Pillow 10.0.0 +(2023-07-01). Instead, ``enum.IntEnum`` classes have been added. + +.. note:: + + Some of these deprecations were restored in Pillow 9.4.0. See + :ref:`restored-image-constants` + +===================================================== ============================================================ +Deprecated Use instead +===================================================== ============================================================ +``Image.NONE`` Either ``Image.Dither.NONE`` or ``Image.Resampling.NEAREST`` +``Image.NEAREST`` Either ``Image.Dither.NONE`` or ``Image.Resampling.NEAREST`` +``Image.ORDERED`` ``Image.Dither.ORDERED`` +``Image.RASTERIZE`` ``Image.Dither.RASTERIZE`` +``Image.FLOYDSTEINBERG`` ``Image.Dither.FLOYDSTEINBERG`` +``Image.WEB`` ``Image.Palette.WEB`` +``Image.ADAPTIVE`` ``Image.Palette.ADAPTIVE`` +``Image.AFFINE`` ``Image.Transform.AFFINE`` +``Image.EXTENT`` ``Image.Transform.EXTENT`` +``Image.PERSPECTIVE`` ``Image.Transform.PERSPECTIVE`` +``Image.QUAD`` ``Image.Transform.QUAD`` +``Image.MESH`` ``Image.Transform.MESH`` +``Image.FLIP_LEFT_RIGHT`` ``Image.Transpose.FLIP_LEFT_RIGHT`` +``Image.FLIP_TOP_BOTTOM`` ``Image.Transpose.FLIP_TOP_BOTTOM`` +``Image.ROTATE_90`` ``Image.Transpose.ROTATE_90`` +``Image.ROTATE_180`` ``Image.Transpose.ROTATE_180`` +``Image.ROTATE_270`` ``Image.Transpose.ROTATE_270`` +``Image.TRANSPOSE`` ``Image.Transpose.TRANSPOSE`` +``Image.TRANSVERSE`` ``Image.Transpose.TRANSVERSE`` +``Image.BOX`` ``Image.Resampling.BOX`` +``Image.BILINEAR`` ``Image.Resampling.BILINEAR`` +``Image.LINEAR`` ``Image.Resampling.BILINEAR`` +``Image.HAMMING`` ``Image.Resampling.HAMMING`` +``Image.BICUBIC`` ``Image.Resampling.BICUBIC`` +``Image.CUBIC`` ``Image.Resampling.BICUBIC`` +``Image.LANCZOS`` ``Image.Resampling.LANCZOS`` +``Image.ANTIALIAS`` ``Image.Resampling.LANCZOS`` +``Image.MEDIANCUT`` ``Image.Quantize.MEDIANCUT`` +``Image.MAXCOVERAGE`` ``Image.Quantize.MAXCOVERAGE`` +``Image.FASTOCTREE`` ``Image.Quantize.FASTOCTREE`` +``Image.LIBIMAGEQUANT`` ``Image.Quantize.LIBIMAGEQUANT`` +``ImageCms.INTENT_PERCEPTUAL`` ``ImageCms.Intent.PERCEPTUAL`` +``ImageCms.INTENT_RELATIVE_COLORMETRIC`` ``ImageCms.Intent.RELATIVE_COLORMETRIC`` +``ImageCms.INTENT_SATURATION`` ``ImageCms.Intent.SATURATION`` +``ImageCms.INTENT_ABSOLUTE_COLORIMETRIC`` ``ImageCms.Intent.ABSOLUTE_COLORIMETRIC`` +``ImageCms.DIRECTION_INPUT`` ``ImageCms.Direction.INPUT`` +``ImageCms.DIRECTION_OUTPUT`` ``ImageCms.Direction.OUTPUT`` +``ImageCms.DIRECTION_PROOF`` ``ImageCms.Direction.PROOF`` +``ImageFont.LAYOUT_BASIC`` ``ImageFont.Layout.BASIC`` +``ImageFont.LAYOUT_RAQM`` ``ImageFont.Layout.RAQM`` +``BlpImagePlugin.BLP_FORMAT_JPEG`` ``BlpImagePlugin.Format.JPEG`` +``BlpImagePlugin.BLP_ENCODING_UNCOMPRESSED`` ``BlpImagePlugin.Encoding.UNCOMPRESSED`` +``BlpImagePlugin.BLP_ENCODING_DXT`` ``BlpImagePlugin.Encoding.DXT`` +``BlpImagePlugin.BLP_ENCODING_UNCOMPRESSED_RAW_RGBA`` ``BlpImagePlugin.Encoding.UNCOMPRESSED_RAW_RGBA`` +``BlpImagePlugin.BLP_ALPHA_ENCODING_DXT1`` ``BlpImagePlugin.AlphaEncoding.DXT1`` +``BlpImagePlugin.BLP_ALPHA_ENCODING_DXT3`` ``BlpImagePlugin.AlphaEncoding.DXT3`` +``BlpImagePlugin.BLP_ALPHA_ENCODING_DXT5`` ``BlpImagePlugin.AlphaEncoding.DXT5`` +``FtexImagePlugin.FORMAT_DXT1`` ``FtexImagePlugin.Format.DXT1`` +``FtexImagePlugin.FORMAT_UNCOMPRESSED`` ``FtexImagePlugin.Format.UNCOMPRESSED`` +``PngImagePlugin.APNG_DISPOSE_OP_NONE`` ``PngImagePlugin.Disposal.OP_NONE`` +``PngImagePlugin.APNG_DISPOSE_OP_BACKGROUND`` ``PngImagePlugin.Disposal.OP_BACKGROUND`` +``PngImagePlugin.APNG_DISPOSE_OP_PREVIOUS`` ``PngImagePlugin.Disposal.OP_PREVIOUS`` +``PngImagePlugin.APNG_BLEND_OP_SOURCE`` ``PngImagePlugin.Blend.OP_SOURCE`` +``PngImagePlugin.APNG_BLEND_OP_OVER`` ``PngImagePlugin.Blend.OP_OVER`` +===================================================== ============================================================ + +ImageShow.Viewer.show_file file argument +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +The ``file`` argument in :py:meth:`~PIL.ImageShow.Viewer.show_file()` has been +deprecated and will be removed in Pillow 10.0.0 (2023-07-01). It has been replaced by +``path``. + +In effect, ``viewer.show_file("test.jpg")`` will continue to work unchanged. +``viewer.show_file(file="test.jpg")`` will raise a deprecation warning, and suggest +``viewer.show_file(path="test.jpg")`` instead. + +FitsStubImagePlugin +^^^^^^^^^^^^^^^^^^^ + +.. deprecated:: 9.1.0 + +The stub image plugin ``FitsStubImagePlugin`` has been deprecated and will be removed in +Pillow 10.0.0 (2023-07-01). FITS images can be read without a handler through +:mod:`~PIL.FitsImagePlugin` instead. + +API Additions +============= + +Added get_photoshop_blocks() to parse Photoshop TIFF tag +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +:py:meth:`~PIL.TiffImagePlugin.TiffImageFile.get_photoshop_blocks` has been added, to +allow users to determine what Photoshop "Image Resource Blocks" are contained within an +image. The keys of the returned dictionary are the image resource IDs. + +At present, the information within each block is merely returned as a dictionary with a +"data" entry. This will allow more useful information to be added in the future without +breaking backwards compatibility. + +Added mct and no_jp2 options for saving JPEG 2000 +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +The :py:meth:`PIL.Image.Image.save` method now supports the following options for +JPEG 2000: + +**mct** + If ``1`` then enable multiple component transformation when encoding, + otherwise use ``0`` for no component transformation (default). If MCT is + enabled and ``irreversible`` is ``True`` then the Irreversible Color + Transformation will be applied, otherwise encoding will use the + Reversible Color Transformation. MCT works best with a ``mode`` of + ``RGB`` and is only applicable when the image data has 3 components. + +**no_jp2** + If ``True`` then don't wrap the raw codestream in the JP2 file format when + saving, otherwise the extension of the filename will be used to determine + the format (default). + +Added PyEncoder +^^^^^^^^^^^^^^^ + +:py:class:`~PIL.ImageFile.PyEncoder` has been added, allowing for file encoders to be +written in Python. See :ref:`Writing Your Own File Codec in Python` for +more information. + +GifImagePlugin loading strategy +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Pillow 9.0.0 introduced the conversion of subsequent GIF frames to ``RGB`` or ``RGBA``. This +behaviour can now be changed so that the first ``P`` frame is converted to ``RGB`` as +well. + +.. code-block:: python + + from PIL import GifImagePlugin + GifImagePlugin.LOADING_STRATEGY = GifImagePlugin.LoadingStrategy.RGB_ALWAYS + +Or subsequent frames can be kept in ``P`` mode as long as there is only a single +palette. + +.. code-block:: python + + from PIL import GifImagePlugin + GifImagePlugin.LOADING_STRATEGY = GifImagePlugin.LoadingStrategy.RGB_AFTER_DIFFERENT_PALETTE_ONLY + +Other Changes +============= + +musllinux wheels +^^^^^^^^^^^^^^^^ + +Pillow now builds binary wheels for musllinux, suitable for Linux distributions based on the musl C standard library such as Alpine +(rather than the glibc library used by manylinux wheels). See :pep:`656`. + +ImageShow temporary files on Unix +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +When calling :py:meth:`~PIL.Image.Image.show` or using :py:mod:`~PIL.ImageShow`, +a temporary file is created from the image. On Unix, Pillow will no longer delete these +files, and instead leave it to the operating system to do so. + +Image._repr_pretty_ +^^^^^^^^^^^^^^^^^^^ + +``im._repr_pretty_`` has been added to provide a representation of an image without the +identity of the object. This allows Jupyter to describe an image and have that +description stay the same on subsequent executions of the same code. + +Added BigTIFF reading +^^^^^^^^^^^^^^^^^^^^^ + +Support has been added for reading BigTIFF images. + +Added BLP saving +^^^^^^^^^^^^^^^^ + +Support has been added for saving BLP images. ``blp_version`` can be used to specify +whether the image should be saved as BLP1 or BLP2, e.g. +``im.save("out.blp", blp_version="BLP1")``. By default, BLP2 will be used. diff --git a/docs/releasenotes/9.1.1.rst b/docs/releasenotes/9.1.1.rst new file mode 100644 index 00000000000..f8b155f3d6a --- /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 new file mode 100644 index 00000000000..6dbfa2702eb --- /dev/null +++ b/docs/releasenotes/9.2.0.rst @@ -0,0 +1,120 @@ +9.2.0 +----- + +Deprecations +============ + +PyQt5 and PySide2 +^^^^^^^^^^^^^^^^^ + +.. deprecated:: 9.2.0 + +`Qt 5 reached end-of-life `_ on 2020-12-08 for +open-source users (and will reach EOL on 2023-12-08 for commercial licence holders). + +Support for PyQt5 and PySide2 has been deprecated from ``ImageQt`` and will be removed +in Pillow 10 (2023-07-01). Upgrade to +`PyQt6 `_ or +`PySide6 `_ instead. + +FreeTypeFont.getmask2 fill parameter +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. deprecated:: 9.2.0 + +The undocumented ``fill`` parameter of :py:meth:`.FreeTypeFont.getmask2` +has been deprecated and will be removed in Pillow 10 (2023-07-01). + +PhotoImage.paste box parameter +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. deprecated:: 9.2.0 + +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` +=========================================================================== ============================================================================================================= + +Previous code: + +.. code-block:: python + + from PIL import Image, ImageDraw, ImageFont + + font = ImageFont.truetype("Tests/fonts/FreeMono.ttf") + width, height = font.getsize("Hello world") + left, top = font.getoffset("Hello world") + + im = Image.new("RGB", (100, 100)) + draw = ImageDraw.Draw(im) + width, height = draw.textsize("Hello world") + + width, height = font.getsize_multiline("Hello\nworld") + width, height = draw.multiline_textsize("Hello\nworld") + +Use instead: + +.. code-block:: python + + from PIL import Image, ImageDraw, ImageFont + + font = ImageFont.truetype("Tests/fonts/FreeMono.ttf") + left, top, right, bottom = font.getbbox("Hello world") + width, height = right - left, bottom - top + + im = Image.new("RGB", (100, 100)) + draw = ImageDraw.Draw(im) + width = draw.textlength("Hello world") + + left, top, right, bottom = draw.multiline_textbbox((0, 0), "Hello\nworld") + width, height = right - left, bottom - top + +API Additions +============= + +Image.apply_transparency +^^^^^^^^^^^^^^^^^^^^^^^^ + +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 +======== + +An additional decompression bomb check has been added for the GIF format. + +Other Changes +============= + +Using gnome-screenshot on Linux +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +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 00000000000..fde2faae3a7 --- /dev/null +++ b/docs/releasenotes/9.3.0.rst @@ -0,0 +1,107 @@ +9.3.0 +----- + +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, ...]) + +Added ExifTags enums +^^^^^^^^^^^^^^^^^^^^ + +The data from :py:data:`~PIL.ExifTags.TAGS` and +:py:data:`~PIL.ExifTags.GPSTAGS` is now also exposed as ``enum.IntEnum`` +classes: :py:data:`~PIL.ExifTags.Base` and :py:data:`~PIL.ExifTags.GPS`. + + +Security +======== + +Initialize libtiff buffer when saving +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +When saving a TIFF image to a file object using libtiff, the buffer was not +initialized. This behaviour introduced in Pillow 2.0.0, and has now been fixed. + +Decode JPEG compressed BLP1 data in original mode +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Within the BLP image format, BLP1 data may use JPEG compression. Instead of +telling the JPEG library that this data is in BGRX mode, Pillow will now +decode the data in its natural CMYK mode, then convert it to RGB and rearrange +the channels afterwards. Trying to load the data in an incorrect mode could +result in a segmentation fault. This issue was introduced in Pillow 9.1.0. + +Limit SAMPLESPERPIXEL to avoid runtime DOS +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +A large value in the ``SAMPLESPERPIXEL`` tag could lead to a memory and runtime DOS in +``TiffImagePlugin.py`` when setting up the context for image decoding. +This was introduced in Pillow 9.2.0, found with `OSS-Fuzz`_ and fixed by limiting +``SAMPLESPERPIXEL`` to the number of planes that we can decode. + + +Other Changes +============= + +Python 3.11 wheels +^^^^^^^^^^^^^^^^^^ + +Pillow 9.2.0 had wheels built against Python 3.11 beta, available as a preview to help +others prepare for 3.11, and ensure Pillow can be used immediately on release day of +3.11.0 final (2022-10-24, :pep:`664`). + +Pillow 9.3.0 now officially includes binary wheels for Python 3.11 final. + +Windows wheels +^^^^^^^^^^^^^^ + +This release contains wheels for Windows built using GitHub Actions. + +Previously they were built by `Christoph Gohlke `_. + +A huge thanks to Christoph for building Windows binaries for us for around a decade, +plus testing, and fixing over a hundred bug fixes along the way, in addition to building +and hosting unofficial Windows binaries for hundreds of Python projects! + +Added DDS ATI1, ATI2 and BC6H reading +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Support has been added to read the ATI1, ATI2 and BC6H formats of DDS images. + +Release GIL when converting images using matrix operations +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Python's Global Interpreter Lock is now released when converting images using matrix +operations. + +Show all frames with ImageShow +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +When calling :py:meth:`~PIL.Image.Image.show` or using +:py:mod:`~PIL.ImageShow`, all frames will now be shown. + +.. _OSS-Fuzz: https://github.com/google/oss-fuzz diff --git a/docs/releasenotes/9.4.0.rst b/docs/releasenotes/9.4.0.rst new file mode 100644 index 00000000000..0af5bc8ca11 --- /dev/null +++ b/docs/releasenotes/9.4.0.rst @@ -0,0 +1,135 @@ +9.4.0 +----- + +API Additions +============= + +Added start position for getmask and getmask2 +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Text may render differently when starting at fractional coordinates, so +:py:meth:`.FreeTypeFont.getmask` and :py:meth:`.FreeTypeFont.getmask2` now +support a ``start`` argument. This tuple of horizontal and vertical offset +will be used internally by :py:meth:`.ImageDraw.text` to more accurately place +text at the ``xy`` coordinates. + +Added the ``exact`` encoding option for WebP +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +The ``exact`` encoding option for WebP is now supported. The WebP encoder +removes the hidden RGB values for better compression by default in libwebp 0.5 +or later. By setting this option to ``True``, the encoder will keep the hidden +RGB values. + +Added ``signed`` option when saving JPEG2000 +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +If the ``signed`` keyword argument is present and true when saving JPEG2000 +images, then tell the encoder to save the image as signed. + +Added IFD, Interop and LightSource ExifTags enums +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +:py:data:`~PIL.ExifTags.IFD` has been added, allowing enums to be used with +:py:meth:`~PIL.Image.Exif.get_ifd`:: + + from PIL import Image, ExifTags + im = Image.open("Tests/images/flower.jpg") + print(im.getexif().get_ifd(ExifTags.IFD.Exif)) + +``IFD1`` can also be used with :py:meth:`~PIL.Image.Exif.get_ifd`, but it should +not be used in other contexts, as the enum value is only internally meaningful. + +:py:data:`~PIL.ExifTags.Interop` has been added for tags within the Interop IFD:: + + from PIL import Image, ExifTags + im = Image.open("Tests/images/flower.jpg") + interop_ifd = im.getexif().get_ifd(ExifTags.IFD.Interop) + print(interop_ifd.get(ExifTags.Interop.InteropIndex)) # R98 + +:py:data:`~PIL.ExifTags.LightSource` has been added for values within the LightSource +tag:: + + from PIL import Image, ExifTags + im = Image.open("Tests/images/iptc.jpg") + exif_ifd = im.getexif().get_ifd(ExifTags.IFD.Exif) + print(ExifTags.LightSource(exif_ifd[0x9208])) # LightSource.Unknown + +getxmp() +^^^^^^^^ + +`XMP data `_ can now be +decoded for WEBP images through ``getxmp()``. + +Writing JPEG comments +^^^^^^^^^^^^^^^^^^^^^ + +When saving a JPEG image, a comment can now be written from +:py:attr:`~PIL.Image.Image.info`, or by using an argument when saving:: + + im.save(out, comment="Test comment") + +Security +======== + +Fix memory DOS in ImageFont +^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +A corrupt or specially crafted TTF font could have font metrics that lead to +unreasonably large sizes when rendering text in font. ``ImageFont.py`` did not +check the image size before allocating memory for it. This dates to the PIL +fork. Pillow 8.2.0 added a check for large sizes, but did not consider the +case where one dimension is zero. + +Null pointer dereference crash in ImageFont +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Pillow attempted to dereference a null pointer in ``ImageFont``, leading to a +crash. An error is now raised instead. This has been present since +Pillow 8.0.0. + +Other Changes +============= + +Added support for DDS L and LA images +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Support has been added to read and write L and LA DDS images in the uncompressed +format, known as "luminance" textures. + +.. _restored-image-constants: + +Constants +^^^^^^^^^ + +In Pillow 9.1.0, the following constants were deprecated. That has been reversed and +these constants will now remain available. + +- ``Image.NONE`` +- ``Image.NEAREST`` +- ``Image.ORDERED`` +- ``Image.RASTERIZE`` +- ``Image.FLOYDSTEINBERG`` +- ``Image.WEB`` +- ``Image.ADAPTIVE`` +- ``Image.AFFINE`` +- ``Image.EXTENT`` +- ``Image.PERSPECTIVE`` +- ``Image.QUAD`` +- ``Image.MESH`` +- ``Image.FLIP_LEFT_RIGHT`` +- ``Image.FLIP_TOP_BOTTOM`` +- ``Image.ROTATE_90`` +- ``Image.ROTATE_180`` +- ``Image.ROTATE_270`` +- ``Image.TRANSPOSE`` +- ``Image.TRANSVERSE`` +- ``Image.BOX`` +- ``Image.BILINEAR`` +- ``Image.HAMMING`` +- ``Image.BICUBIC`` +- ``Image.LANCZOS`` +- ``Image.MEDIANCUT`` +- ``Image.MAXCOVERAGE`` +- ``Image.FASTOCTREE`` +- ``Image.LIBIMAGEQUANT`` diff --git a/docs/releasenotes/index.rst b/docs/releasenotes/index.rst index 8d1ad78379a..a2b58869696 100644 --- a/docs/releasenotes/index.rst +++ b/docs/releasenotes/index.rst @@ -14,6 +14,12 @@ expected to be backported to earlier versions. .. toctree:: :maxdepth: 2 + 9.4.0 + 9.3.0 + 9.2.0 + 9.1.1 + 9.1.0 + 9.0.1 9.0.0 8.4.0 8.3.2 diff --git a/docs/releasenotes/versioning.rst b/docs/releasenotes/versioning.rst index 87f2ba422b3..2a0af9e59ec 100644 --- a/docs/releasenotes/versioning.rst +++ b/docs/releasenotes/versioning.rst @@ -11,7 +11,7 @@ Pillow follows `Semantic Versioning `_: 2. MINOR version when you add functionality in a backwards compatible manner, and 3. PATCH version when you make backwards compatible bug fixes. -Quarterly releases ("`Main Release `_") +Quarterly releases ("`Main Release `_") bump at least the MINOR version, as new functionality has likely been added in the prior three months. @@ -21,8 +21,8 @@ these occur every 12-18 months, guided by `Python's EOL schedule `_, and any APIs that have been deprecated for at least a year are removed at the same time. -PATCH versions ("`Point Release `_" -or "`Embargoed Release `_") +PATCH versions ("`Point Release `_" +or "`Embargoed Release `_") are for security, installation or critical bug fixes. These are less common as it is preferred to stick to quarterly releases. diff --git a/docs/resources/css/dark.css b/docs/resources/css/dark.css index 8866c07eabd..1571cbc4e91 100644 --- a/docs/resources/css/dark.css +++ b/docs/resources/css/dark.css @@ -1,1996 +1,9 @@ +/* For black-on-white/transparent images at handbook/text-anchors.html */ +body[data-theme="dark"] #text-anchors img { + filter: invert(1) brightness(0.85) hue-rotate(-60deg); +} @media (prefers-color-scheme: dark) { - html { - background-color: #181a1b !important; - } - - html, body, input, textarea, select, button { - background-color: #181a1b; - } - - html, body, input, textarea, select, button { - border-color: #736b5e; - color: #e8e6e3; - } - - a { - color: #3391ff; - } - - table { - border-color: #545b5e; - } - - ::placeholder { - color: #b2aba1; - } - - input:-webkit-autofill, - textarea:-webkit-autofill, - select:-webkit-autofill { - background-color: #555b00 !important; - color: #e8e6e3 !important; - } - - ::selection { - background-color: #004daa !important; - color: #e8e6e3 !important; - } - - ::-moz-selection { - background-color: #004daa !important; - color: #e8e6e3 !important; - } - - /* Invert Style */ - .jfk-bubble.gtx-bubble, embed[type="application/pdf"] { - filter: invert(100%) hue-rotate(180deg) contrast(90%) !important; - } - - /* Override Style */ - .vimvixen-hint { - background-color: #7b5300 !important; - border-color: #d8b013 !important; - color: #f3e8c8 !important; - } - - ::placeholder { - opacity: 0.5 !important; - } - - /* Variables Style */ - :root { - --darkreader-neutral-background: #181a1b; - --darkreader-neutral-text: #e8e6e3; - --darkreader-selection-background: #004daa; - --darkreader-selection-text: #e8e6e3; - } - - /* Modified CSS */ - a:hover, - a:active { - outline-color: initial; - } - - abbr[title] { - border-bottom-color: initial; - } - - ins { - background-image: initial; - background-color: rgb(112, 112, 0); - color: rgb(232, 230, 227); - text-decoration-color: initial; - } - - mark { - background-image: initial; - background-color: rgb(204, 204, 0); - color: rgb(232, 230, 227); - } - - ul, - ol, - dl { - list-style-image: none; - } - - li { - list-style-image: initial; - } - - img { - border-color: initial; - } - - fieldset { - border-color: initial; - } - - legend { - border-color: initial; - } - - .chromeframe { - background-image: initial; - background-color: rgb(53, 57, 59); - color: rgb(232, 230, 227); - } - - .ir { - border-color: initial; - background-color: transparent; - } - - .visuallyhidden { - border-color: initial; - } - - .fa-border { - border-color: rgb(53, 57, 59); - } - - .fa-inverse { - color: rgb(232, 230, 227); - } - - .sr-only { - border-color: initial; - } - - .fa::before, - .wy-menu-vertical li span.toctree-expand::before, - .wy-menu-vertical li.on a span.toctree-expand::before, - .wy-menu-vertical li.current > a span.toctree-expand::before, - .rst-content .admonition-title::before, - .rst-content h1 .headerlink::before, - .rst-content h2 .headerlink::before, - .rst-content h3 .headerlink::before, - .rst-content h4 .headerlink::before, - .rst-content h5 .headerlink::before, - .rst-content h6 .headerlink::before, - .rst-content dl dt .headerlink::before, - .rst-content p.caption .headerlink::before, - .rst-content table > caption .headerlink::before, - .rst-content .code-block-caption .headerlink::before, - .rst-content tt.download span:first-child::before, - .rst-content code.download span:first-child::before, - .icon::before, - .wy-dropdown .caret::before, - .wy-inline-validate.wy-inline-validate-success .wy-input-context::before, - .wy-inline-validate.wy-inline-validate-danger .wy-input-context::before, - .wy-inline-validate.wy-inline-validate-warning .wy-input-context::before, - .wy-inline-validate.wy-inline-validate-info .wy-input-context::before { - text-decoration-color: inherit; - } - - a .fa, - a .wy-menu-vertical li span.toctree-expand, - .wy-menu-vertical li a span.toctree-expand, - .wy-menu-vertical li.on a span.toctree-expand, - .wy-menu-vertical li.current > a span.toctree-expand, - a .rst-content .admonition-title, - .rst-content a .admonition-title, - a .rst-content h1 .headerlink, - .rst-content h1 a .headerlink, - a .rst-content h2 .headerlink, - .rst-content h2 a .headerlink, - a .rst-content h3 .headerlink, - .rst-content h3 a .headerlink, - a .rst-content h4 .headerlink, - .rst-content h4 a .headerlink, - a .rst-content h5 .headerlink, - .rst-content h5 a .headerlink, - a .rst-content h6 .headerlink, - .rst-content h6 a .headerlink, - a .rst-content dl dt .headerlink, - .rst-content dl dt a .headerlink, - a .rst-content p.caption .headerlink, - .rst-content p.caption a .headerlink, - a .rst-content table > caption .headerlink, - .rst-content table > caption a .headerlink, - a .rst-content .code-block-caption .headerlink, - .rst-content .code-block-caption a .headerlink, - a .rst-content tt.download span:first-child, - .rst-content tt.download a span:first-child, - a .rst-content code.download span:first-child, - .rst-content code.download a span:first-child, - a .icon { - text-decoration-color: inherit; - } - - .wy-alert, - .rst-content .note, - .rst-content .attention, - .rst-content .caution, - .rst-content .danger, - .rst-content .error, - .rst-content .hint, - .rst-content .important, - .rst-content .tip, - .rst-content .warning, - .rst-content .seealso, - .rst-content .admonition-todo, - .rst-content .admonition { - background-image: initial; - background-color: rgb(32, 35, 36); - } - - .wy-alert-title, - .rst-content .admonition-title { - color: rgb(232, 230, 227); - background-image: initial; - background-color: rgb(29, 91, 131); - } - - .wy-alert.wy-alert-danger, - .rst-content .wy-alert-danger.note, - .rst-content .wy-alert-danger.attention, - .rst-content .wy-alert-danger.caution, - .rst-content .danger, - .rst-content .error, - .rst-content .wy-alert-danger.hint, - .rst-content .wy-alert-danger.important, - .rst-content .wy-alert-danger.tip, - .rst-content .wy-alert-danger.warning, - .rst-content .wy-alert-danger.seealso, - .rst-content .wy-alert-danger.admonition-todo, - .rst-content .wy-alert-danger.admonition { - background-image: initial; - background-color: rgb(52, 12, 8); - } - - .wy-alert.wy-alert-danger .wy-alert-title, - .rst-content .wy-alert-danger.note .wy-alert-title, - .rst-content .wy-alert-danger.attention .wy-alert-title, - .rst-content .wy-alert-danger.caution .wy-alert-title, - .rst-content .danger .wy-alert-title, - .rst-content .error .wy-alert-title, - .rst-content .wy-alert-danger.hint .wy-alert-title, - .rst-content .wy-alert-danger.important .wy-alert-title, - .rst-content .wy-alert-danger.tip .wy-alert-title, - .rst-content .wy-alert-danger.warning .wy-alert-title, - .rst-content .wy-alert-danger.seealso .wy-alert-title, - .rst-content .wy-alert-danger.admonition-todo .wy-alert-title, - .rst-content .wy-alert-danger.admonition .wy-alert-title, - .wy-alert.wy-alert-danger .rst-content .admonition-title, - .rst-content .wy-alert.wy-alert-danger .admonition-title, - .rst-content .wy-alert-danger.note .admonition-title, - .rst-content .wy-alert-danger.attention .admonition-title, - .rst-content .wy-alert-danger.caution .admonition-title, - .rst-content .danger .admonition-title, - .rst-content .error .admonition-title, - .rst-content .wy-alert-danger.hint .admonition-title, - .rst-content .wy-alert-danger.important .admonition-title, - .rst-content .wy-alert-danger.tip .admonition-title, - .rst-content .wy-alert-danger.warning .admonition-title, - .rst-content .wy-alert-danger.seealso .admonition-title, - .rst-content .wy-alert-danger.admonition-todo .admonition-title, - .rst-content .wy-alert-danger.admonition .admonition-title { - background-image: initial; - background-color: rgb(108, 22, 13); - } - - .wy-alert.wy-alert-warning, - .rst-content .wy-alert-warning.note, - .rst-content .attention, - .rst-content .caution, - .rst-content .wy-alert-warning.danger, - .rst-content .wy-alert-warning.error, - .rst-content .wy-alert-warning.hint, - .rst-content .wy-alert-warning.important, - .rst-content .wy-alert-warning.tip, - .rst-content .warning, - .rst-content .wy-alert-warning.seealso, - .rst-content .admonition-todo, - .rst-content .wy-alert-warning.admonition { - background-image: initial; - background-color: rgb(82, 53, 0); - } - - .wy-alert.wy-alert-warning .wy-alert-title, - .rst-content .wy-alert-warning.note .wy-alert-title, - .rst-content .attention .wy-alert-title, - .rst-content .caution .wy-alert-title, - .rst-content .wy-alert-warning.danger .wy-alert-title, - .rst-content .wy-alert-warning.error .wy-alert-title, - .rst-content .wy-alert-warning.hint .wy-alert-title, - .rst-content .wy-alert-warning.important .wy-alert-title, - .rst-content .wy-alert-warning.tip .wy-alert-title, - .rst-content .warning .wy-alert-title, - .rst-content .wy-alert-warning.seealso .wy-alert-title, - .rst-content .admonition-todo .wy-alert-title, - .rst-content .wy-alert-warning.admonition .wy-alert-title, - .wy-alert.wy-alert-warning .rst-content .admonition-title, - .rst-content .wy-alert.wy-alert-warning .admonition-title, - .rst-content .wy-alert-warning.note .admonition-title, - .rst-content .attention .admonition-title, - .rst-content .caution .admonition-title, - .rst-content .wy-alert-warning.danger .admonition-title, - .rst-content .wy-alert-warning.error .admonition-title, - .rst-content .wy-alert-warning.hint .admonition-title, - .rst-content .wy-alert-warning.important .admonition-title, - .rst-content .wy-alert-warning.tip .admonition-title, - .rst-content .warning .admonition-title, - .rst-content .wy-alert-warning.seealso .admonition-title, - .rst-content .admonition-todo .admonition-title, - .rst-content .wy-alert-warning.admonition .admonition-title { - background-image: initial; - background-color: rgb(123, 65, 14); - } - - .wy-alert.wy-alert-info, - .rst-content .note, - .rst-content .wy-alert-info.attention, - .rst-content .wy-alert-info.caution, - .rst-content .wy-alert-info.danger, - .rst-content .wy-alert-info.error, - .rst-content .wy-alert-info.hint, - .rst-content .wy-alert-info.important, - .rst-content .wy-alert-info.tip, - .rst-content .wy-alert-info.warning, - .rst-content .seealso, - .rst-content .wy-alert-info.admonition-todo, - .rst-content .wy-alert-info.admonition { - background-image: initial; - background-color: rgb(32, 35, 36); - } - - .wy-alert.wy-alert-info .wy-alert-title, - .rst-content .note .wy-alert-title, - .rst-content .wy-alert-info.attention .wy-alert-title, - .rst-content .wy-alert-info.caution .wy-alert-title, - .rst-content .wy-alert-info.danger .wy-alert-title, - .rst-content .wy-alert-info.error .wy-alert-title, - .rst-content .wy-alert-info.hint .wy-alert-title, - .rst-content .wy-alert-info.important .wy-alert-title, - .rst-content .wy-alert-info.tip .wy-alert-title, - .rst-content .wy-alert-info.warning .wy-alert-title, - .rst-content .seealso .wy-alert-title, - .rst-content .wy-alert-info.admonition-todo .wy-alert-title, - .rst-content .wy-alert-info.admonition .wy-alert-title, - .wy-alert.wy-alert-info .rst-content .admonition-title, - .rst-content .wy-alert.wy-alert-info .admonition-title, - .rst-content .note .admonition-title, - .rst-content .wy-alert-info.attention .admonition-title, - .rst-content .wy-alert-info.caution .admonition-title, - .rst-content .wy-alert-info.danger .admonition-title, - .rst-content .wy-alert-info.error .admonition-title, - .rst-content .wy-alert-info.hint .admonition-title, - .rst-content .wy-alert-info.important .admonition-title, - .rst-content .wy-alert-info.tip .admonition-title, - .rst-content .wy-alert-info.warning .admonition-title, - .rst-content .seealso .admonition-title, - .rst-content .wy-alert-info.admonition-todo .admonition-title, - .rst-content .wy-alert-info.admonition .admonition-title { - background-image: initial; - background-color: rgb(29, 91, 131); - } - - .wy-alert.wy-alert-success, - .rst-content .wy-alert-success.note, - .rst-content .wy-alert-success.attention, - .rst-content .wy-alert-success.caution, - .rst-content .wy-alert-success.danger, - .rst-content .wy-alert-success.error, - .rst-content .hint, - .rst-content .important, - .rst-content .tip, - .rst-content .wy-alert-success.warning, - .rst-content .wy-alert-success.seealso, - .rst-content .wy-alert-success.admonition-todo, - .rst-content .wy-alert-success.admonition { - background-image: initial; - background-color: rgb(9, 66, 58); - } - - .wy-alert.wy-alert-success .wy-alert-title, - .rst-content .wy-alert-success.note .wy-alert-title, - .rst-content .wy-alert-success.attention .wy-alert-title, - .rst-content .wy-alert-success.caution .wy-alert-title, - .rst-content .wy-alert-success.danger .wy-alert-title, - .rst-content .wy-alert-success.error .wy-alert-title, - .rst-content .hint .wy-alert-title, - .rst-content .important .wy-alert-title, - .rst-content .tip .wy-alert-title, - .rst-content .wy-alert-success.warning .wy-alert-title, - .rst-content .wy-alert-success.seealso .wy-alert-title, - .rst-content .wy-alert-success.admonition-todo .wy-alert-title, - .rst-content .wy-alert-success.admonition .wy-alert-title, - .wy-alert.wy-alert-success .rst-content .admonition-title, - .rst-content .wy-alert.wy-alert-success .admonition-title, - .rst-content .wy-alert-success.note .admonition-title, - .rst-content .wy-alert-success.attention .admonition-title, - .rst-content .wy-alert-success.caution .admonition-title, - .rst-content .wy-alert-success.danger .admonition-title, - .rst-content .wy-alert-success.error .admonition-title, - .rst-content .hint .admonition-title, - .rst-content .important .admonition-title, - .rst-content .tip .admonition-title, - .rst-content .wy-alert-success.warning .admonition-title, - .rst-content .wy-alert-success.seealso .admonition-title, - .rst-content .wy-alert-success.admonition-todo .admonition-title, - .rst-content .wy-alert-success.admonition .admonition-title { - background-image: initial; - background-color: rgb(21, 150, 125); - } - - .wy-alert.wy-alert-neutral, - .rst-content .wy-alert-neutral.note, - .rst-content .wy-alert-neutral.attention, - .rst-content .wy-alert-neutral.caution, - .rst-content .wy-alert-neutral.danger, - .rst-content .wy-alert-neutral.error, - .rst-content .wy-alert-neutral.hint, - .rst-content .wy-alert-neutral.important, - .rst-content .wy-alert-neutral.tip, - .rst-content .wy-alert-neutral.warning, - .rst-content .wy-alert-neutral.seealso, - .rst-content .wy-alert-neutral.admonition-todo, - .rst-content .wy-alert-neutral.admonition { - background-image: initial; - background-color: rgb(27, 36, 36); - } - - .wy-alert.wy-alert-neutral .wy-alert-title, - .rst-content .wy-alert-neutral.note .wy-alert-title, - .rst-content .wy-alert-neutral.attention .wy-alert-title, - .rst-content .wy-alert-neutral.caution .wy-alert-title, - .rst-content .wy-alert-neutral.danger .wy-alert-title, - .rst-content .wy-alert-neutral.error .wy-alert-title, - .rst-content .wy-alert-neutral.hint .wy-alert-title, - .rst-content .wy-alert-neutral.important .wy-alert-title, - .rst-content .wy-alert-neutral.tip .wy-alert-title, - .rst-content .wy-alert-neutral.warning .wy-alert-title, - .rst-content .wy-alert-neutral.seealso .wy-alert-title, - .rst-content .wy-alert-neutral.admonition-todo .wy-alert-title, - .rst-content .wy-alert-neutral.admonition .wy-alert-title, - .wy-alert.wy-alert-neutral .rst-content .admonition-title, - .rst-content .wy-alert.wy-alert-neutral .admonition-title, - .rst-content .wy-alert-neutral.note .admonition-title, - .rst-content .wy-alert-neutral.attention .admonition-title, - .rst-content .wy-alert-neutral.caution .admonition-title, - .rst-content .wy-alert-neutral.danger .admonition-title, - .rst-content .wy-alert-neutral.error .admonition-title, - .rst-content .wy-alert-neutral.hint .admonition-title, - .rst-content .wy-alert-neutral.important .admonition-title, - .rst-content .wy-alert-neutral.tip .admonition-title, - .rst-content .wy-alert-neutral.warning .admonition-title, - .rst-content .wy-alert-neutral.seealso .admonition-title, - .rst-content .wy-alert-neutral.admonition-todo .admonition-title, - .rst-content .wy-alert-neutral.admonition .admonition-title { - color: rgb(192, 186, 178); - background-image: initial; - background-color: rgb(40, 43, 45); - } - - .wy-alert.wy-alert-neutral a, - .rst-content .wy-alert-neutral.note a, - .rst-content .wy-alert-neutral.attention a, - .rst-content .wy-alert-neutral.caution a, - .rst-content .wy-alert-neutral.danger a, - .rst-content .wy-alert-neutral.error a, - .rst-content .wy-alert-neutral.hint a, - .rst-content .wy-alert-neutral.important a, - .rst-content .wy-alert-neutral.tip a, - .rst-content .wy-alert-neutral.warning a, - .rst-content .wy-alert-neutral.seealso a, - .rst-content .wy-alert-neutral.admonition-todo a, - .rst-content .wy-alert-neutral.admonition a { - color: rgb(84, 164, 217); - } - - .wy-tray-container li { - background-image: initial; - background-color: transparent; - color: rgb(232, 230, 227); - box-shadow: rgba(0, 0, 0, 0.1) 0px 5px 5px 0px; - } - - .wy-tray-container li.wy-tray-item-success { - background-image: initial; - background-color: rgb(31, 139, 77); - } - - .wy-tray-container li.wy-tray-item-info { - background-image: initial; - background-color: rgb(33, 102, 148); - } - - .wy-tray-container li.wy-tray-item-warning { - background-image: initial; - background-color: rgb(178, 94, 20); - } - - .wy-tray-container li.wy-tray-item-danger { - background-image: initial; - background-color: rgb(162, 33, 20); - } - - .btn { - color: rgb(232, 230, 227); - border-color: rgba(140, 130, 115, 0.1); - background-color: rgb(31, 139, 77); - text-decoration-color: initial; - box-shadow: rgba(24, 26, 27, 0.5) 0px 1px 2px -1px inset, - rgba(0, 0, 0, 0.1) 0px -2px 0px 0px inset; - } - - .btn-hover { - background-image: initial; - background-color: rgb(37, 114, 165); - color: rgb(232, 230, 227); - } - - .btn:hover { - background-image: initial; - background-color: rgb(35, 156, 86); - color: rgb(232, 230, 227); - } - - .btn:focus { - background-image: initial; - background-color: rgb(35, 156, 86); - outline-color: initial; - } - - .btn:active { - box-shadow: rgba(0, 0, 0, 0.05) 0px -1px 0px 0px inset, - rgba(0, 0, 0, 0.1) 0px 2px 0px 0px inset; - } - - .btn:visited { - color: rgb(232, 230, 227); - } - - .btn:disabled { - background-image: none; - box-shadow: none; - } - - .btn-disabled { - background-image: none; - box-shadow: none; - } - - .btn-disabled:hover, - .btn-disabled:focus, - .btn-disabled:active { - background-image: none; - box-shadow: none; - } - - .btn-info { - background-color: rgb(33, 102, 148) !important; - } - - .btn-info:hover { - background-color: rgb(37, 114, 165) !important; - } - - .btn-neutral { - background-color: rgb(27, 36, 36) !important; - color: rgb(192, 186, 178) !important; - } - - .btn-neutral:hover { - color: rgb(192, 186, 178); - background-color: rgb(34, 44, 44) !important; - } - - .btn-neutral:visited { - color: rgb(192, 186, 178) !important; - } - - .btn-success { - background-color: rgb(31, 139, 77) !important; - } - - .btn-success:hover { - background-color: rgb(27, 122, 68) !important; - } - - .btn-danger { - background-color: rgb(162, 33, 20) !important; - } - - .btn-danger:hover { - background-color: rgb(149, 30, 18) !important; - } - - .btn-warning { - background-color: rgb(178, 94, 20) !important; - } - - .btn-warning:hover { - background-color: rgb(165, 87, 18) !important; - } - - .btn-invert { - background-color: rgb(26, 28, 29); - } - - .btn-invert:hover { - background-color: rgb(35, 38, 40) !important; - } - - .btn-link { - color: rgb(84, 164, 217); - box-shadow: none; - background-color: transparent !important; - border-color: transparent !important; - } - - .btn-link:hover { - box-shadow: none; - background-color: transparent !important; - color: rgb(79, 162, 216) !important; - } - - .btn-link:active { - box-shadow: none; - background-color: transparent !important; - color: rgb(79, 162, 216) !important; - } - - .btn-link:visited { - color: rgb(164, 103, 188); - } - - .wy-dropdown-menu { - background-image: initial; - background-color: rgb(26, 28, 29); - border-color: rgb(60, 65, 67); - box-shadow: rgba(0, 0, 0, 0.1) 0px 2px 2px 0px; - } - - .wy-dropdown-menu > dd > a { - color: rgb(192, 186, 178); - } - - .wy-dropdown-menu > dd > a:hover { - background-image: initial; - background-color: rgb(33, 102, 148); - color: rgb(232, 230, 227); - } - - .wy-dropdown-menu > dd.divider { - border-top-color: rgb(60, 65, 67); - } - - .wy-dropdown-menu > dd.call-to-action { - background-image: initial; - background-color: rgb(40, 43, 45); - } - - .wy-dropdown-menu > dd.call-to-action:hover { - background-image: initial; - background-color: rgb(40, 43, 45); - } - - .wy-dropdown-menu > dd.call-to-action .btn { - color: rgb(232, 230, 227); - } - - .wy-dropdown.wy-dropdown-bubble .wy-dropdown-menu { - background-image: initial; - background-color: rgb(26, 28, 29); - } - - .wy-dropdown.wy-dropdown-bubble .wy-dropdown-menu a:hover { - background-image: initial; - background-color: rgb(33, 102, 148); - color: rgb(232, 230, 227); - } - - .wy-dropdown-arrow::before { - border-bottom-color: rgb(51, 55, 57); - border-left-color: transparent; - border-right-color: transparent; - } - - fieldset { - border-color: initial; - } - - legend { - border-color: initial; - } - - label { - color: rgb(200, 195, 188); - } - - .wy-control-group.wy-control-group-required > label::after { - color: rgb(233, 88, 73); - } - - .wy-form-message-inline { - color: rgb(168, 160, 149); - } - - .wy-form-message { - color: rgb(168, 160, 149); - } - - input[type="text"], input[type="password"], input[type="email"], input[type="url"], input[type="date"], input[type="month"], input[type="time"], input[type="datetime"], input[type="datetime-local"], input[type="week"], input[type="number"], input[type="search"], input[type="tel"], input[type="color"] { - border-color: rgb(62, 68, 70); - box-shadow: rgb(43, 47, 49) 0px 1px 3px inset; - } - - input[type="text"]:focus, input[type="password"]:focus, input[type="email"]:focus, input[type="url"]:focus, input[type="date"]:focus, input[type="month"]:focus, input[type="time"]:focus, input[type="datetime"]:focus, input[type="datetime-local"]:focus, input[type="week"]:focus, input[type="number"]:focus, input[type="search"]:focus, input[type="tel"]:focus, input[type="color"]:focus { - outline-color: initial; - border-color: rgb(123, 114, 101); - } - - input.no-focus:focus { - border-color: rgb(62, 68, 70) !important; - } - - input[type="file"]:focus, input[type="radio"]:focus, input[type="checkbox"]:focus { - outline-color: rgb(13, 113, 167); - } - - input[type="text"][disabled], input[type="password"][disabled], input[type="email"][disabled], input[type="url"][disabled], input[type="date"][disabled], input[type="month"][disabled], input[type="time"][disabled], input[type="datetime"][disabled], input[type="datetime-local"][disabled], input[type="week"][disabled], input[type="number"][disabled], input[type="search"][disabled], input[type="tel"][disabled], input[type="color"][disabled] { - background-color: rgb(27, 29, 30); - } - - input:focus:invalid, - textarea:focus:invalid, - select:focus:invalid { - color: rgb(233, 88, 73); - border-color: rgb(149, 31, 18); - } - - input:focus:invalid:focus, - textarea:focus:invalid:focus, - select:focus:invalid:focus { - border-color: rgb(149, 31, 18); - } - - input[type="file"]:focus:invalid:focus, input[type="radio"]:focus:invalid:focus, input[type="checkbox"]:focus:invalid:focus { - outline-color: rgb(149, 31, 18); - } - - select, - textarea { - border-color: rgb(62, 68, 70); - box-shadow: rgb(43, 47, 49) 0px 1px 3px inset; - } - - select { - border-color: rgb(62, 68, 70); - background-color: rgb(24, 26, 27); - } - - select:focus, - textarea:focus { - outline-color: initial; - } - - select[disabled], - textarea[disabled], - input[readonly], - select[readonly], - textarea[readonly] { - background-color: rgb(27, 29, 30); - } - - .wy-checkbox, - .wy-radio { - color: rgb(192, 186, 178); - } - - .wy-input-prefix .wy-input-context, - .wy-input-suffix .wy-input-context { - background-color: rgb(27, 36, 36); - border-color: rgb(62, 68, 70); - color: rgb(168, 160, 149); - } - - .wy-input-suffix .wy-input-context { - border-left-color: initial; - } - - .wy-input-prefix .wy-input-context { - border-right-color: initial; - } - - .wy-switch::before { - background-image: initial; - background-color: rgb(53, 57, 59); - } - - .wy-switch::after { - background-image: initial; - background-color: rgb(82, 88, 92); - } - - .wy-switch span { - color: rgb(200, 195, 188); - } - - .wy-switch.active::before { - background-image: initial; - background-color: rgb(24, 106, 58); - } - - .wy-switch.active::after { - background-image: initial; - background-color: rgb(31, 139, 77); - } - - .wy-control-group.wy-control-group-error .wy-form-message, - .wy-control-group.wy-control-group-error > label { - color: rgb(233, 88, 73); - } - - .wy-control-group.wy-control-group-error input[type="text"], .wy-control-group.wy-control-group-error input[type="password"], .wy-control-group.wy-control-group-error input[type="email"], .wy-control-group.wy-control-group-error input[type="url"], .wy-control-group.wy-control-group-error input[type="date"], .wy-control-group.wy-control-group-error input[type="month"], .wy-control-group.wy-control-group-error input[type="time"], .wy-control-group.wy-control-group-error input[type="datetime"], .wy-control-group.wy-control-group-error input[type="datetime-local"], .wy-control-group.wy-control-group-error input[type="week"], .wy-control-group.wy-control-group-error input[type="number"], .wy-control-group.wy-control-group-error input[type="search"], .wy-control-group.wy-control-group-error input[type="tel"], .wy-control-group.wy-control-group-error input[type="color"] { - border-color: rgb(149, 31, 18); - } - - .wy-control-group.wy-control-group-error textarea { - border-color: rgb(149, 31, 18); - } - - .wy-inline-validate.wy-inline-validate-success .wy-input-context { - color: rgb(92, 218, 145); - } - - .wy-inline-validate.wy-inline-validate-danger .wy-input-context { - color: rgb(233, 88, 73); - } - - .wy-inline-validate.wy-inline-validate-warning .wy-input-context { - color: rgb(232, 138, 54); - } - - .wy-inline-validate.wy-inline-validate-info .wy-input-context { - color: rgb(84, 164, 217); - } - - .wy-table caption, - .rst-content table.docutils caption, - .rst-content table.field-list caption { - color: rgb(232, 230, 227); - } - - .wy-table thead, - .rst-content table.docutils thead, - .rst-content table.field-list thead { - color: rgb(232, 230, 227); - } - - .wy-table thead th, - .rst-content table.docutils thead th, - .rst-content table.field-list thead th { - border-bottom-color: rgb(56, 61, 63); - } - - .wy-table td, - .rst-content table.docutils td, - .rst-content table.field-list td { - background-color: transparent; - } - - .wy-table-secondary { - color: rgb(152, 143, 129); - } - - .wy-table-tertiary { - color: rgb(152, 143, 129); - } - - .wy-table-odd td, - .wy-table-striped tr:nth-child(2n-1) td, - .rst-content table.docutils:not(.field-list) tr:nth-child(2n-1) td { - background-color: rgb(27, 36, 36); - } - - .wy-table-backed { - background-color: rgb(27, 36, 36); - } - - .wy-table-bordered-all, - .rst-content table.docutils { - border-color: rgb(56, 61, 63); - } - - .wy-table-bordered-all td, - .rst-content table.docutils td { - border-bottom-color: rgb(56, 61, 63); - border-left-color: rgb(56, 61, 63); - } - - .wy-table-bordered { - border-color: rgb(56, 61, 63); - } - - .wy-table-bordered-rows td { - border-bottom-color: rgb(56, 61, 63); - } - - .wy-table-horizontal td, - .wy-table-horizontal th { - border-bottom-color: rgb(56, 61, 63); - } - - a { - color: rgb(84, 164, 217); - text-decoration-color: initial; - } - - a:hover { - color: rgb(68, 156, 214); - } - - a:visited { - color: rgb(164, 103, 188); - } - - body { - color: rgb(192, 186, 178); - background-image: initial; - background-color: rgb(33, 35, 37); - } - - .wy-text-strike { - text-decoration-color: initial; - } - - .wy-text-warning { - color: rgb(232, 138, 54) !important; - } - - a.wy-text-warning:hover { - color: rgb(236, 157, 87) !important; - } - - .wy-text-info { - color: rgb(84, 164, 217) !important; - } - - a.wy-text-info:hover { - color: rgb(79, 162, 216) !important; - } - - .wy-text-success { - color: rgb(92, 218, 145) !important; - } - - a.wy-text-success:hover { - color: rgb(73, 214, 133) !important; - } - - .wy-text-danger { - color: rgb(233, 88, 73) !important; - } - - a.wy-text-danger:hover { - color: rgb(237, 118, 104) !important; - } - - .wy-text-neutral { - color: rgb(192, 186, 178) !important; - } - - a.wy-text-neutral:hover { - color: rgb(176, 169, 159) !important; - } - - hr { - border-right-color: initial; - border-bottom-color: initial; - border-left-color: initial; - border-top-color: rgb(56, 61, 63); - } - - code, - .rst-content tt, - .rst-content code { - background-image: initial; - background-color: rgb(24, 26, 27); - border-color: rgb(56, 61, 63); - color: rgb(233, 88, 73); - } - - .wy-plain-list-disc, - .rst-content .section ul, - .rst-content .toctree-wrapper ul, - article ul { - list-style-image: initial; - } - - .wy-plain-list-disc li, - .rst-content .section ul li, - .rst-content .toctree-wrapper ul li, - article ul li { - list-style-image: initial; - } - - .wy-plain-list-disc li li, - .rst-content .section ul li li, - .rst-content .toctree-wrapper ul li li, - article ul li li { - list-style-image: initial; - } - - .wy-plain-list-disc li li li, - .rst-content .section ul li li li, - .rst-content .toctree-wrapper ul li li li, - article ul li li li { - list-style-image: initial; - } - - .wy-plain-list-disc li ol li, - .rst-content .section ul li ol li, - .rst-content .toctree-wrapper ul li ol li, - article ul li ol li { - list-style-image: initial; - } - - .wy-plain-list-decimal, - .rst-content .section ol, - .rst-content ol.arabic, - article ol { - list-style-image: initial; - } - - .wy-plain-list-decimal li, - .rst-content .section ol li, - .rst-content ol.arabic li, - article ol li { - list-style-image: initial; - } - - .wy-plain-list-decimal li ul li, - .rst-content .section ol li ul li, - .rst-content ol.arabic li ul li, - article ol li ul li { - list-style-image: initial; - } - - .wy-breadcrumbs li code, - .wy-breadcrumbs li .rst-content tt, - .rst-content .wy-breadcrumbs li tt { - border-color: initial; - background-image: none; - background-color: initial; - } - - .wy-breadcrumbs li code.literal, - .wy-breadcrumbs li .rst-content tt.literal, - .rst-content .wy-breadcrumbs li tt.literal { - color: rgb(192, 186, 178); - } - - .wy-breadcrumbs-extra { - color: rgb(184, 178, 169); - } - - .wy-menu a:hover { - text-decoration-color: initial; - } - - .wy-menu-horiz li:hover { - background-image: initial; - background-color: rgba(24, 26, 27, 0.1); - } - - .wy-menu-horiz li.divide-left { - border-left-color: rgb(119, 110, 98); - } - - .wy-menu-horiz li.divide-right { - border-right-color: rgb(119, 110, 98); - } - - .wy-menu-vertical header, - .wy-menu-vertical p.caption { - color: rgb(99, 161, 201); - } - - .wy-menu-vertical li.divide-top { - border-top-color: rgb(119, 110, 98); - } - - .wy-menu-vertical li.divide-bottom { - border-bottom-color: rgb(119, 110, 98); - } - - .wy-menu-vertical li.current { - background-image: initial; - background-color: rgb(40, 43, 45); - } - - .wy-menu-vertical li.current a { - color: rgb(152, 143, 129); - border-right-color: rgb(63, 69, 71); - } - - .wy-menu-vertical li.current a:hover { - background-image: initial; - background-color: rgb(47, 51, 53); - } - - .wy-menu-vertical li code, - .wy-menu-vertical li .rst-content tt, - .rst-content .wy-menu-vertical li tt { - border-color: initial; - background-image: inherit; - background-color: inherit; - color: inherit; - } - - .wy-menu-vertical li span.toctree-expand { - color: rgb(183, 177, 168); - } - - .wy-menu-vertical li.on a, - .wy-menu-vertical li.current > a { - color: rgb(192, 186, 178); - background-image: initial; - background-color: rgb(26, 28, 29); - border-color: initial; - } - - .wy-menu-vertical li.on a:hover, - .wy-menu-vertical li.current > a:hover { - background-image: initial; - background-color: rgb(26, 28, 29); - } - - .wy-menu-vertical li.on a:hover span.toctree-expand, - .wy-menu-vertical li.current > a:hover span.toctree-expand { - color: rgb(152, 143, 129); - } - - .wy-menu-vertical li.on a span.toctree-expand, - .wy-menu-vertical li.current > a span.toctree-expand { - color: rgb(200, 195, 188); - } - - .wy-menu-vertical li.toctree-l1.current > a { - border-bottom-color: rgb(63, 69, 71); - border-top-color: rgb(63, 69, 71); - } - - .wy-menu-vertical li.toctree-l2 a, - .wy-menu-vertical li.toctree-l3 a, - .wy-menu-vertical li.toctree-l4 a { - color: rgb(192, 186, 178); - } - - .wy-menu-vertical li.toctree-l2.current > a { - background-image: initial; - background-color: rgb(54, 59, 61); - } - - .wy-menu-vertical li.toctree-l2.current li.toctree-l3 > a { - background-image: initial; - background-color: rgb(54, 59, 61); - } - - .wy-menu-vertical li.toctree-l2 a:hover span.toctree-expand { - color: rgb(152, 143, 129); - } - - .wy-menu-vertical li.toctree-l2 span.toctree-expand { - color: rgb(174, 167, 156); - } - - .wy-menu-vertical li.toctree-l3.current > a { - background-image: initial; - background-color: rgb(61, 66, 69); - } - - .wy-menu-vertical li.toctree-l3.current li.toctree-l4 > a { - background-image: initial; - background-color: rgb(61, 66, 69); - } - - .wy-menu-vertical li.toctree-l3 a:hover span.toctree-expand { - color: rgb(152, 143, 129); - } - - .wy-menu-vertical li.toctree-l3 span.toctree-expand { - color: rgb(166, 158, 146); - } - - .wy-menu-vertical li.toctree-l2.current a, - .wy-menu-vertical li.toctree-l3.current a { - background-color: #363636; - } - - .wy-menu-vertical li ul li a { - color: rgb(208, 204, 198); - } - - .wy-menu-vertical a { - color: rgb(208, 204, 198); - } - - .wy-menu-vertical a:hover { - background-color: rgb(57, 62, 64); - } - - .wy-menu-vertical a:hover span.toctree-expand { - color: rgb(208, 204, 198); - } - - .wy-menu-vertical a:active { - background-color: rgb(33, 102, 148); - color: rgb(232, 230, 227); - } - - .wy-menu-vertical a:active span.toctree-expand { - color: rgb(232, 230, 227); - } - - .wy-side-nav-search { - background-color: rgb(33, 102, 148); - color: rgb(230, 228, 225); - } - - .wy-side-nav-search input[type="text"] { - border-color: rgb(35, 111, 160); - } - - .wy-side-nav-search img { - background-color: rgb(33, 102, 148); - } - - .wy-side-nav-search > a, - .wy-side-nav-search .wy-dropdown > a { - color: rgb(230, 228, 225); - } - - .wy-side-nav-search > a:hover, - .wy-side-nav-search .wy-dropdown > a:hover { - background-image: initial; - background-color: rgba(24, 26, 27, 0.1); - } - - .wy-side-nav-search > a img.logo, - .wy-side-nav-search .wy-dropdown > a img.logo { - background-image: initial; - background-color: transparent; - } - - .wy-side-nav-search > div.version { - color: rgba(232, 230, 227, 0.3); - } - - .wy-nav .wy-menu-vertical header { - color: rgb(84, 164, 217); - } - - .wy-nav .wy-menu-vertical a { - color: rgb(184, 178, 169); - } - - .wy-nav .wy-menu-vertical a:hover { - background-color: rgb(33, 102, 148); - color: rgb(232, 230, 227); - } - - .wy-body-for-nav { - background-image: initial; - background-color: rgb(24, 26, 27); - } - - .wy-nav-side { - color: rgb(169, 161, 150); - background-image: initial; - background-color: rgb(38, 41, 43); - } - - .wy-nav-top { - background-image: initial; - background-color: rgb(33, 102, 148); - color: rgb(232, 230, 227); - } - - .wy-nav-top a { - color: rgb(232, 230, 227); - } - - .wy-nav-top img { - background-color: rgb(33, 102, 148); - } - - .wy-nav-content-wrap { - background-image: initial; - background-color: rgb(26, 28, 29); - } - - .wy-body-mask { - background-image: initial; - background-color: rgba(0, 0, 0, 0.2); - } - - footer { - color: rgb(152, 143, 129); - } - - footer span.commit code, - footer span.commit .rst-content tt, - .rst-content footer span.commit tt { - background-image: none; - background-color: initial; - border-color: initial; - color: rgb(152, 143, 129); - } - - #search-results .search li { - border-bottom-color: rgb(56, 61, 63); - } - - #search-results .search li:first-child { - border-top-color: rgb(56, 61, 63); - } - - #search-results .context { - color: rgb(152, 143, 129); - } - - @media screen and (min-width: 1100px) { - .wy-nav-content-wrap { - background-image: initial; - background-color: rgba(0, 0, 0, 0.05); - } - - .wy-nav-content { - background-image: initial; - background-color: rgb(26, 28, 29); - } - } - .rst-versions { - color: rgb(230, 228, 225); - background-image: initial; - background-color: rgb(23, 24, 25); - } - - .rst-versions a { - color: rgb(84, 164, 217); - text-decoration-color: initial; - } - - .rst-versions .rst-current-version { - background-color: rgb(29, 31, 32); - color: rgb(92, 218, 145); - } - - .rst-versions .rst-current-version .fa, - .rst-versions .rst-current-version .wy-menu-vertical li span.toctree-expand, - .wy-menu-vertical li .rst-versions .rst-current-version span.toctree-expand, - .rst-versions .rst-current-version .rst-content .admonition-title, - .rst-content .rst-versions .rst-current-version .admonition-title, - .rst-versions .rst-current-version .rst-content h1 .headerlink, - .rst-content h1 .rst-versions .rst-current-version .headerlink, - .rst-versions .rst-current-version .rst-content h2 .headerlink, - .rst-content h2 .rst-versions .rst-current-version .headerlink, - .rst-versions .rst-current-version .rst-content h3 .headerlink, - .rst-content h3 .rst-versions .rst-current-version .headerlink, - .rst-versions .rst-current-version .rst-content h4 .headerlink, - .rst-content h4 .rst-versions .rst-current-version .headerlink, - .rst-versions .rst-current-version .rst-content h5 .headerlink, - .rst-content h5 .rst-versions .rst-current-version .headerlink, - .rst-versions .rst-current-version .rst-content h6 .headerlink, - .rst-content h6 .rst-versions .rst-current-version .headerlink, - .rst-versions .rst-current-version .rst-content dl dt .headerlink, - .rst-content dl dt .rst-versions .rst-current-version .headerlink, - .rst-versions .rst-current-version .rst-content p.caption .headerlink, - .rst-content p.caption .rst-versions .rst-current-version .headerlink, - .rst-versions .rst-current-version .rst-content table > caption .headerlink, - .rst-content table > caption .rst-versions .rst-current-version .headerlink, - .rst-versions .rst-current-version .rst-content .code-block-caption .headerlink, - .rst-content .code-block-caption .rst-versions .rst-current-version .headerlink, - .rst-versions .rst-current-version .rst-content tt.download span:first-child, - .rst-content tt.download .rst-versions .rst-current-version span:first-child, - .rst-versions .rst-current-version .rst-content code.download span:first-child, - .rst-content code.download .rst-versions .rst-current-version span:first-child, - .rst-versions .rst-current-version .icon { - color: rgb(230, 228, 225); - } - - .rst-versions .rst-current-version.rst-out-of-date { - background-color: rgb(162, 33, 20); - color: rgb(232, 230, 227); - } - - .rst-versions .rst-current-version.rst-active-old-version { - background-color: rgb(192, 156, 11); - color: rgb(232, 230, 227); - } - - .rst-versions .rst-other-versions { - color: rgb(152, 143, 129); - } - - .rst-versions .rst-other-versions hr { - border-right-color: initial; - border-bottom-color: initial; - border-left-color: initial; - border-top-color: rgb(119, 111, 98); - } - - .rst-versions .rst-other-versions dd a { - color: rgb(230, 228, 225); - } - - .rst-versions.rst-badge { - border-color: initial; - } - - .rst-content abbr[title] { - text-decoration-color: initial; - } - - .rst-content.style-external-links a.reference.external::after { - color: rgb(184, 178, 169); - } - - .rst-content pre.literal-block, .rst-content div[class^="highlight"] { - border-color: rgb(56, 61, 63); - } - - .rst-content pre.literal-block div[class^="highlight"], .rst-content div[class^="highlight"] div[class^="highlight"] { - border-color: initial; - } - - .rst-content .linenodiv pre { - border-right-color: rgb(54, 59, 61); - } - - .rst-content .admonition table { - border-color: rgba(140, 130, 115, 0.1); - } - - .rst-content .admonition table td, - .rst-content .admonition table th { - background-image: initial !important; - background-color: transparent !important; - border-color: rgba(140, 130, 115, 0.1) !important; - } - - .rst-content .section ol.loweralpha, - .rst-content .section ol.loweralpha li { - list-style-image: initial; - } - - .rst-content .section ol.upperalpha, - .rst-content .section ol.upperalpha li { - list-style-image: initial; - } - - .rst-content .toc-backref { - color: rgb(192, 186, 178); - } - - .rst-content .sidebar { - background-image: initial; - background-color: rgb(27, 36, 36); - border-color: rgb(56, 61, 63); - } - - .rst-content .sidebar .sidebar-title { - background-image: initial; - background-color: rgb(40, 43, 45); - } - - .rst-content .highlighted { - background-image: initial; - background-color: rgb(192, 156, 11); - } - - .rst-content table.docutils.citation, - .rst-content table.docutils.footnote { - background-image: none; - background-color: initial; - border-color: initial; - color: rgb(152, 143, 129); - } - - .rst-content table.docutils.citation td, - .rst-content table.docutils.citation tr, - .rst-content table.docutils.footnote td, - .rst-content table.docutils.footnote tr { - border-color: initial; - background-color: transparent !important; - } - - .rst-content table.docutils.citation tt, - .rst-content table.docutils.citation code, - .rst-content table.docutils.footnote tt, - .rst-content table.docutils.footnote code { - color: rgb(178, 172, 162); - } - - .rst-content table.docutils th { - border-color: rgb(56, 61, 63); - } - - .rst-content table.field-list { - border-color: initial; - } - - .rst-content table.field-list td { - border-color: initial; - } - - .rst-content tt, - .rst-content tt, - .rst-content code { - color: rgb(232, 230, 227); - } - - .rst-content tt.literal, - .rst-content tt.literal, - .rst-content code.literal { - color: rgb(233, 88, 73); - } - - .rst-content tt.xref, - a .rst-content tt, - .rst-content tt.xref, - .rst-content code.xref, - a .rst-content tt, - a .rst-content code { - color: rgb(192, 186, 178); - } - - .rst-content a tt, - .rst-content a tt, - .rst-content a code { - color: rgb(84, 164, 217); - } - - .rst-content dl:not(.docutils) dt { - background-image: initial; - background-color: rgb(32, 35, 36); - color: rgb(84, 164, 217); - border-top-color: rgb(28, 89, 128); - } - - .rst-content dl:not(.docutils) dt::before { - color: rgb(109, 178, 223); - } - - .rst-content dl:not(.docutils) dt .headerlink { - color: rgb(192, 186, 178); - } - - .rst-content dl:not(.docutils) dl dt { - border-top-color: initial; - border-right-color: initial; - border-bottom-color: initial; - border-left-color: rgb(62, 68, 70); - background-image: initial; - background-color: rgb(32, 35, 37); - color: rgb(178, 172, 162); - } - - .rst-content dl:not(.docutils) dl dt .headerlink { - color: rgb(192, 186, 178); - } - - .rst-content dl:not(.docutils) tt.descname, - .rst-content dl:not(.docutils) tt.descclassname, - .rst-content dl:not(.docutils) tt.descname, - .rst-content dl:not(.docutils) code.descname, - .rst-content dl:not(.docutils) tt.descclassname, - .rst-content dl:not(.docutils) code.descclassname { - background-color: transparent; - border-color: initial; - } - - .rst-content dl:not(.docutils) .optional { - color: rgb(232, 230, 227); - } - - .rst-content .viewcode-link, - .rst-content .viewcode-back { - color: rgb(92, 218, 145); - } - - .rst-content tt.download, - .rst-content code.download { - background-image: inherit; - background-color: inherit; - color: inherit; - border-color: inherit; - } - - .rst-content .guilabel { - border-color: rgb(27, 84, 122); - background-image: initial; - background-color: rgb(32, 35, 36); - } - - span[id*="MathJax-Span"] { - color: rgb(192, 186, 178); - } - - .highlight .hll { - background-color: rgb(82, 82, 0); - } - - .highlight { - background-image: initial; - background-color: rgb(61, 82, 0); - } - - .highlight .c { - color: rgb(119, 179, 195); - } - - .highlight .err { - border-color: rgb(179, 0, 0); - } - - .highlight .k { - color: rgb(126, 255, 163); - } - - .highlight .o { - color: rgb(168, 160, 149); - } - - .highlight .ch { - color: rgb(119, 179, 195); - } - - .highlight .cm { - color: rgb(119, 179, 195); - } - - .highlight .cp { - color: rgb(126, 255, 163); - } - - .highlight .cpf { - color: rgb(119, 179, 195); - } - - .highlight .c1 { - color: rgb(119, 179, 195); - } - - .highlight .cs { - color: rgb(119, 179, 195); - background-color: rgb(60, 0, 0); - } - - .highlight .gd { - color: rgb(255, 92, 92); - } - - .highlight .gr { - color: rgb(255, 26, 26); - } - - .highlight .gh { - color: rgb(127, 174, 255); - } - - .highlight .gi { - color: rgb(92, 255, 92); - } - - .highlight .go { - color: rgb(200, 195, 188); - } - - .highlight .gp { - color: rgb(246, 147, 68); - } - - .highlight .gu { - color: rgb(255, 114, 255); - } - - .highlight .gt { - color: rgb(71, 160, 255); - } - - .highlight .kc { - color: rgb(126, 255, 163); - } - - .highlight .kd { - color: rgb(126, 255, 163); - } - - .highlight .kn { - color: rgb(126, 255, 163); - } - - .highlight .kp { - color: rgb(126, 255, 163); - } - - .highlight .kr { - color: rgb(126, 255, 163); - } - - .highlight .kt { - color: rgb(255, 137, 103); - } - - .highlight .m { - color: rgb(125, 222, 174); - } - - .highlight .s { - color: rgb(123, 166, 202); - } - - .highlight .na { - color: rgb(123, 166, 202); - } - - .highlight .nb { - color: rgb(126, 255, 163); - } - - .highlight .nc { - color: rgb(81, 194, 242); - } - - .highlight .no { - color: rgb(103, 177, 215); - } - - .highlight .nd { - color: rgb(178, 172, 162); - } - - .highlight .ni { - color: rgb(217, 100, 73); - } - - .highlight .ne { - color: rgb(126, 255, 163); - } - - .highlight .nf { - color: rgb(131, 186, 249); - } - - .highlight .nl { - color: rgb(137, 193, 255); - } - - .highlight .nn { - color: rgb(81, 194, 242); - } - - .highlight .nt { - color: rgb(138, 191, 249); - } - - .highlight .nv { - color: rgb(190, 103, 215); - } - - .highlight .ow { - color: rgb(126, 255, 163); - } - - .highlight .w { - color: rgb(189, 183, 175); - } - - .highlight .mb { - color: rgb(125, 222, 174); - } - - .highlight .mf { - color: rgb(125, 222, 174); - } - - .highlight .mh { - color: rgb(125, 222, 174); - } - - .highlight .mi { - color: rgb(125, 222, 174); - } - - .highlight .mo { - color: rgb(125, 222, 174); - } - - .highlight .sa { - color: rgb(123, 166, 202); - } - - .highlight .sb { - color: rgb(123, 166, 202); - } - - .highlight .sc { - color: rgb(123, 166, 202); - } - - .highlight .dl { - color: rgb(123, 166, 202); - } - - .highlight .sd { - color: rgb(123, 166, 202); - } - - .highlight .s2 { - color: rgb(123, 166, 202); - } - - .highlight .se { - color: rgb(123, 166, 202); - } - - .highlight .sh { - color: rgb(123, 166, 202); - } - - .highlight .si { - color: rgb(117, 168, 209); - } - - .highlight .sx { - color: rgb(246, 147, 68); - } - - .highlight .sr { - color: rgb(133, 182, 224); - } - - .highlight .s1 { - color: rgb(123, 166, 202); - } - - .highlight .ss { - color: rgb(188, 230, 128); - } - - .highlight .bp { - color: rgb(126, 255, 163); - } - - .highlight .fm { - color: rgb(131, 186, 249); - } - - .highlight .vc { - color: rgb(190, 103, 215); - } - - .highlight .vg { - color: rgb(190, 103, 215); - } - - .highlight .vi { - color: rgb(190, 103, 215); - } - - .highlight .vm { - color: rgb(190, 103, 215); - } - - .highlight .il { - color: rgb(125, 222, 174); - } - - .rst-other-versions a { - border-color: initial; - } - - .ethical-sidebar .ethical-image-link, - .ethical-footer .ethical-image-link { - border-color: initial; - } - - .ethical-sidebar, - .ethical-footer { - background-color: rgb(34, 36, 38); - border-color: rgb(62, 68, 70); - color: rgb(226, 223, 219); - } - - .ethical-sidebar ul { - list-style-image: initial; - } - - .ethical-sidebar ul li { - background-color: rgb(5, 77, 121); - color: rgb(232, 230, 227); - } - - .ethical-sidebar a, - .ethical-sidebar a:visited, - .ethical-sidebar a:hover, - .ethical-sidebar a:active, - .ethical-footer a, - .ethical-footer a:visited, - .ethical-footer a:hover, - .ethical-footer a:active { - color: rgb(226, 223, 219); - text-decoration-color: initial !important; - border-bottom-color: initial !important; - } - - .ethical-callout a { - color: rgb(161, 153, 141) !important; - text-decoration-color: initial !important; - } - - .ethical-fixedfooter { - background-color: rgb(34, 36, 38); - border-top-color: rgb(66, 72, 74); - color: rgb(192, 186, 178); - } - - .ethical-fixedfooter .ethical-text::before { - background-color: rgb(61, 140, 64); - color: rgb(232, 230, 227); - } - - .ethical-fixedfooter .ethical-callout { - color: rgb(168, 160, 149); - } - - .ethical-fixedfooter a, - .ethical-fixedfooter a:hover, - .ethical-fixedfooter a:active, - .ethical-fixedfooter a:visited { - color: rgb(192, 186, 178); - text-decoration-color: initial; - } - - .ethical-rtd .ethical-sidebar { - color: rgb(184, 178, 169); - } - - .ethical-alabaster a.ethical-image-link { - border-color: initial !important; - } - - .ethical-dark-theme .ethical-sidebar { - background-color: rgb(58, 62, 65); - border-color: rgb(75, 81, 84); - color: rgb(193, 188, 180) !important; - } - - .ethical-dark-theme a, - .ethical-dark-theme a:visited { - color: rgb(216, 213, 208) !important; - border-bottom-color: initial !important; - } - - .ethical-dark-theme .ethical-callout a { - color: rgb(184, 178, 169) !important; - } - - .keep-us-sustainable { - border-color: rgb(87, 133, 38); - } - - .keep-us-sustainable a, - .keep-us-sustainable a:hover, - .keep-us-sustainable a:visited { - text-decoration-color: initial; - } - - .wy-body-for-nav .keep-us-sustainable { - color: rgb(184, 178, 169); - } - - .wy-body-for-nav .keep-us-sustainable a { - color: rgb(222, 219, 215); - } - - /* For black-on-white/transparent images at handbook/text-anchors.html */ - #text-anchors img { + body[data-theme="auto"] #text-anchors img { filter: invert(1) brightness(0.85) hue-rotate(-60deg); } } diff --git a/docs/resources/css/light.css b/docs/resources/css/light.css deleted file mode 100644 index 04edd7b16b9..00000000000 --- a/docs/resources/css/light.css +++ /dev/null @@ -1,8 +0,0 @@ -@media (prefers-color-scheme: light) { - - .wy-menu-vertical li.toctree-l2.current a, - .wy-menu-vertical li.toctree-l3.current a { - background-color: #c9c9c9; - } - -} diff --git a/docs/resources/css/styles.css b/docs/resources/css/styles.css deleted file mode 100644 index 111f84085b7..00000000000 --- a/docs/resources/css/styles.css +++ /dev/null @@ -1,8 +0,0 @@ -th p { - margin-bottom: 0; -} - -.rst-content tr .line-block { - font-size: 1rem; - margin-bottom: 0; -} diff --git a/docs/resources/js/script.js b/docs/resources/js/script.js deleted file mode 100644 index 5cb6494ea59..00000000000 --- a/docs/resources/js/script.js +++ /dev/null @@ -1,58 +0,0 @@ -jQuery(document).ready(function ($) { - setTimeout(function () { - var sectionID = 'base'; - var search = function ($section, $sidebarItem) { - $section.children('.section, .function, .method').each(function () { - if ($(this).hasClass('section')) { - sectionID = $(this).attr('id'); - search($(this), $sidebarItem.parent().find('[href="#'+sectionID+'"]')); - } else { - var $dt = $(this).children('dt'); - var id = $dt.attr('id'); - if (id === undefined) { - return; - } - - var $functionsUL = $sidebarItem.siblings('[data-sectionID='+sectionID+']'); - if (!$functionsUL.length) { - $functionsUL = $('