0

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?

rok
  • 9,403
  • 17
  • 70
  • 126
  • try temporarily changing `imageName` to `*imageName`, which will collect all the arguments provided to the function and wont complain if there are too many/few. Then you can print them out and see what is actually being passed. – Paul Rooney May 02 '17 at 23:55

1 Answers1

1

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.

xenoid
  • 8,396
  • 3
  • 23
  • 49
  • hi, if i run it directly i get *gimp_wire_write_msg: the wire protocol has not been initialized* error – rok May 04 '17 at 18:50
  • 1
    "Running it directly" stll means using Gimp. Something like `gimp --no-interface -b '(scale logo.png")' -b '(gimp-quit 0)'`. You may have to tweak the python path and do an explicit import of your script: `gimp-idf --batch-interpreter python-fu-eval -b 'import sys; sys.path=["."]+sys.path;import yourscript;yourscript.run("logo.png")' -b 'pdb.gimp_quit(1)` – xenoid May 05 '17 at 00:29