Post Reply 

Batch problem

Mar 1, 2012, 12:08
Post: #1
Batch problem
I am a newbie having trouble getting the sample batch programs to run. I placed simple-unsharp-mask.scm in C:\.gimp-2.6\scripts and put the .bat file in the E: drive directory with the image file foo.png. When I run the .bat file on my PC running Vista, I get "batch command experienced an execution error." Here is the .bat file:

"C:\Program Files\GIMP-2.0\bin\gimp-2.6.exe" -i -b "(simple-unsharp-mask \"foo.png\" 5.0 0.5 0)" -b "(gimp-quit 0)"

Obviously, I am doing something wrong, but don't have a clue what it is. Thanks for your help.
Find all posts by this user
Quote this message in a reply
Mar 1, 2012, 12:40 (This post was last modified: Mar 1, 2012 12:40 by ofnuts.)
Post: #2
RE: Batch problem
"C:\.gimp-2.6\scripts" doesn't look like the right place. It's more like "C:\users\{yourid}\.gimp-2.6\scripts" (on Vista/Seven or "C:\Documents and setttings\{yourid}\.gimp-2.6\scripts" (on XP).

Now answering your questions on
https://Gimp-Forum.net
Visit this user's website Find all posts by this user
Quote this message in a reply
Mar 1, 2012, 14:28
Post: #3
RE: Batch problem
That seems to have helped a bit. Now, I get:
script-fu.exe-Warning: Error while loading C:\Users\Tom\.gimp-2.6\scripts\simple-unsharp-mask.scm:

Error: syntax error: illegal token 1

script-fu.exe-Warning: Error while loading C:\Users\Tom\.gimp-2.6\scripts\simple-unsharp-mask.scm:

Error: syntax error: illegal token 1

batch command executed successfully
script-fu.exe-Warning: Error while loading C:\Users\Tom\.gimp-2.6\scripts\simple-unsharp-mask.scm:

Error: syntax error: illegal token 1

Here is the simple-unsharp-mask.scm:

(define (simple-unsharp-mask filename
radius
amount
threshold)
(let* ((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-file-save RUN-NONINTERACTIVE image drawable filename filename)
(gimp-image-delete image)))
)))))
Find all posts by this user
Quote this message in a reply
Mar 1, 2012, 18:11 (This post was last modified: Mar 1, 2012 18:34 by ofnuts.)
Post: #4
RE: Batch problem
Hmm... Way too many parentheses at the end but Lisp s usually quite lenient about it. Another explanation is an end-of-line delimiter problem. or some hidden tab. How did you produce the file? Cut/paste from http://www.gimp.org/tutorials/Basic_Batch/ ?

Now answering your questions on
https://Gimp-Forum.net
Visit this user's website Find all posts by this user
Quote this message in a reply
Mar 1, 2012, 18:54
Post: #5
RE: Batch problem
Thanks for revising your advice. As you suspected, I simply copied an example from the tutorials. By deleting the extra close parens at the end, I got it run run without an error. I don't really understand what it was supposed to do to the image file, but it did update its modified by date in the directory and i don't see anything significantly different about the image now. For now, I'll assume that it's working and move on to a more complicated example.

Thanks again.
Find all posts by this user
Quote this message in a reply
Mar 1, 2012, 19:20
Post: #6
RE: Batch problem
Here's my feeble attempt at changing the threshold on a photo:

(define (simple-threshold-change filename
low-value
high-value)
(let* ((image (car (gimp-file-load RUN-NONINTERACTIVE filename filename)))
(drawable (car (gimp-image-get-active-layer image))))
(gimp-threshold low-value high-value)
(gimp-image-delete image)))

When running the following batch job

"C:\Program Files\GIMP-2.0\bin\gimp-2.6.exe" -i -b "(simple-threshold-change \"foo.png\" 75 255)" -b "(gimp-quit 0)"

I get "batch command experienced an execution error." Is more detail about errors logged in a file somewhere?

Thanks.
Find all posts by this user
Quote this message in a reply
Mar 1, 2012, 20:48
Post: #7
RE: Batch problem
I found the problem(s):
1. I left the drawable parameter out of the gimp-threshold call, and
2. left out the gimp-file-save call.

It now runs without error and gives the desired result.

Now, to expand it for all the images in a directory.

