Skip to content

Raise ValueError when blending with inf or nan alpha - #10570

Closed
lazerg wants to merge 2 commits into
python-pillow:mainfrom
lazerg:fix/issue-10567-enhance-nan
Closed

lazerg wants to merge 2 commits into
python-pillow:mainfrom
lazerg:fix/issue-10567-enhance-nan

Conversation

@lazerg

@lazerg lazerg commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #10567

Image.blend() passed a NaN alpha straight through to C, so every pixel came out as one clipped value (black in the report on 13.0.0, white on main). ImageEnhance goes through Image.blend(), so all four enhancers did the same. An inf alpha has the same problem wherever the two images have equal pixels, since inf * 0 is NaN. This raises a ValueError for both, similar to #10440 for rotate(). Finite values still work as before.

@lazerg lazerg changed the title Raise ValueError when blending with nan alpha Raise ValueError when blending with inf or nan alpha Nov 20, 2026
@lazerg

lazerg commented Nov 20, 2026

Copy link
Copy Markdown
Contributor Author

The Windows failures happen while building libavif's dav1d dependency with the new MSVC, before the tests run. Main fails the same way, and #10569 fixes it.

@radarhere

Copy link
Copy Markdown
Member

#10567 (comment)

I'm slightly reluctant to action this - I don't want to end up validating every float input to Pillow to check if it is NaN

@radarhere radarhere closed this Nov 22, 2026
@radarhere

Copy link
Copy Markdown
Member

Thanks anyway for attempting to resolve the issue!

@lazerg

lazerg commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

understood, thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"ImageEnhance (Color/Contrast/Brightness/Sharpness) .enhance(factor=NaN) silently returns an all-black image"

2 participants