Running script-fu-round-corners from gimp command line
This discussion is connected to the gimp-user-list.gnome.org mailing list which is provided by the GIMP developers and not related to gimpusers.com.
This is a read-only list on gimpusers.com so this discussion thread is read-only, too.
Running script-fu-round-corners from gimp command line | Gene Smith | 13 Nov 07:51 |
Running script-fu-round-corners from gimp command line | Sven Neumann | 13 Nov 08:48 |
Running script-fu-round-corners from gimp command line | Gene Smith | 13 Nov 17:40 |
Running script-fu-round-corners from gimp command line | Michael Schumacher | 13 Nov 17:54 |
Running script-fu-round-corners from gimp command line | Gene Smith | 14 Nov 06:36 |
Running script-fu-round-corners from gimp command line | Saul Goode | 14 Nov 07:08 |
Running script-fu-round-corners from gimp command line | Gene Smith | 18 Nov 06:46 |
Running script-fu-round-corners from gimp command line | Saul Goode | 18 Nov 13:24 |
Running script-fu-round-corners from gimp command line | Gene Smith | 20 Nov 04:31 |
Running script-fu-round-corners from gimp command line | Saul Goode | 21 Nov 01:09 |
Running script-fu-round-corners from gimp command line
I have a bunch of jpg's that I need to run the stock procedure for making rounded corners and drop shadows on. I would like to do it from the command line rather than manually, one file at a time with the gui. I think it involves calling something like this, but I can't seem to figure out the right parameter:
gimp -i -d -b '(script-fu-round-corners RUN-NONINTERACTIVE \ "./white-shawl.jpg" -1 15 TRUE 8 8 15 TRUE FALSE)' '(gimp-quit 0)'
The jpg file shown above is just an example of one of many. I am not even sure that the filename goes there since the template calls for IMAGE_ID or image, run_mode and drawable which I am not sure what they mean (I know little about the GIMP). This is from "procedure browser":
(script-fu-round-corners run_mode image drawable value toggle value value value toggle toggle)
thanks, -gene
Running script-fu-round-corners from gimp command line
Hi,
On Mon, 2006-11-13 at 01:51 -0500, Gene Smith wrote:
I have a bunch of jpg's that I need to run the stock procedure for making rounded corners and drop shadows on. I would like to do it from the command line rather than manually, one file at a time with the gui.
Have a look at the Batch tutorial on gimp.org:
http://gimp.org/tutorials/Basic_Batch/
Sven
Running script-fu-round-corners from gimp command line
Sven Neumann wrote:
Hi,
On Mon, 2006-11-13 at 01:51 -0500, Gene Smith wrote:
I have a bunch of jpg's that I need to run the stock procedure for making rounded corners and drop shadows on. I would like to do it from the command line rather than manually, one file at a time with the gui.
Have a look at the Batch tutorial on gimp.org:
http://gimp.org/tutorials/Basic_Batch/
Sven
Thank, I did see that page. But I just want to run an existing "scrip-fu" like this:
gimp -i -d -b '(script-fu-round-corners RUN-NONINTERACTIVE "./white-shawl.jpg" -1 15 TRUE 8 8 15 TRUE FALSE)' '(gimp-quit 0)'
and not sure what to put in for the first 3 parameter of the round-corners script. I think the first one, RUN-NONINTERACTIVE, is right. The next two, image and drawable, I am not sure what to put in (possibly I need to call drawable?). The last 7 I think are OK since they match the gimp dialog box that you run manually. That's really what I am asking.
-gene
Running script-fu-round-corners from gimp command line
Von: Gene Smith
Thank, I did see that page. But I just want to run an existing "scrip-fu" like this:
This is exactly what the tutorials is about.
gimp -i -d -b '(script-fu-round-corners RUN-NONINTERACTIVE "./white-shawl.jpg" -1 15 TRUE 8 8 15 TRUE FALSE)' '(gimp-quit 0)'
and not sure what to put in for the first 3 parameter of the round-corners script. I think the first one, RUN-NONINTERACTIVE, is right. The next two, image and drawable, I am not sure what to put in (possibly I need to call drawable?).
You have to put the call to the script at the right place - this is where the "(plug-in-unsharp-mask RUN-NONINTERACTIVE image drawable radius amount threshold)" is called in the example.
HTH, Michael
Running script-fu-round-corners from gimp command line
Michael Schumacher wrote, On 11/13/2006 11:54 AM:
Von: Gene Smith
Thank, I did see that page. But I just want to run an existing "scrip-fu" like this:
This is exactly what the tutorials is about.
gimp -i -d -b '(script-fu-round-corners RUN-NONINTERACTIVE "./white-shawl.jpg" -1 15 TRUE 8 8 15 TRUE FALSE)' '(gimp-quit 0)'
and not sure what to put in for the first 3 parameter of the round-corners script. I think the first one, RUN-NONINTERACTIVE, is right. The next two, image and drawable, I am not sure what to put in (possibly I need to call drawable?).
You have to put the call to the script at the right place - this is where the "(plug-in-unsharp-mask RUN-NONINTERACTIVE image drawable radius amount threshold)" is called in the example.
HTH, Michael
I made this script from the example and put in ~/.gimp-2.2/scripts/round-corners.scm:
(define (round-corners filename)
(let* ((image (car (gimp-file-load RUN-NONINTERACTIVE filename
filename)))
(drawable (car (gimp-image-get-active-layer image))))
(script-fu-round-corners RUN-NONINTERACTIVE
image drawable 15 TRUE 8 8 15 TRUE FALSE)
(set! drawable (car (gimp-image-get-active-layer image)))
(gimp-file-save RUN-NONINTERACTIVE image drawable filename filename)
(gimp-image-delete image)))
and run it for a image file:
gimp -i -b '(round-corners "/home/gene/product_images/white-shawl.png")' '(gimp-quit 0)'
No batch interpreter specified, using the default 'plug_in_script_fu_eval'. batch command: experienced an execution error.
--verbose doesn't say more.
When I run in Script-Fu Console:
=> (round-corners "/home/gene/product_images/white-shawl.jpg") ERROR: Procedural database execution failed: (gimp_image_width 1)
I still must be doing something wrong.
-gene
Running script-fu-round-corners from gimp command line
I think it is just a matter of you having to flatten the image before calling 'script-fu-round-corners' (which does not accept images with an alpha channel).
Von: Gene Smith
I made this script from the example and put in ~/.gimp-2.2/scripts/round-corners.scm:
(define (round-corners filename) (let* ((image (car (gimp-file-load RUN-NONINTERACTIVE filename filename)))
(drawable (car (gimp-image-get-active-layer image)))) (script-fu-round-corners RUN-NONINTERACTIVE image drawable 15 TRUE 8 8 15 TRUE FALSE) (set! drawable (car (gimp-image-get-active-layer image))) (gimp-file-save RUN-NONINTERACTIVE image drawable filename filename) (gimp-image-delete image)))and run it for a image file:
gimp -i -b '(round-corners "/home/gene/product_images/white-shawl.png")' '(gimp-quit 0)'
No batch interpreter specified, using the default
'plug_in_script_fu_eval'.
batch command: experienced an execution error.
--verbose doesn't say more.
When I run in Script-Fu Console:
=> (round-corners "/home/gene/product_images/white-shawl.jpg") ERROR: Procedural database execution failed: (gimp_image_width 1)
I still must be doing something wrong.
--------
"It is amazing what you can accomplish if you do
not care who gets the credit." -- Harry S. Truman
Running script-fu-round-corners from gimp command line
Saul Goode wrote, On 11/14/2006 01:08 AM:
I think it is just a matter of you having to flatten the image before calling 'script-fu-round-corners' (which does not accept images with an alpha channel).
Von: Gene Smith
I made this script from the example and put in ~/.gimp-2.2/scripts/round-corners.scm:
(define (round-corners filename) (let* ((image (car (gimp-file-load RUN-NONINTERACTIVE filename filename)))
(drawable (car (gimp-image-get-active-layer image)))) (script-fu-round-corners RUN-NONINTERACTIVE image drawable 15 TRUE 8 8 15 TRUE FALSE) (set! drawable (car (gimp-image-get-active-layer image))) (gimp-file-save RUN-NONINTERACTIVE image drawable filename filename) (gimp-image-delete image)))and run it for a image file:
gimp -i -b '(round-corners "/home/gene/product_images/white-shawl.png")' '(gimp-quit 0)'
No batch interpreter specified, using the default
'plug_in_script_fu_eval'.
batch command: experienced an execution error.
How do I put the call to gimp_image_flatten() in my script. Everything I try still gives the "experience an exec error" message. Last thing tried:
(define (round-corners filename)
(let* ((image (car (gimp-file-load RUN-NONINTERACTIVE filename
filename)))
(drawable (car (gimp-image-get-active-layer image))))
(image (gimp_image_flatten(image)))
(script-fu-round-corners RUN-NONINTERACTIVE
image drawable 15 TRUE 8 8 15 TRUE FALSE)
(set! drawable (car (gimp-image-get-active-layer image)))
(gimp-file-save RUN-NONINTERACTIVE image drawable filename filename)
(gimp-image-delete image)))
Running script-fu-round-corners from gimp command line
Von: Gene Smith
How do I put the call to gimp_image_flatten() in my script. Everything I try still gives the "experience an exec error" message. Last thing tried:
(define (round-corners filename) (let* ((image (car (gimp-file-load RUN-NONINTERACTIVE filename filename)))
(drawable (car (gimp-image-get-active-layer image)))) (image (gimp_image_flatten(image))) (script-fu-round-corners RUN-NONINTERACTIVE image drawable 15 TRUE 8 8 15 TRUE FALSE) (set! drawable (car (gimp-image-get-active-layer image))) (gimp-file-save RUN-NONINTERACTIVE image drawable filename filename) (gimp-image-delete image)))
"(gimp_image_flatten(image))" is incorrect for a couple of reasons.
First, Script-fu never uses underscores (except for marking strings for foreign language translation) and these need to be converted to dashes; therefore the function becomes "gimp-image-flatten".
Second, 'image' should not be within parentheses.
Third, after you perform the flatten, the variable 'drawable' is no longer valid (flatten creates a new layer). You need to assign the active layer to 'drawable' AFTER you perform the flatten.
-------- "It is amazing what you can accomplish if you do not care who gets the credit." -- Harry S. Truman
Running script-fu-round-corners from gimp command line
Saul Goode wrote, On 11/18/2006 07:24 AM:
"(gimp_image_flatten(image))" is incorrect for a couple of reasons.
First, Script-fu never uses underscores (except for marking strings for foreign language translation) and these need to be converted to dashes; therefore the function becomes "gimp-image-flatten".
Second, 'image' should not be within parentheses.
Third, after you perform the flatten, the variable 'drawable' is no longer valid (flatten creates a new layer). You need to assign the active layer to 'drawable' AFTER you perform the flatten.
It was pretty much a stab in the dark. Thanks for the pointers.
I have come up with some scripts that work but sure they are not optimum, but think I am getting closer to my goal.
The first one converts a singe file.jpg to file.xcf where the default parameters for script-fu-round-corners are applied:
(define (round-corners in-filename out-filename)
(let* ((image (car (gimp-file-load RUN-NONINTERACTIVE in-filename
in-filename)))
(drawable (car (gimp-image-get-active-layer image))))
(script-fu-round-corners image drawable 15 TRUE 8 8 15 TRUE FALSE)
(gimp-file-save RUN-NONINTERACTIVE image drawable out-filename
out-filename)
(gimp-image-delete image)))
Note: A call to flatten does not seem to be required when the input is jpg.
Example call: $ gimp -i -b '(round-corners "white-shawl.jpg" "wwww.xcf")' '(gimp-quit 0)'
The next script is based on your script http://flashingtwelve.brickfilms.com/GIMP/Scripts/batch-xcf2jpg.scm that converts a glob of *.xcf to *.jpg. What I want is to run a glob of *.jpg through script-fu-round-corners and save as *-new.jpg. The only way I could get this to work was to save the output of script-fu-round-corners as xcf then essentially apply your script to the xcf files to get jpg files like this:
(define (round-corners-batch pattern)
(let* (
(filelist (cadr (file-glob pattern 1)))
(xcfname)
(jpgname)
(filename)
(image)
(drawable)
)
(while filelist
(set! filename (car filelist))
(set! image (car (gimp-file-load RUN-NONINTERACTIVE filename
filename)))
(set! xcfname (strbreakup filename "."))
(set! xcfname (unbreakupstr (butlast xcfname ".")))
(set! xcfname (string-append xcfname ".xcf"))
(set! drawable (car (gimp-image-get-active-layer image)))
(script-fu-round-corners image drawable 15 TRUE 8 8 15 TRUE FALSE)
(gimp-file-save RUN-NONINTERACTIVE image drawable xcfname xcfname)
(set! image (car (gimp-file-load RUN-NONINTERACTIVE xcfname
xcfname)))
(set! jpgname (strbreakup xcfname "."))
(set! jpgname (unbreakupstr (butlast jpgname ".")))
(set! jpgname (string-append jpgname "-new"))
(set! jpgname (string-append jpgname ".jpg"))
(set! drawable (car (gimp-image-flatten image)))
(gimp-file-save RUN-NONINTERACTIVE image drawable jpgname jpgname)
(gimp-image-delete image)
(set! filelist (cdr filelist))
)
)
)
Example call:
$ gimp -i -b '(round-corners-batch "w*.jpg")' '(gimp-quit 0)'
which produces new files w*.xcf and w*-new.jpg. What I don't understand about this is what parameters, such as quality, are applied to this jpg conversion? I do notice that the *-new.jpg files are a few K larger than then original *.jpg files. Also, does it know to save as jpg just because the file extension is jpg? If I want other than default jpg setting I might need to call something like gimp-file-save-jpg with about 10 parameters? Possibly this might also eliminate the need for the intermediate save to xcf?
-gene
Running script-fu-round-corners from gimp command line
Gene Smith wrote
The next script is based on your script http://flashingtwelve.brickfilms.com/GIMP/Scripts/batch-xcf2jpg.scm that converts a glob of *.xcf to *.jpg. What I want is to run a glob of *.jpg through script-fu-round-corners and save as *-new.jpg. The only way I could get this to work was to save the output of script-fu-round-corners as xcf then essentially apply your script to the xcf files to get jpg files like this:
*snipped*
What I don't understand about this is what parameters, such as quality, are applied to this jpg conversion? I do notice that the *-new.jpg files are a few K larger than then original *.jpg files. Also, does it know to save as jpg just because the file extension is jpg? If I want other than default jpg setting I might need to call something like gimp-file-save-jpg with about 10 parameters? Possibly this might also eliminate the need for the intermediate save to xcf?
There is a PDB function called 'file-jpeg-save' which will permit you to specify different parameters. Open the PDB Browser ("Xtns->Procedure Browser") and type "jpeg" in as the Search key for a description of the function.
It seems like you have things pretty well in hand. I think it is unnecessary to save the xcf file and then reload it though. You should be able to delete those two lines and obtain the same result.
-------- "It is amazing what you can accomplish if you do not care who gets the credit." -- Harry S. Truman