2

I'm attempting to open two images and paste one on top of the other as it's own layer using a script-fu. I need to then call this script from the command line (windows) passing in two file names.

Here's my .scm code:

(define (open-as-layer file1 file2)
    (let* (
            ; first main image
            (image (car (gimp-file-load RUN-NONINTERACTIVE file1 file1)))
            ; them layer
            (draw1 (car (gimp-image-get-active-drawable image)))
            ; open image as layer
            (draw2 (car (gimp-file-load-layer RUN-NONINTERACTIVE image file2)))
        )

    ; add layer to image
    (gimp-image-insert-layer image draw2 0 0)

    )
)

When I used this command:

gimp-2.10 -d -b '(open-as-layer "C:\Users\me\Desktop\testoriginal.pgm" "C:\Users\me\Desktop\testfinished.pgm")'

Gimp opens and loads the first image fine, but produces this error on loading the second:

Opening 'C:\Users\me\Desktop\testfinished.pgm)'' failed: Error opening file C:\Users\me\Desktop\testfinished.pgm)': No such file or directory

The error shows that it thinks the file name is C:\Users\me\Desktop\testfinished.pgm)', notice the )' is included. So I tried adding a space after the full file name in the command:

gimp-2.10 -d -b '(open-as-layer "C:\Users\me\Desktop\testoriginal.pgm" "C:\Users\me\Desktop\testfinished.pgm" )'

And gimp now loads both images in separate tabs, but tries to load a third image and fails with this error:

Opening 'C:\Program Files\GIMP 2\bin\)'' failed: Error opening file C:\Program Files\GIMP 2\bin\)': No such file or directory

Again, it tried to load an image (an empty string?) but included the )'

All I need is to get it to recognize just the string within the double quotes.

Ausche
  • 139
  • 2
  • 12
  • Try using double quotes around your Gimp parms and escaping the quotes as seen by script-fu, something like: `gimp-2.10 -d -b "(open-as-layer \"C:/Users/me/Desktop/testoriginal.pgm\" \"C:/Users/me/Desktop/testfinished.pgm\" )"` (unless you just ave to use double double quotes). You can also make your life simpler by using forward slashes in file names (that work OK in Windows). – xenoid Jan 08 '19 at 00:30
  • You can also use Python for this. Python scripts are at an avantage here, because you can use double quotes outside and single quotes inside, see [here](https://stackoverflow.com/questions/44430081/how-to-run-python-scripts-using-gimpfu-from-windows-command-line/44435560#44435560)/). – xenoid Jan 08 '19 at 00:31

0 Answers0