FIX Clamp ImageResizingConverter output dimensions#2169
Conversation
…low-1-pixel dimensions in ImageResizingConverter
|
@microsoft-github-policy-service agree |
|
Thx for taking a look! I was on the fence, but I think ultimately I'm going to close it. I know this is a judgement call, but I think this makes the code less readable; and ultimately it just changes the exceptions raised. |
|
Thanks again for putting this together. I revisited the approach and would like to preserve this PR and your contribution. The non-finite scale-factor validation here is useful; for the zero-dimension case, the revised behavior should clamp each calculated dimension with |
Keep fractional resizing successful for tiny images while preserving the original non-finite scale-factor validation. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 0b9b23c1-ac03-4d04-962f-d4e01df4f2a7
Integrates microsoft#2169 (ImageResizingConverter clamp) and microsoft#2186 (Scenarios/Technique Registry alignment). Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 52d2518d-ebe5-4888-8189-6146b6503448
|
@romanlutz I thought it was good practice to open an issue before creating a PR, otherwise I would've created the PR directly myself. I feel like @ThryLox is taking credit for my finding. I'd have preferred to handle this. |
Description
ImageResizingConvertercan compute a zero width or height when a positive fractional scale factor is applied to a tiny image, causing Pillow to fail. It also accepted non-finite scale factors such asnanandinf.This change rejects non-finite scale factors and clamps each computed output dimension to at least one pixel. Clamping allows tiny images to resize successfully rather than replacing Pillow's exception with another error, while preserving the existing
int()truncation behavior whenever dimensions are already positive.Fixes: #2162
Tests and Documentation
nan, positive infinity, and negative infinity.