I'm sorry to be a bother.
Find all posts by this user
Quote this message in a reply
Mar 1, 2012, 21:17
Post: #8
RE: Batch problem
A Scheme expert will hopefully chime in (I use Python).

Now answering your questions on
https://Gimp-Forum.net
Visit this user's website Find all posts by this user
Quote this message in a reply
Mar 2, 2012, 06:45
Post: #9
RE: Batch problem
If you need an example script to show processing all the files in a directory, you could have a look at this script I wrote:
http://gimpforums.com/thread-batch-despe...64#pid8937

Kevin
Find all posts by this user
Quote this message in a reply
Mar 4, 2012, 16:02
Post: #10
RE: Batch problem
I now have a new problem. This time it has to do with executing gimp-edit-bucket-fill and (probably) not understanding the parameters required. The following is the batch job that errors out:

"C:\Program Files\GIMP-2.0\bin\gimp-2.6.exe" -i -b "(gimp-edit-bucket-fill \"foo1.png\" 0 0 0.0 128 1 56.0 80.0)" -b "(gimp-quit 1)"

I want the third from the last parameter to be false but am not sure if I should enter 0, 1 or FALSE. Trying each of them one at a time hasn't worked, quite possibly due to some other problem.

Thanks,

Tom
Find all posts by this user
Quote this message in a reply
Mar 5, 2012, 09:07
Post: #11
RE: Batch problem
I'm wondering if Ofnut's reply to your question in this thread: http://gimpforums.com/thread-how-to-plac...d-an-image and using ImageMagic might be the best way to go, but to answer your Gimp question...

The problem isn't with the value for FALSE (0 should work fine), but you have miss-understood what the "drawable" parameter for gimp-edit-bucket-fill is.

Almost all of the gimp- procedures operate on already open images and you tell each procedure what part of that image to operate on using the drawable parameter, which is an ID number. In your example above, you are passing a file-name string not a drawable ID.

If you look at the code for simple-threshold-change that you posted above, you'll see that you pass in the file name string, then load the image file using gimp-file-load which returns an image ID number, then get the drawable ID number to pass to the threshold procedure.

If you want to do the bucket-fill using the same, single-process method you will need to write a script to do the same thing: load the file, get the IDs, call the bucket-fill procedure, and save the image.

Kevin
Find all posts by this user
Quote this message in a reply
Mar 5, 2012, 17:26
Post: #12
RE: Batch problem
My only excuse for being so stupid when I tried that is that I was tired. Doing what you suggested caused my script to run to completion but it changed nothing. I observed foo.png in Windows Explorer while the sctipt ran. The bottom ~5/6 of the image turned black but reverted to as it was in the beginning when the script completed. I am clearly missing something. Here are my procedure script and batch file:

(define (simple-bucket-fill filename
fill-mode
paint-mode
opacity
threshold
sample-merged
x
y)
(let* ((image (car (gimp-file-load RUN-NONINTERACTIVE filename filename)))
(drawable (car (gimp-image-get-active-layer image))))
(gimp-edit-bucket-fill drawable
fill-mode
paint-mode
opacity
threshold
sample-merged
x
y)
(gimp-file-save RUN-NONINTERACTIVE image drawable filename filename)
(gimp-image-delete image)))



"C:\Program Files\GIMP-2.0\bin\gimp-2.6.exe" -i -b "(simple-bucket-fill \"foo.png\" 0 0 0.0 128 0 56.0 80.0)" -b "(gimp-quit 1)"

Thanks,

Tom
Find all posts by this user
Quote this message in a reply
Mar 5, 2012, 17:55
Post: #13
RE: Batch problem
In your command line, you've set the opacity value to 0.0 i.e. fully transparent. Try 100.0 i.e. fully opaque.

Kevin
Find all posts by this user
Quote this message in a reply
Post Reply 


Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  problem with drop shadow Kharl 37 1,228 Oct 8, 2014 04:53
Last Post: Kharl
  Batch adding logo to lots of pictures kenny1999 2 211 Sep 27, 2014 08:02
Last Post: rich2005
  batch processing to obtain several different versions of a picture esteban 3 194 Sep 23, 2014 14:44
Last Post: esteban
  batch processing (OSX) pace514 3 260 Sep 21, 2014 08:03
Last Post: rich2005
  Pattern Fill Problem, Request BeePee 7 488 Jul 25, 2014 18:41
Last Post: rich2005

Forum Jump:


GIMP ForumPortalArchiveContactTermsRSS