Post Reply 

GIMP batch process script run-time error

Apr 8, 2014, 09:10 (This post was last modified: Apr 8, 2014 09:16 by Paddy Landau.)
Post: #1
GIMP batch process script run-time error
I have installed script-fu-pencil-drawing, which works well.

My problem arises when I want to use this in batch mode; I have many pictures to process, so doing them manually is not a reasonable option.

I have taken the example verbatim from the tutorial for batch scripting. The example uses plug-in-unsharp-mask, and again it works well.

However, when I modify the script to use script-fu-pencil-drawing, the batch process fails. Here are the details.

My modified script:
Code:
(define (simple-script-fu-pencil-drawing filename
                                         radius
                                         strength
                                         mergelayers)
   (let* ((image (car (gimp-file-load RUN-NONINTERACTIVE filename filename)))
          (drawable (car (gimp-image-get-active-layer image))))
          (script-fu-pencil-drawing RUN-NONINTERACTIVE
                                    image drawable radius strength mergelayers)
     (gimp-file-save RUN-NONINTERACTIVE image drawable filename filename)
     (gimp-image-delete image)))

The command line, where foo.png is my test image:
Code:
gimp -i -b '(simple-script-fu-pencil-drawing "foo.png" 8.0 16.0 TRUE)' -b '(gimp-quit 0)'

Here is the error that I get.
Code:
GIMP-Error: Calling error for procedure 'gimp-layer-copy':
Procedure 'gimp-layer-copy' has been called with an invalid ID for argument 'layer'. Most likely a plug-in is trying to work on a layer that doesn't exist any longer.

batch command experienced an execution error:
Error: ( : 1) Procedure execution of gimp-layer-copy failed on invalid input arguments: Procedure 'gimp-layer-copy' has been called with an invalid ID for argument 'layer'.
Most likely a plug-in is trying to work on a layer that doesn't exist any longer.
I have tried various changes, none of which works, and Google hasn't helped me.

If you can tell me how to fix this, please, I would be most grateful.

I'm using GIMP 2.8.10 on Linux Ubuntu 12.04.
Find all posts by this user
Quote this message in a reply
Apr 8, 2014, 19:46
Post: #2
RE: GIMP batch process script run-time error
(Apr 8, 2014 09:32)paynekj Wrote:  Try it without the RUN-NONINTERACTIVE parameter in the script-fu-pencil-drawing call.
Kevin, thank you. I would never have guessed that.

Your suggestion has removed the reported error, but a problem still remains.

The script processes the file, as can be seen by a change in both the file size and the modified date. However, visually, the two images appear identical. The pencil-drawing has not actually been applied.

If I process the file manually (GIMP > Filters > Pencil-Drawing > fill in the parameters > OK; File > Export As… > replace file), it works properly. But when using the script, it appears to work properly but doesn't actually change the image (apart from shrinking the file size).

I've tried changing a few lines in the script, but as a complete newbie to scripting, I'm working pretty much in the dark. My guess is that the new layer needs to be made active, but I've not managed to do anything without creating further errors.

Do you know how to fix this last problem?
Find all posts by this user
Quote this message in a reply
Apr 8, 2014, 20:33
Post: #3
RE: GIMP batch process script run-time error
Yay, I managed to solve the problem!

Here is the revised script. I have reformatted it to make it easier (for me) to locate all the parentheses. I replaced the single line containing gimp-file-save with the group beginning with the second let*.

This was mostly guesswork on my part, because I don't know Scheme, so I'll welcome any improvements to the script.

Code:
(define (simple-script-fu-pencil-drawing filename
                                         radius
                                         strength
                                         mergelayers
        )
        (let* (
                (image (car (gimp-file-load RUN-NONINTERACTIVE filename filename)))
                (drawable (car (gimp-image-get-active-layer image)))
              )
              (script-fu-pencil-drawing image drawable radius strength mergelayers)
              (let* ( (newdrawable (car (gimp-image-get-active-layer image))) )
                    (gimp-file-save RUN-NONINTERACTIVE image newdrawable filename filename)
              )
              (gimp-image-delete image)
        )
)

Thank you again. I couldn't have done it without your help.
Find all posts by this user
Quote this message in a reply
Post Reply 


Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  PDN Plug-in for GIMP? snoopy55 11 11,033 Dec 3, 2018 09:16
Last Post: paynekj
  Run Deskew plugin from Python-Fu console ramonvaldezz 12 3,201 Nov 18, 2018 21:48
Last Post: paynekj
  Run script on action rchav 2 1,239 Aug 13, 2018 14:57
Last Post: rchav
  Script Fu Errors Gimp 2.10.4 lightsaber jd3481 1 808 Aug 2, 2018 05:13
Last Post: paynekj
  Script-fu script to conversion pdf to image 4ever 12 14,167 Jul 17, 2018 16:01
Last Post: paynekj

Forum Jump:


GIMP ForumPortalArchiveContactTermsRSS