8000 [Bug] GIMP 3.2.6 API regressions in export_sprite_sheet, edit_text, set_active_image, close_image, undo/redo, and _export_to_path · Issue #64 · gimp-mcp/gimp-mcp · GitHub
[go: up one dir, main page]

Skip to content

[Bug] GIMP 3.2.6 API regressions in export_sprite_sheet, edit_text, set_active_image, close_image, undo/redo, and _export_to_path #64

Open

Description

@Gustavo-Github

Environment

  • GIMP Version: 3.2.6
  • OS: Windows 10/11 (x64)
  • Plugin: gimp-mcp-plugin.py (main)

Summary

While running a full 79-tool verification against GIMP 3.2.6, 6 tools failed with AttributeError due to GIMP 2.x / early 3.0 remnants, and _export_to_path silently exported PNG data for JPEG/WebP/TIFF files.


1. export_sprite_sheet: type object 'ImageBaseType' has no attribute 'RGBA'

  • Location: gimp-mcp-plugin.py (line ~3672 in _export_sprite_sheet)
  • Cause: Gimp.ImageBaseType only defines RGB, GRAY, and INDEXED. Alpha belongs to Gimp.ImageType.RGBA_IMAGE on the layer. Also, calling self._export_to_path(sheet, output_path, "png", 95, True) with flatten=True strips the transparent background of the sprite sheet.
  • Fix:
sheet = Gimp.Image.new(sheet_w, sheet_h, Gimp.ImageBaseType.RGB)
# ...
self._export_to_path(sheet, output_path, "png", 95, False)

2. edit_text: type object 'Unit' has no attribute 'PIXEL' & GimpFont type mismatch

  • Location: gimp-mcp-plugin.py (line ~3169 & ~3177 in _edit_text)
  • Cause:
    1. In GIMP 3.2 PyGObject, pixel unit is retrieved via Gimp.Unit.pixel() (as already used in _create_text_layer_native on line 3033), not Gimp.Unit.PIXEL.
    2. gimp-text-layer-set-font expects a Gimp.Font object (resolved via self._resolve_font(new_font)), not a raw string.
  • Fix: Use Gimp.Unit.pixel() and self._resolve_font(new_font) (or call layer.set_text(), layer.set_font(), layer.set_font_size(), layer.set_color() directly on Gimp.TextLayer).

3. set_active_image & close_image: 'gi.repository.Gimp' object has no attribute 'get_displays'

  • Location: gimp-mcp-plugin.py (lines ~3800 and ~3908)
  • Cause: Both Gimp.get_displays() and display.get_image() were removed from libgimp in GIMP 3.2. Additionally, calling image.delete() fails while a Gimp.Display is still attached to the image, whereas Gimp.Display.delete(display) closes both the display and the underlying image.
  • Fix: Track the display.get_id() returned by Gimp.Display.new(image) in _new_canvas and _open_image (self._image_displays[image.get_id()] = display.get_id()), or enumerate valid displays via Gimp.Display.get_by_id(i).

4. undo & redo: 'Image' object has no attribute 'undo' / 'redo'

  • Location: gimp-mcp-plugin.py (lines ~3822 and ~3839)
  • Cause: Gimp.Image.undo() and Gimp.Image.redo() are not exposed in GIMP 3.2's libgimp bindings or PDB (only undo_group_start/end, undo_freeze/thaw, undo_enable/disable exist).

5. _export_to_path & export_web_optimized: Always exports PNG even when format is jpeg, webp, or tiff

  • Location: gimp-mcp-plugin.py (line ~1561 in _export_to_path)
  • Cause: _export_to_path looks up file-jpeg-save, file-webp-save, and file-tiff-save. In GIMP 3.2, these PDB procedures were renamed to file-jpeg-export, file-webp-export, and file-tiff-export. Because lookup_procedure("file-jpeg-save") returns None, _export_to_path falls back to file-png-export and writes PNG bytes into .jpg files (causing export_web_optimized to report identical sizes for .jpg and .png).
  • Fix: Look up file-<fmt>-export first, falling back to file-<fmt>-save.

Activity

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