Skip to content

fix(cli): respect transparent image pixels in occlusion audit#2367

Closed
miguel-heygen wants to merge 2 commits into
mainfrom
fix/layout-transparent-image-occlusion
Closed

fix(cli): respect transparent image pixels in occlusion audit#2367
miguel-heygen wants to merge 2 commits into
mainfrom
fix/layout-transparent-image-occlusion

Conversation

@miguel-heygen

@miguel-heygen miguel-heygen commented Jul 13, 2026

Copy link
Copy Markdown
Collaborator

What

Make the layout occlusion audit sample the rendered alpha of <img> pixels at each text probe point instead of treating every image rectangle as fully opaque. Preserve the conservative opaque fallback for unloaded or cross-origin images whose pixels cannot be read.

Why

A full-screen transparent paper texture was reported as covering visibly unobstructed labels. The checker emitted text_occluded because <img> elements were classified as opaque based only on their bounding box.

Source report: https://heygen.slack.com/archives/C0BGC335AQY/p1783981645222299

How

  • Cache a same-origin canvas per image source.
  • Map viewport probe coordinates through object-fit and object-position into source pixels.
  • Combine sampled alpha with the element opacity chain before classifying a point as occluded.
  • Keep video/canvas behavior and unreadable-image fallback unchanged.

Test plan

  • Unit tests added/updated
  • Manual testing performed
  • Documentation updated (not applicable)

Verified:

  • bun run --filter @hyperframes/cli test -- src/commands/layout-audit.browser.test.ts (52/52)
  • bun run --filter @hyperframes/cli typecheck
  • bunx oxlint on changed files
  • pre-commit lint, format, fallow, typecheck hooks

@miguel-heygen

Copy link
Copy Markdown
Collaborator Author

Consolidated with the related layout and contrast audit fixes in #2401, which preserves this PR’s behavior and regression coverage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant