Repository navigation
Preserve palette and transparency in zero dimension ImageOps results - #10299
Merged
radarhere merged 4 commits intoOct 24, 2026
Merged
Conversation
radarhere
force-pushed
the
fix/empty-contain-palette-20261023
branch
from
October 24, 2026 01:38
4cbaaed to
cc0c246
Compare
Member
|
This PR is a sequel to #9673. Your concerns about I don't think this needs release notes. Creating an empty image in ImageOps |
radarhere
force-pushed
the
fix/empty-contain-palette-20261023
branch
from
October 24, 2026 01:53
cc0c246 to
a75824c
Compare
Member
|
I appreciate the attempt to fix MinGW, but it's a bit out of scope for this PR. |
Member
|
I cherry-picked your MinGW commit into #10300 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ImageOps.contain()returns a newly created image when the result has zero width or height. For palette images this loses both palette state and transparency, sopad()can fill a very thin image with opaque black instead of the selected palette color.Use a zero-area crop in the three empty-return branches. This preserves the existing output dimensions while carrying the source palette and metadata through the established copy path. Add synthetic regressions for P/PA images, RGB/RGBA palettes, transparent indices, full-palette allocation, and lazy PNG/GIF input, plus a release note.
Validation on Python 3.12 with the native core built from this source revision:
python selftest.py: 59 passed.python -m pytest -q Tests/test_imageops.py: 72 passed.The empty paths now call
load()throughcrop(), including for non-paletted sources. Lazy images can therefore incur decoding work or raise decoder errors that the previous empty shortcut bypassed. The full optional-codec/platform matrix was not executed locally.CI follow-up: correct the release-note heading underline and move the MinGW job to MSYS2 UCRT64, including all dependency prefixes. The MINGW64 repository no longer supplies python-pyqt6; UCRT64 supplies it and all 18 other dependencies used by this job. This retains Qt test coverage. The changed release-note section builds with Sphinx warnings treated as errors, sphinx-lint passes, and the workflow passes GitHub Actions schema validation. Windows runtime validation remains with hosted CI.