Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Script Fu - Batch Command Error
#1
Learning Scrpt Fu is slow. Any assistance is welcome regarding the Error message.


I am trying to replicated the reported success of others who have posted online. I am running GIMP 2.10.32.

Opening CMD Window within the folder:

C:\Users\parkinsj\Desktop\GIMP_Batch\

; which contains two JPG files, I ran the following:

gimp-2.10 -i -b "(batch-auto-fix "C:\Users\parkinsj\Desktop\GIMP_Batch\img*.jpg")" -b "(gimp-quit 0)"

The result was:

batch command experienced an execution error:
Error: eval: unbounded variable: C:\Users\parkinsj\Desktop\GIMP_Batch\img*.jpg

The SCM file   batch-auto-fix.scm   is at location:

C:\Program Files\GIMP 2\share\gimp\2.0\scripts

The SCM file reads:

(define (batch-auto-fix pattern  
                radius  
                amount  
                threshold)  
  (let* ((filelist (cadr (file-glob pattern 1))))  
   (while (not (null? filelist))  
      (let* ((filename (car filelist))  
          (image (car (gimp-file-load RUN-NONINTERACTIVE  
                        filename filename)))  
          (drawable (car (gimp-image-get-active-layer image))))  
       (plug-in-unsharp-mask RUN-NONINTERACTIVE  
                  image drawable radius amount threshold)  
       (gimp-levels-stretch drawable)  
       (plug-in-color-enhance RUN-NONINTERACTIVE  
                  image drawable)  
       (gimp-file-save RUN-NONINTERACTIVE  
               image drawable filename filename)  
       (gimp-image-delete image))  
      (set! filelist (cdr filelist)))))
Reply
#2
1) Learning Python-fu is somewhat faster,
2) "(batch-auto-fix "C:\Users\parkinsj\Desktop\GIMP_Batch\img*.jpg")" -b "(gimp-quit 0)": nested quotes and backslashes... the problem isn't Gimp, but the Windows shell processor (CMD.EXE).  You likely have to escape the quotes around  "C:\Users\parkinsj\Desktop\GIMP_Batch\img*.jpg" because they are inside those that delimit "(batch-auto-fix "C:\Users\parkinsj\Desktop\GIMP_Batch\img*.jpg")".  I don't remember if this is done by doubling them ("") or by putting a backslash (\"). Your error message indicates that the quotes where stripped out to the input string so Gimp no longer sees a string literal.

Then use (gimp-message ...) to print the values of the arguments you received and se of this is what you expect. No point in debugging code that doesn't receive proper arguments.
Reply
#3
As Ofnuts says, your command line needs fixing:

gimp-2.10 -i -b "(batch-auto-fix \"C:\Users\parkinsj\Desktop\GIMP_Batch\img*.jpg\")" -b "(gimp-quit 0)"

Also you would be better putting the script in your personal scripts folder not in the system folder - the next update you do to GIMP runs the risk of removing anything that's not supplied by the GIMP installer.

Your personal folder would normally be C:\Users\parkins\AppData\Roaming\GIMP\2.10\scripts

I assume you already know that your script is going to overwrite your images.
Reply
#4
(12-12-2022, 10:28 PM)Kevin Wrote: As Ofnuts says, your command line needs fixing:

gimp-2.10 -i -b "(batch-auto-fix \"C:\Users\parkinsj\Desktop\GIMP_Batch\img*.jpg\")" -b "(gimp-quit 0)"

Also you would be better putting the script in your personal scripts folder not in the system folder - the next update you do to GIMP runs the risk of removing anything that's not supplied by the GIMP installer.

Your personal folder would normally be  C:\Users\parkins\AppData\Roaming\GIMP\2.10\scripts

I assume you already know that your script is going to overwrite your images.

How does GIMP find the Personal Script Folder?

I am not familiar with GIMP Messages. I assume this is a way to get more details on the Error.

I ran this at the CMD Line.

gimp-2.10 -i -b "(batch-auto-fix \""C:\Users\parkinsj\Desktop\GIMP_Batch\img*.jpg\"")" -b "(gimp-quit 0)"

New result:

batch commend experienced an error:
Error: not enough arguments
Reply
#5
(12-13-2022, 06:45 PM)James Parkinson Wrote:
(12-12-2022, 10:28 PM)Kevin Wrote: As Ofnuts says, your command line needs fixing:

gimp-2.10 -i -b "(batch-auto-fix \"C:\Users\parkinsj\Desktop\GIMP_Batch\img*.jpg\")" -b "(gimp-quit 0)"

Also you would be better putting the script in your personal scripts folder not in the system folder - the next update you do to GIMP runs the risk of removing anything that's not supplied by the GIMP installer.

Your personal folder would normally be  C:\Users\parkins\AppData\Roaming\GIMP\2.10\scripts

I assume you already know that your script is going to overwrite your images.

How does GIMP find the Personal Script Folder?

I am not familiar with GIMP Messages. I assume this is a way to get more details on the Error.

I ran this at the CMD Line.

gimp-2.10 -i -b "(batch-auto-fix \""C:\Users\parkinsj\Desktop\GIMP_Batch\img*.jpg\"")" -b "(gimp-quit 0)"

New result:

batch commend experienced an error:
Error: not enough arguments

Why the \"" (backslash double-quote)?

not enough arguments is a Scheme error, you are calling a function with not enough arguments. Looking at your code you define (batch-auto-fix pattern  radius  amount  threshold) so it takes 4 arguments and your line above only passes the pattern argument, so this is probably why Gim/Script-fu complains.
Reply
#6
(12-14-2022, 06:11 PM)Ofnuts Wrote:
(12-13-2022, 06:45 PM)James Parkinson Wrote:
(12-12-2022, 10:28 PM)Kevin Wrote: As Ofnuts says, your command line needs fixing:

gimp-2.10 -i -b "(batch-auto-fix \"C:\Users\parkinsj\Desktop\GIMP_Batch\img*.jpg\")" -b "(gimp-quit 0)"

Also you would be better putting the script in your personal scripts folder not in the system folder - the next update you do to GIMP runs the risk of removing anything that's not supplied by the GIMP installer.

Your personal folder would normally be  C:\Users\parkins\AppData\Roaming\GIMP\2.10\scripts

I assume you already know that your script is going to overwrite your images.

How does GIMP find the Personal Script Folder?

I am not familiar with GIMP Messages. I assume this is a way to get more details on the Error.

I ran this at the CMD Line.

gimp-2.10 -i -b "(batch-auto-fix \""C:\Users\parkinsj\Desktop\GIMP_Batch\img*.jpg\"")" -b "(gimp-quit 0)"

New result:

batch commend experienced an error:
Error: not enough arguments

Why the \"" (backslash double-quote)?

not enough arguments is a Scheme error, you are calling a function with not enough arguments. Looking at your code you define (batch-auto-fix pattern  radius  amount  threshold) so it takes 4 arguments and your line above only passes the pattern argument, so this is probably why Gim/Script-fu complains.

I corrected the CMD line script to:
gimp-2.10 -i -b "(batch-auto-fix ""C:\Users\parkinsj\Desktop\GIMP_Batch\img*.jpg\"" 5.0 0.5 0)" -b "(gimp-quit 0)"

... and moderate success, no run errors

Now in checking the images they have not changed.

The learning curve continues.

Much thanks for your help.
Reply


Forum Jump: