Skip to content

SVG: use the sRGB color of a paint with an ICC color - #2196

Merged
andersonhc merged 1 commit into
py-pdf:masterfrom
RavSinghChandan:svg-icc-color-fallback
Nov 13, 2026
Merged

andersonhc merged 1 commit into
py-pdf:masterfrom
RavSinghChandan:svg-icc-color-fallback

Conversation

@RavSinghChandan

Copy link
Copy Markdown

SVG 1.1 lets a paint give an ICC color after an sRGB color (https://www.w3.org/TR/SVG11/painting.html#SpecifyingPaint), and Inkscape writes them in color-managed documents, such as stroke:#094491 icc-color(sRGB, 0.18046845, 0.27837034, 0.41960784) in the icon of Deluge. svgcolor() fails with ValueError: ... could not be interpreted as a RGB(A) hex string, so the icons of Deluge and Open TV and the logo of stlite do not convert.

Without color management the sRGB color is used, as browsers do, so svgcolor() now drops a trailing icc-color(...). This covers fill, stroke and gradient stop-color.

New cases in parameters.py and test_gradient_stop_color_with_icc_color fail without the change.

SVG 1.1 allows an ICC color after an sRGB color, as Inkscape writes
them, such as fill="#094491 icc-color(sRGB, 0.18, 0.28, 0.42)". This
failed with ValueError; the sRGB color is now used, as in browsers.
@andersonhc
andersonhc merged commit 53f5cbf into py-pdf:master Nov 13, 2026
39 of 42 checks passed
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.

2 participants