0

Question is pretty much in the title. Source code i have this far:

from gimpfu import *

def add_stuff(watermark, opacity, footer, file_out):
    pass

register(
  'add-stuff',
  N_('Adds stuff'),
  'Adds watermark and Footer',
  'Malte Fischer',
  'AM-Solutions',
  '2019',
  _('Add Stuff'),
  '*',
  [
    (PF_STRING,"watermark","Watermark","Path of the watermark image"),
    (PF_INT,"opacity","Opacity","Opacity of the Watermark"),
    (PF_STRING,"footer","Footer","Path of the footer image"),
    (PF_STRING,"file_out","Output","Output path and name of the image")
  ],
  [],
  add_stuff,
  menu = "<Image>/Filters/")

main()

Saved it under {gimp installation}/lib/gimp/2.0/plug-ins/add-stuff/add-stuff.py

Thank you in advance

M. Fischer
  • 11
  • 2

1 Answers1

0

Syntax error:

Traceback (most recent call last):
File "/home/me/Code/Gimp/Foreign/Activated/baddie.py", line 13, in <module>
    _('Add Stuff'),
NameError: name '_' is not defined

Some more hints:

  1. If on OSX/Linux, also make sure the file is executable
  2. If on OSX/Linux start Gimp in a terminal, you'll see errors like this. This is of course harder to do in Windows. For Windows, some hints here
  3. If you are writing code to be called in batch mode, no need to define it as a plugin, see here for a walk-through/example. But what you are doing can likely be easier done with ImageMagick's compose command.
  4. If it is meant to be used interactively from Gimp, then the standard technique is to have a PF_IMAGE as the first parameter, this will automatically be set to the current image by the plugin call mechanism.
  5. Likewise the path of the other images can be defined as PF_FILE parameters, that give the final user a file selector (the script still receives a string, but it is much more likely to be a valid file name).
  6. Put the python file in the plug-ins directory of your own Gimp profile instead of polluting the Gimp install tree. On OSX/Linux, you can also put the file anywhere (in its own directory, together with test data, etc...), and put a link to it in that same plug-insdirectory.
xenoid
  • 8,396
  • 3
  • 23
  • 49