RSS/Atom feed Twitter
Site is read-only, email is disabled

Scripting, batch mode and passing filenames and colours as arguments from the command line

2016-10-07 14:18:13 UTC (over 7 years ago)
postings
2

Scripting, batch mode and passing filenames and colours as arguments from the command line

Hello,

I've written a script to load an image, substitute a plain colour background for a second image as the new background, and then save the result as a third image. (Script is attached)

This works fine from the console inside GIMP, but I need it to work from the command line. I am struggling to pass both filenames and a colour as arguments to the script. Filenames get the current directory path appended to the front of the string by default and I can't pass the colour as a list (with leading apostrophe - because the command line interprets it, and escaping it doesn't work either)

Unfortunately GIMP and python-fu don't produce very helpful error messages. "Error: (: 143920292) illegal function"

In the python-fu console this works: pdb.python_fu_test_background_swap("/home/luke/input.jpg", (0,0,0), 60, "/home/luke/background.jpg", "/home/luke/output.jpg")

but on the command line, this doesn't work: #gimp -cidf -b '(python-fu-test-background-swap 1 "/home/luke/input.jpg" (0 0 0) 60 "/home/background.jpg" "/home/luke/output.jpg")' -b'(gimp-quit 0)

Even If I limit myself to only working on files in the current directory, I'm at a loss as how to pass the colour list item as an argument.

Please can someone advise, as this is driving me crazy.

Luke

[To explain the purpose of this script. It's intended to run on a kiosk raspberry pi computer. The intention is to set up a greenscreen (chromakey) photobooth. So the subjects sit in front of a greenscreen and takes a photograph of themselves, and the booth can automatically provide a selection of different background images to the photo. The background images are already resized to be exactly the same size as the pi camera to keep the script simple]

2016-10-24 13:17:48 UTC (over 7 years ago)
postings
2

Scripting, batch mode and passing filenames and colours as arguments from the command line

I've managed to work around this issue:

Passing arguments to a script using script-fu on the command line leads to unexpected outcomes. Particularly filenames and colour arrays. The interpreter strips the directory path off filenames.

Passing arguments to the script works as expected when you invoke the script using python-fu. It took me a while to understand that you can write a script in either language and call it using either script-fu or python.

This is the command line which works for me:

gimp -c -s -f -d -i --batch-interpreter=python-fu-eval -b "pdb.python_fu_test_background_swap('/var/www/html/images/20161024_140737', (178, 140, 55), 38, '/var/www/html/images/backgrounds/1.jpg')" -b "pdb.gimp_quit(TRUE)"

[it's quite deliberately running out of the webdirectory - I'm using the web server to control a camera and view the results. It's not on a machine accessible from the internet, so security isn't a major concern.]

[I have changed the script so it takes less arguments than the script in the OP]