a11y-toolkit: Text-over-image contrast
a11y_contrast_imageChecks WCAG contrast for text over photos or gradients by sampling the actual background pixels, returning worst, median, and p95 ratios, AA pass area, and hostile zones.
Instructions
TEXT OVER IMAGE contrast: pixel-level sampling of the real background behind the text box → worst/median/p95 ratio, % of area passing AA, and automatic hostile-zone detection on a 3×3 grid (worst_zone). What pair-only checkers cannot do. region="x,y,w,h" recommended. — Use instead of a11y_contrast_pair whenever the background is a photo/gradient. Returns JSON: {worst_ratio, median_ratio, p95_ratio, area_passes_aa_normal_text_4_5, worst_zone, sampled_pixels}.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| lang | No | Output language (default en) | |
| path | Yes | Local path to the screenshot/image the text sits on (PNG/JPG/PPM) | |
| region | No | Text bounding box as "x,y,width,height" in pixels (strongly recommended: defines what to sample) | |
| sample | No | Pixel step: 4 samples every 4px (auto-raised for huge regions) | |
| text_color | Yes | The text color as rendered over the image (must be opaque) |