Keep ImageOps.contain dimensions at least one pixel - #9998
Closed
ROTl24 wants to merge 1 commit into
Closed
Conversation
contain 在正数目标尺寸下可能把短边舍入为零,导致 resize 抛出异常,并连带影响 pad。将计算出的短边限制为至少一个像素,保留已有正常尺寸计算。 新增横向、纵向及半像素边界四组回归用例,检查 contain 尺寸和 pad 内容,并补充 13.0.0 发布说明。修复前四组失败,修复后 ImageOps 文件 53 项测试通过。验证采用当前 ImageOps 源码与已安装 Pillow 12.3.0 核心,未构建当前主分支 C 扩展或运行完整测试套件。已安装核心 selftest 59 项通过,Black、Ruff、sphinx-lint 和差异检查通过;Black 提示运行时低于目标 Python 版本。
Member
|
This is a duplicate of #9672 |
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.
Fixes #9997.
Changes proposed in this pull request:
ImageOps.contain()at least one pixel. For example, fitting a 100×1 image into 10×10 currently calculates a height of zero and raisesValueError. With this change it returns 10×1.pad()dimensions, image content, and background color.Validation on Windows / Python 3.13.15: all four new cases failed before the fix, and all 53 tests in
Tests/test_imageops.pypassed after it. These runs loaded this checkout'sImageOps.pyagainst the installed Pillow 12.3.0 modules and binary core; I did not build main's C extensions or run the full suite. The installed core also passed the 59 selftests.Black, Ruff, sphinx-lint, and
git diff --checkpassed for the changed files. Black reported that the Python 3.13 runtime is older than the configured Python 3.15 target.Prepared with OpenAI Codex assistance.