You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
<
8000
link rel="modulepreload" href="https://github.githubassets.com/assets/1h-bda0ef6a63d5b54c.js" crossorigin="anonymous" />
rgb(r,g,b) color strings silently paint white instead of the requested color #50
fill_rectangle(color="rgb(40,180,90)") returns {"status": "success"} and paints white instead of the requested green. Nothing errors, so a caller cannot detect the failure except by inspecting pixels.
rgb() is documented as supported. From the fill_rectangle docstring:
color: Fill color (CSS name, hex, or rgb() string)
and new_canvas:
fill: ... Any CSS color name or hex string: "white" (default), "black", "transparent", "#FF5733", "rgb(100,200,50)", etc.
Reproduce
new_canvas(800, 400, name="t", fill="white")
# black frame first, so that a white fill is actually visible
fill_rectangle(x=540, y=80, width=200, height=160, color="#000000", layer_name="t")
fill_rectangle(x=580, y=110, width=120, height=100, color="rgb(40,180,90)", layer_name="t")
Both return {"status": "success"}. The second paints a white rectangle inside the black one. get_pixel_color(640, 160, layer_name="t") then returns #ffffff.
The white-on-white case is nastier: on a default white canvas the same call looks like a complete no-op, so the failure is entirely invisible.
Root cause
Colour strings are passed straight to Gegl.Color.new() at roughly twenty call sites in gimp-mcp-plugin.py (1469, 2309, 2377, 2513, 2712, 2766, 2792, 2826, 2864, 2901, 2929, 2961-2962, 2971-2972, 3057, 3106, 3184, ...). Gegl.Color.new() does not accept rgb(r,g,b) syntax and, on a parse failure, returns a default colour instead of raising — so the error is swallowed.
Hex (#RRGGBB) works correctly.
This is the same underlying cause as #44 (CSS colour names resolving to cyan); only the fallback colour differs by input format.
Suggested fix
One _parse_color(s) -> str helper, used everywhere, that:
normalises rgb(r,g,b) and CSS colour names to #RRGGBB before handing off to Gegl.Color.new(), and
raises on anything it cannot parse, so the tool returns {"status": "error"} rather than painting the wrong colour.
The silent-wrong-colour behaviour is the dangerous part: a batch job reports success across hundreds of images while producing wrong output.
Activity