Fix label line-height in image-annotations skill (getbbox bottom-top)#2266
Open
drognanar wants to merge 1 commit into
Open
Fix label line-height in image-annotations skill (getbbox bottom-top)#2266drognanar wants to merge 1 commit into
drognanar wants to merge 1 commit into
Conversation
font.getbbox() returns (left, top, right, bottom), so text line height must be bottom - top (bbox[3] - bbox[1]). The label placement code used bbox[3] - bbox[0] (bottom - left), mixing an x-coordinate into a height and producing a slightly wrong label-box height (empirically off by 0-4px depending on font). The debug heatmap labeling in the same module already uses the correct bbox[3] - bbox[1], so this brings placement in line.
Contributor
🔒 PR Risk Scan ResultsScanned 1 changed file(s).
✅ No matching risk patterns were detected in changed files.
|
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request fixes a text measurement bug in the embedded annotate.py code within the image-annotations skill, ensuring label background sizing uses the correct font bounding-box height calculation.
Changes:
- Corrects line-height computation from
bottom - lefttobottom - topby usingbbox[3] - bbox[1]. - Stores the
'Ay'bbox once before computingline_h, aligning this code path with other bbox usage in the same module.
Contributor
🔍 Vally Lint Results⛔ Findings need attention
Summary
Full linter output
|
Contributor
|
LGTM, but I have no power here. |
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.
Pull Request Checklist
README.mdis up to date. (No README change — this is a code-logic fix inside an existing skill; no frontmatter/titles changed.)mainbranch for this pull request.Description
Fixes a small line-height bug in the
annotate.pymodule embedded inskills/image-annotations/SKILL.md.ImageFont.getbbox()returns(left, top, right, bottom). Text height must therefore bebottom - top=bbox[3] - bbox[1]. The automatic label-placement code computed it asbbox[3] - bbox[0](bottom - left), which mixes an x-coordinate into a height:Why it matters:
line_hfeeds the label-box height (th), so the black label background is sized slightly wrong. The error equals the glyph's top bearing — empirically 0–4px depending on font (≈4px Consolas, ≈2px Pillow default, ≈1px Ink Free @32). It's most visible on multi-line labels where the error accumulates per line.The debug heatmap labeling a few lines down in the same module already uses the correct
bbox[3] - bbox[1], so this simply brings label placement in line with the rest of the file.Found while vendoring this skill into another repo.
Type of Contribution
Additional Notes
Validation:
python -m py_compile).annotate_image()end-to-end on a 2326×1486 screenshot with both single-line and multi-line labels — output renders correctly with correctly-sized label backgrounds.