How to properly use file_raw_save via Python (GIMP PDB Procedure)

While writing a GIMP 2.0 plugin via Python and gimpfu, I've run into pdb procedures such as file_raw_save(...). There arguments are laid out in the GIMP Procedure Browser (Help->Procedure Browser). But when calling them I receive very unhelpful output. My code and output is as follows:

Plugin code:

def save_aci(save_img, filename):
    img = save_img
    filename = filename.strip()
    pdb.file_raw_save(img, img.layers[0], filename, filename)

    "Exports to ACI file",
    "Exports image to ACI file, with LODs if they are present",
    "Save ACI File",
    "GRAYA",      # Currently only support export from Grayscale image (with alpha) to (RG_88) .aci format
        (PF_IMAGE, "save_img", "Image to Save", None),
        (PF_FILE, "filename", "Filename Fullpath", None),
    save_aci, menu="<Image>/File/")


Output when running GIMP plugin:

/home/astro/.gimp-2.8/plug-ins/ fatal error: Segmentation fault
^C/usr/lib64/gimp/2.0/plug-ins/script-fu terminated: Interrupt
gimp: terminated: Interrupt
/home/astro/.gimp-2.8/plug-ins/ terminated: Interrupt
/home/astro/.gimp-2.8/plug-ins/ terminated: Interrupt
[astro@cobalt-vm plug-ins]$ gimp
Traceback (most recent call last):
  File "/usr/lib64/gimp/2.0/python/", line 736, in response
    dialog.res = run_script(params)
  File "/usr/lib64/gimp/2.0/python/", line 361, in run_script
    return apply(function, params)
  File "/home/astro/.gimp-2.8/plug-ins/", line 128, in save_aci
    pdb.file_raw_save(img, img.layers[0], filename, filename)
RuntimeError: calling error

After messing around with the filename arguments (perhaps one expected a path, and the other just a filename), the same output occurs. I was unable to find any documentation on this issue either.

My GIMP version is 2.8 and GIMP is running the script via Python 2.7.

Any suggestions?


  • Your code is OK and works in Gimp 2.10. I get the same calling error when I run it in my Gimp 2.8. So I assume it's a bug that was fixed later.

    Gimp 2.10 has been around for over 5 years, so why Gimp 2.8?