It is currently Sun Jun 14, 2026 11:30 am


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Error running Gimp Script-fu from windows cmd prompt
PostPosted: Sun Jun 09, 2019 10:50 am  (#1) 
Offline
New Member

Joined: Jun 09, 2019
Posts: 3
I am writing a simple Gimp Script-Fu script to batch process pictures of fingerprints. This is for a classroom project. The script is below:

(define (process-fingerprint filename)
(let* (
(image (car (gimp-file-load RUN-NONINTERACTIVE filename filename)))
(drawable (car (gimp-image-get-active-layer image))))
(gimp-image-rotate image 0)
(gimp-drawable-desaturate drawable 3)
(plug-in-unsharp-mask RUN-NONINTERACTIVE image drawable 3 3 0)
(gimp-drawable-threshold drawable 0 0.5 1)
(gimp-file-save RUN-NONINTERACTIVE image drawable filename filename)
(gimp-image-delete image)))

When I run this script in the gimp console using the following command, it runs just fine and does exactly what I want.

(process-fingerprint "C:\\Users\\mikef\\Documents\\Projects\\FingerPrints\\S20190605_0001.jpg")

However, the ultimate goal is to run this in a batch file from the Windows "cmd" prompt. When I run the following command at the windows command prompt -

gimp-console-2.10 -b "(process_fingerprints "C:/Users/mikef/Documents/Projects/FingerPrints/S20190605_0001.jpg")"

I get the following error:

batch command experienced an execution error:
Error: eval: unbound variable: process_fingerprints

I have tried both single backslashes and double backslashes in the path and filename argument passed to the script. Both ways give me the same error. It took me a lot of google searches to get the script working in the gimp console. I have done a ton more google searches trying to find out how to run this from the windows "cmd" prompt. I am at my wits end.

Can anyone point me in the right direction?

Thank you!

PS - I am running Gimp 2.10.8 under Windows 10.


Share on Facebook Share on Twitter Share on Orkut Share on Digg Share on MySpace Share on Delicious Share on Technorati
Top
 Post subject: Re: Error running Gimp Script-fu from windows cmd prompt
PostPosted: Sun Jun 09, 2019 11:13 am  (#2) 
Offline
New Member

Joined: Jun 09, 2019
Posts: 3
I discovered that when I am running gimp-console-2.10, I don't need the -b. However, the script is still not functioning. Maybe because I am getting the following dll errors as well:

GEGL-Message: 11:05:23.215: Module 'C:\Program Files\GIMP 2\lib\gegl-0.4\exr-load.dll' load error: 'C:\Program Files\GIMP 2\lib\gegl-0.4\exr-load.dll': The specified module could not be found.
GEGL-Message: 11:05:23.223: Module 'C:\Program Files\GIMP 2\lib\gegl-0.4\exr-save.dll' load error: 'C:\Program Files\GIMP 2\lib\gegl-0.4\exr-save.dll': The specified module could not be found.
GEGL-Message: 11:05:23.311: Module 'C:\Program Files\GIMP 2\lib\gegl-0.4\raw-load.dll' load error: 'C:\Program Files\GIMP 2\lib\gegl-0.4\raw-load.dll': The specified module could not be found.

I thought this might be a Windows path issue. So I added the path "C:\Program Files\GIMP 2\lib\gegl-0.4" to my windows PATH variable. I still get the same errors.

I have also played with running gimp-2.10 with the "-b" option to run Gimp in batch mode. When I run the following command, I get closer.

gimp-2.10 -b (process_fingerprints "C:\Users\mikef\Documents\Projects\FingerPrints\S20190605_0001.jpg")

A window pops up stating that the "batch command executed successfully". But a second window pops up giving me the following error:

Opening C:
\Users\mikef\Documents\Projects\FingerPrints\S20190605_0001.jpg)'
failed: Error opening file C:
\Users\mikef\Documents\Projects\FingerPrints\S20190605_0001.jpg):
No such file or directory

This error actually looks familiar. It seems I have seen this on a google search result. So I will go back and look.


Top
 Post subject: Re: Error running Gimp Script-fu from windows cmd prompt
PostPosted: Sun Jun 09, 2019 12:01 pm  (#3) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4812
Not a a script-fu expert, but when you do "((process_fingerprints "C:\Users\mikef\Documents\Projects\FingerPrints\S20190605_0001.jpg"))" this assumes that the function has been defined somewhere (so if it's in a file, that something loaded the file).

Given that unless you use "-n" there is one single instance of Gimp (further calls to Gimp pass the bucket to the existing instance), and since there is one single instance of the script-fu executor, if you have an interactive Gimp instance loaded when you start the batch one, and if you played with the procedure in the script-fu console of the intreactive instance, the batch process will find it.

Side note, we are in 2019 and Gimp can also be scripted in Python.

_________________
Image


Top
 Post subject: Re: Error running Gimp Script-fu from windows cmd prompt
PostPosted: Sun Jun 09, 2019 12:08 pm  (#4) 
Offline
GimpChat Member
User avatar

Joined: Jan 13, 2011
Posts: 2639
Location: Poland
Maybe try to register a script-fu (like any scripts)


(script-fu-register "process-fingerprint"
.....

SF-IMAGE "Image" 0
SF-DRAWABLE "Drawable" 0

.....

_________________
Image


Top
 Post subject: Re: Error running Gimp Script-fu from windows cmd prompt
PostPosted: Mon Jun 10, 2019 4:37 am  (#5) 
Offline
Script Coder
User avatar

Joined: Jun 22, 2010
Posts: 1171
Location: Here and there
I hope you're working on copies as your script overwrites your originals.

You're also being inconsistent about the name of your function - is it process-fingerprint or process-fingerprints ?

You need to enclose the -b argument in double-quotes, and escape the double-quotes around the file name. And escape the back-slashes.

You also need to quit gimp when you're finished (or write a script to process multiple files)

So I get this command line:
"C:\Program Files\GIMP 2.10\bin\gimp-console-2.10.exe" -b "(process-fingerprint \"C:\\Users\\paynekj\\Pictures\\tmp\\output1.jpg\")" -b "(gimp-quit 0)"


Top
 Post subject: Re: Error running Gimp Script-fu from windows cmd prompt
PostPosted: Mon Jun 10, 2019 7:04 am  (#6) 
Offline
New Member

Joined: Jun 09, 2019
Posts: 3
paynekj wrote:
I hope you're working on copies as your script overwrites your originals.

You're also being inconsistent about the name of your function - is it process-fingerprint or process-fingerprints ?

You need to enclose the -b argument in double-quotes, and escape the double-quotes around the file name. And escape the back-slashes.

You also need to quit gimp when you're finished (or write a script to process multiple files)

So I get this command line:
"C:\Program Files\GIMP 2.10\bin\gimp-console-2.10.exe" -b "(process-fingerprint \"C:\\Users\\paynekj\\Pictures\\tmp\\output1.jpg\")" -b "(gimp-quit 0)"


Paynekj,

Thank you so much! The only thing that I had to change was the first part. The command that I used was:

gimp-console-2.10.exe -b "(process-fingerprint \"C:\\Users\\mikef\\Documents\\Projects\\FingerPrints\\S20190605_0001.jpg\")" -b "(gimp-quit 0)"

It worked great. I spent hours playing yesterday trying to figure this out. I was so close. But never got there. Your help got me over the hump. Thanks again! The kids will be thrilled (I hope) by the fun we are going to have with our fingerprints.

Mike


Top
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 5 hours [ DST ]



* Login  



Powered by phpBB3 © phpBB Group