8000 Fix AttributeError in _edit_text: use Gimp.Unit.pixel() instead of Gimp.Unit.PIXEL on GIMP 3.2 by tarikkircali-amg · Pull Request #59 · gimp-mcp/gimp-mcp · GitHub
[go: up one dir, main page]

Skip to content

Fix AttributeError in _edit_text: use Gimp.Unit.pixel() instead of Gimp.Unit.PIXEL on GIMP 3.2 - #59

Open
tarikkircali-amg wants to merge 1 commit into
gimp-mcp:mainfrom
tarikkircali-amg:fix-edit-text-pixel-unit
Open

tarikkircali-amg wants to merge 1 commit into
gimp-mcp:mainfrom
tarikkircali-amg:fix-edit-text-pixel-unit

Conversation

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

Problem

In _edit_text, the font-size branch passes the text unit as Gimp.Unit.PIXEL:

cfg.set_property("unit", Gimp.Unit.PIXEL)

On the GIMP 3.2.6 Python (GObject Introspection) binding, Gimp.Unit is an object type that has no PIXEL attribute, so evaluating Gimp.Unit.PIXEL raises:

AttributeError: type object 'Unit' has no attribute 'PIXEL'

Python evaluates that argument before set_property runs, so any edit_text call that sets a new font size fails every time on GIMP 3.2.

The correct API is the function Gimp.Unit.pixel(), which returns the pixels Gimp.Unit object. The same file already uses this correct form when creating text layers (Gimp.TextLayer.new(..., Gimp.Unit.pixel())), so this line was simply inconsistent.

Fix

One line:

-                        cfg.set_property("unit",      Gimp.Unit.PIXEL)
+                        cfg.set_property("unit",      Gimp.Unit.pixel())

Verification

  • Live GIMP 3.2.6 runtime test via the same PDB path as _edit_text (gimp-text-layer-set-font-size with unit=Gimp.Unit.pixel(), font-size 42): the procedure returned SUCCESS and the text layer's actual font size read back as 42.0 pixels.
  • The test used a temporary, unsaved in-memory image and text layer; the image was deleted afterward and left no residue (open image list identical before and after).
  • 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 text editing to correctly apply font sizes in pixel units.

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: fee6105c-4bec-4b28-9317-36e015518a99

📥 Commits

Reviewing files that changed from the base of the PR and between 09bfb2d and 744d2c6.

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

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


Walkthrough

The _edit_text function now uses Gimp.Unit.pixel() instead of the removed Gimp.Unit.PIXEL member for font-size configuration.

Changes

Text editing

Layer / File(s) Summary
Pixel unit configuration
gimp-mcp-plugin.py
_edit_text uses Gimp.Unit.pixel() when setting the text-layer font size unit.

Priority: ⬇️ Low

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

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 744d2

The font-size editing path now uses the compatible pixel-unit API, so no merge-blocking risk remains.

🚥 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 identifies the main change: replacing the unavailable Gimp.Unit.PIXEL with Gimp.Unit.pixel() in _edit_text 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