fix(testdata): normalize diff artifacts to 813x1626 canvas - #38
Open
GOODBOY008 wants to merge 3 commits into
Open
fix(testdata): normalize diff artifacts to 813x1626 canvas#38GOODBOY008 wants to merge 3 commits into
GOODBOY008 wants to merge 3 commits into
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The new “perfect match” cleanup path is keyed off diff_image == None, which can also occur on dimensions-only mismatches, potentially deleting useful artifacts and mislabeling a mismatch as perfect.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR addresses inconsistent image dimensions in testdata/diffs/ artifacts by normalizing diff outputs to the standard 813×1626 canvas and preventing legacy diff images from lingering when a label now renders without pixel differences.
Changes:
- Add a self-healing cleanup step in
e2e_diff_reportto remove stale*_diff.pngartifacts when no diff image is produced. - Introduce
remove_diff_image()helper intests/common/image_compare.rsto delete previously saved diff images. - Regenerate
testdata/diffs/diff_report_unit.txtto reflect normalized dimensions and updated diff percentages.
File summaries
| File | Description |
|---|---|
| tests/e2e_diff_report.rs | Removes stale diff artifacts when the comparison produces no diff image. |
| tests/common/image_compare.rs | Adds helper to delete previously saved diff images in testdata/diffs/. |
| testdata/diffs/diff_report_unit.txt | Updates the unit diff report after normalization (dims and diff% changes). |
Review details
- Files reviewed: 3/32 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
145
to
151
| if let Some(ref diff_img) = result.diff_image { | ||
| image_compare::save_diff_image(&name, diff_img); | ||
| } else { | ||
| // Perfect match — drop any stale diff image left over from an older canvas | ||
| // size (the pipeline no longer produces one, so it could never be refreshed). | ||
| image_compare::remove_diff_image(&name); | ||
| } |
GOODBOY008
force-pushed
the
fix/normalize-diff-artifacts-canvas
branch
2 times, most recently
from
September 2, 2026 15:35
db0235d to
6d2abaa
Compare
Several diff artifacts in testdata/diffs/ were stale or mismatched: - gb_normal/gb_0_width/gb_0_height, postnl_qr, qr_code_offset: leftover 400x640 diff images from an old canvas era; these labels are now PERFECT so the pipeline never regenerated them - cf_font_designator, cf_font_no_orientation, code128_mode_d_fnc1, cp850_hex_chars, fo_lenient_coord, maxicode_default_mode2, maxicode_mode4: Labelary reference PNGs were 812x1624, so every diff run produced 1629x1626 comparisons and 812x1624 diffs Fix: pad the 7 unit references to 813x1626 (same normalization the bootstrap already applies to new fetches), drop the stale diff images, and make the diff report self-healing — when a label has no diff, remove any leftover diff image so old canvases can't linger. Diff percentages drop for the 7 labels since the spurious 1px column no longer counts (e.g. fo_lenient_coord 0.27% -> 0.02%, maxicode labels 0.84%/0.83% -> 0.59%/0.58%). All e2e_golden tests still pass.
GOODBOY008
force-pushed
the
fix/normalize-diff-artifacts-canvas
branch
from
September 2, 2026 15:52
6d2abaa to
fdb6512
Compare
Labels improved: - font_p: 0.54% → 0.16% (GOOD <1%) Root cause: ^APN,,30 was treated as height=width=30 via the generic scalable-font path, but Labelary renders font P (Letter Gothic) at a 15-dot default em with the width parameter setting the character advance linearly (~0.44 x w). Changes: - src/elements/font.rs: font P defaults to 15 dots when h/w omitted (measured: ^APN,,15 == ^APN,,; ^APN,,30 == 2x width); advance ratio 0.90 (Labelary ~0.44em advances vs DejaVu Mono Bold's 0.518em) - src/drawers/renderer.rs: cap scale 1.10 + low-cap anchor 0.30em, calibrated against the Labelary reference (sweep 0.80-0.95 ratio, 1.0-1.4 cap, 0.0-0.30em anchor) - docs/DIFF_THRESHOLDS.md: add font_p row (0.16 / tolerance 1.0) - testdata/diffs: regenerated font_p comparison + diff images
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.
问题
testdata/diffs/中部分 diff 产物尺寸不一致,根源有两类:1. 过期残留(gb_normal / gb_0_width / gb_0_height / postnl_qr / qr_code_offset)
这三个标签以及 postnl_qr、qr_code_offset 的
*_diff.png是 400×640 的旧画布时代(50×80mm 默认画布)产物。这些标签现在与 Labelary 渲染完全一致(PERFECT 0.00%),管线不再生成 diff 图,旧文件就永远留在仓库里。font_p/font_q/font_s 也有同样的 813×1626 时代残留。2. 引用 PNG 尺寸不一致(7 个标签)
cf_font_designator、cf_font_no_orientation、code128_mode_d_fnc1、cp850_hex_chars、fo_lenient_coord、maxicode_default_mode2、maxicode_mode4的 Labelary 引用 PNG 是 812×1624(服务端浮点舍入),其他全部是 813×1626。导致每次 diff 报告都生成 1629×1626 对比图、812×1624 diff 图,并多计 1px 列的"伪差异"。修复
*_diff.pnge2e_diff_report增加自愈:某标签无 diff 时自动清理遗留的旧尺寸 diff 图,防止画布变更后残留验证
_diff.png统一为 813×1626,所有对比图为 1630×1626,报告中无尺寸不一致行e2e_golden109 个测试全过,unit_golden_png_dimensions通过