Search code examples
pythongimppython-fugimpfu

Error: ( : 1) Invalid number of arguments for python-fu command line execution


I have added the following python script to /usr/lib/gimp/2.0/plug-ins folder

#!/usr/bin/python

from gimpfu import *

def scale(imageName):
    pass

register(
    "my",
    "",
    "",
    "",
    "",
    "2017",
    "<Image>/Image/Hi..",
    "RGB*, GRAY*",
    [(PF_STRING, 'file_name', 'file_name', 'logo.png')],
    [],
    scale)

main()

Running it via

gimp --no-interface -b '(python-fu-my RUN-NONINTERACTIVE "logo.png")' -b '(gimp-quit 0)'

returns

batch command experienced an execution error: Error: ( : 1) Invalid number of arguments for python-fu-my (expected 4 but received 2)

In Gimp's Procedure Browser there are 4 parameters indeed, but it should not expect them if procedure is run via command line, should it?

Parameters

I followed the docs. What is wrong?


Solution

  • You shouldn't register the function as a plugin, and you should call it directly (scale("logo.png")). But your code has to explicitly load the image file to obtain a gimp.Image object.