test: add percentage-based tolerance for image size verification#3660
Open
ceberam wants to merge 3 commits into
Open
test: add percentage-based tolerance for image size verification#3660ceberam wants to merge 3 commits into
ceberam wants to merge 3 commits into
Conversation
Signed-off-by: Cesar Berrospi Ramis <ceb@zurich.ibm.com>
The images in docx should pass the verification with small tolerance due to cross-platform Signed-off-by: Cesar Berrospi Ramis <ceb@zurich.ibm.com>
Signed-off-by: Cesar Berrospi Ramis <ceb@zurich.ibm.com>
Contributor
|
✅ DCO Check Passed Thanks @ceberam, all your commits are properly signed off. 🎉 |
Contributor
Merge ProtectionsYour pull request matches the following merge protections and will not be merged until they are valid. 🟢 Enforce conventional commitWonderful, this rule succeeded.Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
PeterStaar-IBM
approved these changes
Jun 19, 2026
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.
Summary
Implements percentage-based tolerance for image size verification in
verify_picture_image_v2()to handle cross-platform rendering differences, following the same pattern as bounding box verification.Problem
Image verification tests were failing when run on different platforms (Linux vs macOS) due to minor pixel differences in image dimensions caused by platform-specific rendering. These failures occurred even when the code was working correctly, blocking legitimate test runs.
Example failure:
Solution
Added percentage-based tolerance thresholds similar to existing bbox verification:
Constants added:
STRICT_IMAGE_SIZE_TOL_RATIO = 0.015(~1.5% tolerance for cross-platform variance)FUZZY_IMAGE_SIZE_TOL_RATIO = 0.05(~5% tolerance for OCR/image processing variance)Key features:
_assert_bbox_close()Testing
✅ All existing tests pass (15 tests in
test_verify_utils.py)✅ New parameterized test covers 8 scenarios (strict/fuzzy modes, width/height, edge cases)
✅ Original failing case (254x267 vs 251x267) now passes in strict mode
✅ DOCX tests now run with
fuzzy=False, demonstrating proper cross-platform handling✅ Cross-platform compatibility verified on macOS and Fedora Linux
Related Issues
Fixes #3659