8000 rgb(r,g,b) color strings silently paint white instead of the requested color · Issue #50 · gimp-mcp/gimp-mcp · GitHub
[go: up one dir, main page]

Skip to content
8000
< 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

Open

Description

@floraschouw

Summary

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:

  1. normalises rgb(r,g,b) and CSS colour names to #RRGGBB before handing off to Gegl.Color.new(), and
  2. 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.

Environment

  • GIMP 3.2.4, Windows 10, per-user install
  • plugin: gimp-mcp-plugin.py @ 09bfb2d
  • server: mcp 1.10.1 / fastmcp 2.10.1 on Python 3.13

Activity

  1. added
    bugSomething isn't working
    documentationImprovements or additions to documentation
    on Sep 1, 2026
  2. removed
    documentationImprovements or additions to documentation
    on Oct 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0