Repository navigation
Blend I;16, I and F pixels as whole values when pasting with a mask #10378
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
waw666waw666
wants to merge
4
commits into
python-pillow:main
Choose a base branch
from
waw666waw666:fix-paste-mask-wide-modes
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
0634558
Blend I;16, I and F pixels as whole values when pasting with a mask
waw666waw666 ba533da
Keep NaN and infinity out of fully opaque or transparent F pixels
waw666waw666 347895c
Merge branch 'main' of https://github.com/python-pillow/Pillow into f…
waw666waw666 c47dc49
Merge branch 'main' into fix-paste-mask-wide-modes
waw666waw666 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this preserve the fully transparent / fully opaque cases when an
Fpixel is NaN or infinity? Multiplying the ignored value by zero still produces NaN:The reverse also occurs with a NaN destination, finite source and mask 255; infinity produces the same result. I reproduced both image and scalar-color pastes on Windows/Python 3.12, comparing 0634558 with its parent 86399b1. The PR's 42 wide-mode tests and both builds' selftests passed. These were in-memory tests; the local builds had JPEG and zlib disabled.
Would short-circuiting the L-mask endpoints before the arithmetic be appropriate? Tests with non-finite values on the ignored side would catch this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for catching this! Fixed in ba533da.
blend_wide()now returns the source as it is when alpha is 255, and the destination as it is when alpha is 0 (L, LA and RGBA masks), before any arithmetic. With an RGBa mask, alpha 0 still adds the premultiplied source likePREBLEND, so only the opaque end is short-circuited there. This covers both image and color pastes.Added
test_mask_wide_non_finite_ignored, with NaN, inf and -inf on the ignored side for each mask mode; it fails on 0634558 and passes now.Tests/test_image_paste.pypasses (115), and the full suite shows no new failures compared to 0634558 (my local build has zlib and JPEG disabled, so those tests fail on both). ruff, black and clang-format are clean.