Check text contrast over a background image
Measure text contrast over a background image at the weakest point behind the letters. Test a new crop and choose a backing color when a photo varies.
Find the weakest part of the photo
For white text, start with the brightest patch behind the letters. For black text, start with the darkest. A photo’s average color can hide a failure where just one word crosses a window or a shadow. Capture the final layout, then hide the lettering without moving the image to sample the background at those positions.
Test the foreground against each sampled background
Enter the text color and a sampled background as a pair in the contrast checker. White on white yields 1:1 and white on black yields 21:1. Use these pairs to check your setup. For ordinary body text under WCAG AA, each tested pair needs at least 4.5:1. A handful of passing samples on a busy photo may still miss a failing region.
Keep contrast stable as the crop moves
A desktop headline over dark foliage may sit over the sky once the image is cropped on a phone. Try the narrow layout, longer translated text and a replacement photo. An opaque panel behind the whole text block gives you a single background to check. For a translucent scrim, sample the composited result again wherever the image is brightest or darkest.
Tools featured in this guide
Related formats
Frequently asked questions
Can I sample a pixel at the edge of a letter?
Use the specified text color. Anti-aliased edge pixels contain a blend of the text and the background and can give a misleading value.
What if a content editor can replace the image?
Provide a solid text backing or place the caption outside the photo. Verify the text against that surface so the next image can change independently.
Authoritative Specifications & References
More color guides
- WCAG 2.2 Contrast Ratio vs APCA (Lc): Complete Color GuideCompare WCAG 2.2 relative luminance ratios (4.5:1) against modern APCA perceptual lightness contrast (Lc 60/75/90), dark-mode polarity, and CVD.
- Choose accessible line chart colorsChoose accessible line chart colors and pair them with labels, markers and dash patterns so readers can follow each series through a crossing.
- Zero-Server Browser Color Processing: Privacy & ArchitectureHow Colr executes Canvas quantization, CSS rewriting, and binary .ase/.aco/.cube parsing 100% inside local browser RAM with zero file transfers.
- Hex to OKLCH: Migrating Design Tokens to Tailwind CSS v4Step-by-step guide to upgrading Hex and HSL Tailwind v3 themes into CSS Color 4 @theme oklch() scales with perceptual brightness and Display P3 support.