8000 Fix auto levels on GIMP 3.2 by tarikkircali-amg · Pull Request #60 · gimp-mcp/gimp-mcp · GitHub
[go: up one dir, main page]

Skip to content

Fix auto levels on GIMP 3.2 - #60

Open
tarikkircali-amg wants to merge 1 commit into
gimp-mcp:mainfrom
tarikkircali-amg:fix-auto-levels-gimp-3.2
Open

tarikkircali-amg wants to merge 1 commit into
gimp-mcp:mainfrom
tarikkircali-amg:fix-auto-levels-gimp-3.2

Conversation

@tarikkircali-amg
@tarikkircali-amg tarikkircali-amg commented Sep 17, 2026 •
Copy link
Copy Markdown

Problem

_auto_levels looks up the PDB procedure gimp-levels-stretch:

proc = pdb.lookup_procedure("gimp-levels-stretch")

That procedure does not exist in GIMP 3.2.6, so lookup_procedure returns None and the code takes its else fallback, which calls gimp-drawable-levels with identity parameters (low-input=0.0, high-input=1.0, gamma=1.0, low-output=0.0, high-output=1.0). That identity mapping returns SUCCESS but does not change the image — so auto_levels silently does nothing on GIMP 3.2 while reporting success.

GIMP 3.2.6 provides the correct procedure gimp-drawable-levels-stretch, which takes a single drawable argument — exactly what the existing if proc: branch already passes.

Fix

One line — switch the lookup to the procedure that exists in GIMP 3.2:

-                proc = pdb.lookup_procedure("gimp-levels-stretch")
+                proc = pdb.lookup_procedure("gimp-drawable-levels-stretch")

The if proc: branch (set_property("drawable", drawable) then proc.run(cfg)) already matches the single-argument signature, so no other change is needed. The identity fallback is left untouched (out of scope).

Verification

Live GIMP 3.2.6 runtime test of the fixed path (gimp-drawable-levels-stretch, single drawable arg) on a temporary, unsaved deterministic low-contrast grayscale image (stored value range 100–150):

Metric Before After
PDB status — SUCCESS
histogram mean (0–255) 125.0 168.063
histogram std_dev 14.874 60.718
linear min / max 0.1274 / 0.305 0.011 / 0.9911

The range is genuinely stretched (std_dev and min/max spread both increase). For reference, the old identity fallback left every one of these values unchanged.

The test used a temporary in-memory image that was deleted afterward; the open-image list was identical before and after (no residue), and no pre-existing image was touched.

  • python -m py_compile gimp-mcp-plugin.py passed.
  • git diff --check passed.

Scope: 1 line changed (1 insertion, 1 deletion) in gimp-mcp-plugin.py.

Summary by CodeRabbit

  • Bug Fixes
    • Fixed automatic levels adjustment to use the correct drawable-specific operation, improving compatibility with current image-editing APIs.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@coderabbitai
coderabbitai Bot commented Sep 17, 2026 •
Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 1c3ff9f2-fe21-47ac-a726-e68b5cb7fcd0

📥 Commits

Reviewing files that changed from the base of the PR and between 09bfb2d and 685f72b.

📒 Files selected for processing (1)
  • gimp-mcp-plugin.py

Included review availability: Your plan provides up to 2 included reviews per hour; 0 remain after this review.


Walkthrough

The auto-levels path now looks up gimp-drawable-levels-stretch instead of gimp-levels-stretch. Its fallback configuration remains unchanged.

Changes

Auto-levels procedure lookup

Layer / File(s) Summary
Update auto-levels procedure lookup
gimp-mcp-plugin.py
_auto_levels now uses the drawable-scoped PDB procedure name. The existing gimp-drawable-levels fallback remains unchanged.

Priority: ⬇️ Low

Estimated code review effort: 1 (Trivial) | ~2 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 685f7

The auto-levels update is compatible with the supported GIMP 3.2 procedure API and presents no concrete merge-blocking risk.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: fixing auto-levels support for GIMP 3.2.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

0