Skip to content

fix(image): keep theme colors inside the hex range - #429

Open
rajanpanth wants to merge 1 commit into
openzim:mainfrom
rajanpanth:fix/theme-color-range
Open

rajanpanth wants to merge 1 commit into
openzim:mainfrom
rajanpanth:fix/theme-color-range

Conversation

@rajanpanth

Copy link
Copy Markdown

Summary

  • get_colors formatted channels with hex() and no upper bound. ColorThief and the solarize step can return 256, which becomes a 3-digit channel and is not a CSS color (#100… instead of #FF…).
  • Channels are clamped to 0-255 before formatting. Values that were already in range are unchanged, including the existing image fixtures (#04659B).

Test plan

  • pytest tests/image/test_color_range.py
  • pytest tests/uri is unrelated; the pinned get_colors expectations in tests/image/test_image.py still match because in-range channels are not modified

Made with Cursor

ColorThief and the solarize step can return a channel of 256. hex() turned that into three digits, so the CSS color was not valid.

Co-authored-by: Cursor <[email protected]>

This branch has not been deployed

No deployments
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