Skip to content

fix: resolve transparency to white and convert source images to sRGB - #158

Closed
kbaker827 wants to merge 1 commit into
OpenDisplay:mainfrom
kbaker827:fix/77-73-normalize-source-images
Closed

kbaker827 wants to merge 1 commit into
OpenDisplay:mainfrom
kbaker827:fix/77-73-normalize-source-images

Conversation

@kbaker827

Copy link
Copy Markdown

Fixes #77
Refs #73

Summary

  • Transparency: flattened on white when an image loads, and in the preview encoder, so a transparent drawcustom canvas matches too.
  • Colour profiles: wide-gamut sources are converted to sRGB when they load, which corrects the panel and the preview entity together, as proposed in the Source images with a non-sRGB ICC profile are pushed unconverted (Adobe RGB / Display P3) #73 discussion. sRGB sources skip the conversion. An unreadable profile logs a warning and the image still goes out.

ImageCms is imported inside the function so a Pillow build without LittleCMS cannot stop the integration from importing.

Not covered

Evidence

On the Adobe RGB photo from #73, mean difference from Unsplash's own cs=srgb render fell from 7.27 to 1.25 (per channel, 0-255).

Test plan

  • New tests/test_image_loading.py, using a real Adobe RGB profile; the behaviour tests failed before the change
  • Full suite passes. Run locally on Windows with small local stand-ins for the Unix and BlueZ modules Home Assistant needs (not part of this PR), so CI on Linux is the first clean run.
  • Not run on a real panel

🤖 Generated with Claude Code

A transparent area came out as whatever colour the encoder left beneath it, usually black, on the preview always and on the panel for grayscale and indexed files. Flatten on white when loading, and in the preview encoder so a transparent drawcustom canvas matches too.

Source images with a wide-gamut profile were quantized by their raw values against palettes defined in sRGB. Convert them when loading, which corrects the panel and the preview together. An unreadable profile is logged and the image still goes out.

A dlimg in drawcustom is loaded by odl-renderer, so its colour profile is not converted here.

Fixes OpenDisplay#77

Refs OpenDisplay#73

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kbaker827
kbaker827 requested a review from g4bri3lDev as a code owner November 6, 2026 16:13
@kbaker827

Copy link
Copy Markdown
Author

CI is waiting on maintainer approval here, so I ran the workflows on my fork at 3beae70:

  • Tests: passed, on both the latest and min-ha Home Assistant, plus ruff
  • hassfest: passed
  • HACS: 8 of 10 checks passed. The two failures are fork settings (issues disabled, no topics), and the fork's unmodified main fails the same two.

This covers this branch on its own, not merged with the other open PRs, and nothing has been run on real hardware.

@g4bri3lDev

Copy link
Copy Markdown
Member

Fixed in library, closing

@g4bri3lDev g4bri3lDev closed this Nov 14, 2026
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.

Transparent images render on a black background instead of white

2 participants