Page 1 of 1
Batch mode from XP - escape sequences?
#1
Posted 13 April 2006 - 11:46 AM
I have a script to scale, sharpen and resave all files in a specified directory to a new directory, but I can't seem to figure out the escape sequences I need to get the parameters passed into gimp properly.
When I run my script from the script-fu console it works, but running the same command from the command line doesn't. I've tried every escape sequence I can think of and I'm at a loss what to try next.
Here is the command line with the parameters as they worked from the script-fu console:
gimp-2.2.exe -i -b '(batch_scale_up_and_sharpen "c:\\imgs\\" "*.gif" "c:\\img\\" 1.25 .50 .50 5)' '(gimp-quit 0)'
Any hints would be greately appreciated. I don't have much hair left! :)
Thanks!
When I run my script from the script-fu console it works, but running the same command from the command line doesn't. I've tried every escape sequence I can think of and I'm at a loss what to try next.
Here is the command line with the parameters as they worked from the script-fu console:
gimp-2.2.exe -i -b '(batch_scale_up_and_sharpen "c:\\imgs\\" "*.gif" "c:\\img\\" 1.25 .50 .50 5)' '(gimp-quit 0)'
Any hints would be greately appreciated. I don't have much hair left! :)
Thanks!
#2
Posted 13 April 2006 - 12:48 PM
HINT: Change underscores to dashes.
Everybody makes their own fun. If you don't make it yourself it's not fun, it's entertainment.
#3
Posted 13 April 2006 - 12:57 PM
No bueno :s:
gimp-2.2.exe -i -b '(batch-scale-up-and-sharpen "c:\\imgs\\" "*.gif" "c:\\img\\" 1.25 .50 .50 5)' '(gimp-quit 0)'
does the same thing (I altered the script from underscores to dashes. I originally used dashes, but somewhere in my research I read that underscores were required for batch. Must have been a previous version).
One thing I noticed too is that even with the gimp-quit command, gimp stays loaded in memory and new instance is started everytime I run the command.
gimp-2.2.exe -i -b '(batch-scale-up-and-sharpen "c:\\imgs\\" "*.gif" "c:\\img\\" 1.25 .50 .50 5)' '(gimp-quit 0)'
does the same thing (I altered the script from underscores to dashes. I originally used dashes, but somewhere in my research I read that underscores were required for batch. Must have been a previous version).
One thing I noticed too is that even with the gimp-quit command, gimp stays loaded in memory and new instance is started everytime I run the command.
#4
Posted 13 April 2006 - 02:31 PM
It was worth a try. :l:
I think underscores are entirely a thing of the past; although I am not sure about Windows. Would you consider posting your script so that we can check for any obscure "gotchas" (or at least provide some ideas on how to test it)?
I think underscores are entirely a thing of the past; although I am not sure about Windows. Would you consider posting your script so that we can check for any obscure "gotchas" (or at least provide some ideas on how to test it)?
Everybody makes their own fun. If you don't make it yourself it's not fun, it's entertainment.
#5
Posted 13 April 2006 - 03:43 PM
Gladly!
What gets my goat is that it works from within gimp and from the script-fu console, just can't get it from outside gimp.
What gets my goat is that it works from within gimp and from the script-fu console, just can't get it from outside gimp.
(define (batch-scale-up-and-sharpen
foldername
pattern
newfolder
scalemultiplier
radius
amount
threshold
)
(set! filepattern (string-append foldername pattern))
(let*
(
(filelist (cadr (file-glob filepattern 1)))
)
(while filelist
(let*
(
(filename (car filelist))
(image (car (gimp-file-load 1 filename filename)))
(drawable (car (gimp-image-get-active-layer image)))
(oldwidth (car (gimp-image-width image)))
(oldheight (car (gimp-image-height image)))
(newwidth (* oldwidth scalemultiplier))
(newheight (* oldheight scalemultiplier))
(newfilename (string-append
newfolder
(car (reverse (strbreakup filename "\\")))
)
)
)
(gimp-image-convert-rgb image)
(gimp-image-scale image newwidth newheight)
(plug-in-unsharp-mask 1 image drawable radius amount threshold)
(gimp-image-convert-indexed image 0 0 256 0 0 "")
(gimp-file-save 1 image drawable newfilename newfilename)
)
(set! filelist (cdr filelist))
)
)
)
(script-fu-register
"batch-scale-up-and-sharpen"
"/Xtns/Script-Fu/Batch/Scale Up or Down"
"Scales up images by a multipler, sharpens, and saves file with file prefix."
"Sean Hamilton"
""
"April 8, 2006"
"Notes: End directories with backslashes. \n Destination folder must already exist. \n Currently
geared towards .gif files."
SF-STRING "Source Folder (c:\\folder\\):" ""
SF-STRING "Wildcard (*.gif):" ""
SF-STRING "Destination Folder (c:\\new\\):" ""
SF-VALUE "Scale Multiplier:" "1.25"
SF-VALUE "Radius:" ".50"
SF-VALUE "Sharpen Amount:" ".50"
SF-VALUE "Threshold:" "5"
)
#6
Posted 13 April 2006 - 06:42 PM
I think that the problem might have to do with how the backslash gets handled by the Windows command prompt. If you could put the following code into your GIMP script directory and run the the command line
[*] gimp -f -i -b '(test-glob "C:\some folder\another folder\*.gif")' '(gimp-quit 0)'
I would be interested in the output. The code tries to separate the folders using both slashes and backslashes. Only one will work (the GIMP's native operating system uses slashes, Windows uses backslashes). I am thinking that the Script-fu console might be converting them but the command line isn't; or versa-vice.
[*] gimp -f -i -b '(test-glob "C:\some folder\another folder\*.gif")' '(gimp-quit 0)'
I would be interested in the output. The code tries to separate the folders using both slashes and backslashes. Only one will work (the GIMP's native operating system uses slashes, Windows uses backslashes). I am thinking that the Script-fu console might be converting them but the command line isn't; or versa-vice.
(define (test-glob pattern)
(let* (
(filelist (cadr (file-glob pattern 1)))
(cnt 1)
)
(gimp-message-set-handler 2)
(gimp-message (string-append "First file: " (car filelist)))
(while filelist
(let* (
(filename (car filelist))
(folders)
)
(gimp-message (string-append "File #" (number->string cnt) ": " filename))
(gimp-message "Trying slash...")
(set! folders (strbreakup filename "/"))
(gimp-message (unbreakupstr folders ".."))
(gimp-message "Trying backslash ...")
(set! folders (strbreakup filename "\\"))
(gimp-message (unbreakupstr folders ".."))
(set! cnt (+ 1 cnt))
(set! filelist (cdr filelist))
)
)
)
)
Everybody makes their own fun. If you don't make it yourself it's not fun, it's entertainment.
#7
Posted 19 April 2006 - 03:25 PM
Sorry it took so long to get back to this.
If i create a script-fu interface for it, this works, and parses out the directory and the files within it just fine, and I see the results in the error console.
I can't get it to work from the script-fu console, it gives me a closure error.
Running it from the command line, I don't see any output at all, even if I turn the interface back on.
I wonder if I have something wrong with my gIMP install as running gimp-2.2.exe -help at the command line does nothing either (no output).
If i create a script-fu interface for it, this works, and parses out the directory and the files within it just fine, and I see the results in the error console.
I can't get it to work from the script-fu console, it gives me a closure error.
Running it from the command line, I don't see any output at all, even if I turn the interface back on.
I wonder if I have something wrong with my gIMP install as running gimp-2.2.exe -help at the command line does nothing either (no output).
#9
Posted 19 April 2006 - 06:29 PM
Quote
I can't get it to work from the script-fu console, it gives me a closure error.
The "closure" is not an error, it is a message saying that the function was defined successfully. The function is not automatically executed, you have to call it after it has been defined.
[*] (test-glob "*")
from the GIMP's Script-fu console should open a message window and start listing filenames to it.
Everybody makes their own fun. If you don't make it yourself it's not fun, it's entertainment.
#10
Posted 19 April 2006 - 08:17 PM
Learn something new every day...
=> (test-glob "c:\img\test\*.gif")
ERROR: not a symbol or string
But
=> (test-glob "c:\\img\\test\\*.gif")
()
Kicks off and lists the files.
From the command line:
C:\Program Files\GIMP-2.0\bin>gimp -f -b '(test-glob "c:\\img\\test\\*.gif")''(gimp-quit 0)'
The interface opens, but the errors window doesn't. is there anyway to log the results to a file? or.. hmm... i can probably open an image and log the results into a text object and save it. Kinda back'wards. But it could be good exercise. I'll try that tonite or in the morning as work permits.
Thanks for your time and patience, saulgoode!
=> (test-glob "c:\img\test\*.gif")
ERROR: not a symbol or string
But
=> (test-glob "c:\\img\\test\\*.gif")
()
Kicks off and lists the files.
From the command line:
C:\Program Files\GIMP-2.0\bin>gimp -f -b '(test-glob "c:\\img\\test\\*.gif")''(gimp-quit 0)'
The interface opens, but the errors window doesn't. is there anyway to log the results to a file? or.. hmm... i can probably open an image and log the results into a text object and save it. Kinda back'wards. But it could be good exercise. I'll try that tonite or in the morning as work permits.
Thanks for your time and patience, saulgoode!
#11
Posted 19 April 2006 - 09:57 PM
From the command line, try:
C:\Program Files\GIMP-2.0\bin>gimp -f -i -b '(test-glob "c:\img\test\*.gif")' '(gimp-quit 0)'
The problem (I think) is still the backslash. Script-fu uses it to create non-printing characters: for example "\t" is a TAB and "\n" is a NEWLINE. In order to print a backslash, you have to follow it by another ("\\"); this is interpreted as a single backslash. This is also true in the Script-fu console, which is why "(test-glob "c:\\img\\test\\*.gif")" worked but the one before it didn't.
The Windows command line is basically the opposite: slashes have to be doubled and backslashes do not. (This is based on my DOS experience, so you might want to keep a saltlick handy). There is also the difference in directories: Windows uses "\dir\subdir\" while the rest of the galaxy uses "/dir/subdir/". Script-fu is setup to convert these back and forth when run from the Script-fu console but I do not know what takes place in parameters passed from the DOS command prompt. That is the reason for all this difficulty and for the "test-glob" program; to find out what Windows passes to Script-fu from the command line.
C:\Program Files\GIMP-2.0\bin>gimp -f -i -b '(test-glob "c:\img\test\*.gif")' '(gimp-quit 0)'
The problem (I think) is still the backslash. Script-fu uses it to create non-printing characters: for example "\t" is a TAB and "\n" is a NEWLINE. In order to print a backslash, you have to follow it by another ("\\"); this is interpreted as a single backslash. This is also true in the Script-fu console, which is why "(test-glob "c:\\img\\test\\*.gif")" worked but the one before it didn't.
The Windows command line is basically the opposite: slashes have to be doubled and backslashes do not. (This is based on my DOS experience, so you might want to keep a saltlick handy). There is also the difference in directories: Windows uses "\dir\subdir\" while the rest of the galaxy uses "/dir/subdir/". Script-fu is setup to convert these back and forth when run from the Script-fu console but I do not know what takes place in parameters passed from the DOS command prompt. That is the reason for all this difficulty and for the "test-glob" program; to find out what Windows passes to Script-fu from the command line.
Everybody makes their own fun. If you don't make it yourself it's not fun, it's entertainment.
#12
Posted 20 April 2006 - 03:25 PM
Okay, I think this is a problem with the Win32 command line just sucking in general.
I downloaded Msys which is supposed to give me 'nix style interface under Windows and I'm have more success... at least I get can "Hello World" to run, whereas on the native command line under Windows I can't.
Link to it, if anyone else needs it.
http://www.mingw.org/
I downloaded Msys which is supposed to give me 'nix style interface under Windows and I'm have more success... at least I get can "Hello World" to run, whereas on the native command line under Windows I can't.
Link to it, if anyone else needs it.
http://www.mingw.org/
Share this topic:
Page 1 of 1

Help










