From c14ec612c9ac8c36cfd1af9b947b27fcb71ce9c9 Mon Sep 17 00:00:00 2001 From: Anthony Herman Date: Fri, 1 May 2026 21:24:55 -0500 Subject: [PATCH] Fix select_by_color silently no-opping on GIMP 3.2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The PDB procedure 'gimp-by-color-select' does not exist in GIMP 3.2 — it was renamed to 'gimp-image-select-color'. The previous code called pdb.lookup_procedure() which returned None, then guarded the run with `if proc:` and silently fell through to a successful return. No selection ever got created, so any subsequent operation that depends on the selection (notably fill_selection with fill_type='transparent', which calls Gimp.Drawable.edit_clear) acted on the entire layer. Switch to the GIMP 3.2 procedure name and raise if the lookup fails so the failure is surfaced instead of swallowed. The new procedure config exposes only image/drawable/color/operation; threshold, antialias, and feather settings are now read from the GIMP context, so set them via Gimp.context_* inside a context_push/pop pair. Co-Authored-By: Claude Opus 4.7 --- gimp-mcp-plugin.py | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/gimp-mcp-plugin.py b/gimp-mcp-plugin.py index 1ee8ca8..8f3ac5a 100755 --- a/gimp-mcp-plugin.py +++ b/gimp-mcp-plugin.py @@ -2376,18 +2376,26 @@ def _select_by_color(self, params): op = self._channel_ops_from_string(operation) color = Gegl.Color.new(color_str) pdb = Gimp.get_pdb() - proc = pdb.lookup_procedure("gimp-by-color-select") - if proc: + proc = pdb.lookup_procedure("gimp-image-select-color") + if proc is None: + raise RuntimeError( + "PDB procedure 'gimp-image-select-color' not found" + ) + Gimp.context_push() + try: + Gimp.context_set_antialias(True) + Gimp.context_set_feather(False) + Gimp.context_set_sample_threshold_int(threshold) + Gimp.context_set_sample_merged(False) + Gimp.context_set_sample_transparent(False) cfg = proc.create_config() - cfg.set_property("drawable", drawable) - cfg.set_property("color", color) - cfg.set_property("threshold", threshold) - cfg.set_property("operation", op) - cfg.set_property("antialias", True) - cfg.set_property("feather", False) - cfg.set_property("feather-radius", 0.0) - cfg.set_property("sample-merged", False) + cfg.set_property("image", image) + cfg.set_property("drawable", drawable) + cfg.set_property("color", color) + cfg.set_property("operation", op) proc.run(cfg) + finally: + Gimp.context_pop() Gimp.displays_flush() return {"status": "success", "results": {"status": "success"}} except Exception as e: