GIMP Forums

Full Version: A script fu (rounded corners) from the command line...
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello there!
I've made a script in order to round the corners of my images with one click.
Maybe it wasn't necessary, because I could use script-fu-round-corners in the command line, but that's what I've tried, stupid or not:
(define (script-fu-rounded-corners image drawable)
  (let* ()
    (script-fu-round-corners image drawable 10 FALSE 8 8 15 FALSE FALSE)
    (gimp-file-save RUN-NONINTERACTIVE image drawable "/home/alex/Desktop/1.png" "/home/alex/Desktop/1.png")

(script-fu-register "script-fu-rounded-corners"
                    "Round Corners"
                    "Script by Alex"
                    "Copyright (C) 2012 Alex"
                    "Version 0.1"
                    SF-IMAGE "Input Image" 0
                    SF-DRAWABLE "Input Drawable" 0

(script-fu-menu-register "script-fu-rounded-corners" "<Image>/Alex")
And I've run it like this from the command line:
gimp -i -b '(script-fu-rounded-corners "2.png"' -b '(gimp-quit 0)'

And here are the 3 major problems:

a) If I open an image in gimp and run the script from inside gimp, then the image /home/alex/Desktop/1.png is created successfully and everything is fine. When I run the above command from the command line, it exits without errors but nothing happens to the image.

b) As 4th and 5th argument in gimp-file-save I've hardcored the path of the image, but I'd like to overwrite automatically the specified image, I've tried instead of hardcoring the path to put the variable 'image', but it isn't of type 'STRING', and this type of variable is needed there. No clues.

c) It feels like that this could be done without the use of the custom script-fu called 'script-fu-rounded-corners' I made. It could probably be a one-liner in gimp, where 'script-fu-round-corners' is being called.

Thanks in advance for any help!
Your problem with running it from the command line is that you have miss-understood what the "image" and "drawable" parameters are.

They are internal id NUMBERS, not strings, so you can't run your script from the command line as it stands because you don't know what the numbers are going to be.

You would need to supply the filename as a string, then use something like:
(set! (image (car (gimp-file-load RUN-NONINTERACTIVE filename filename))))  ; load the image

Have a look at the batch script I wrote for someone else, which should give you an idea how this works:

You should be able to take that example and make it use 'script-fu-round-corners' instead of 'plug-in-despeckle' - changing the parameters accordingly of course.

Thanks a lot Smile
After a bit of searching in your code I managed to make it work.
This is the final code:
(define (round_the_corners filename)
        (let* (
               (image (car (gimp-file-load RUN-NONINTERACTIVE filename filename)))
               (drawable (car (gimp-image-flatten image)))

              (script-fu-round-corners image drawable 10 FALSE 8 8 15 FALSE FALSE)
              (gimp-file-save RUN-NONINTERACTIVE image drawable filename filename)
              (gimp-image-delete image)
I saved it as ~/.gimp-2.8/scripts/round_the_corners.scm
and i run it through a terminal as:
gimp -i -f -d -b '(round_the_corners "1.png")' -b "(gimp-quit 0)"
Hi hakermania and all
I tried above example but it doesnt seem to work on my linux system.
I tried gimp -i -f -d -b --verbose '(round_the_corners "toby.jpg")' -b "(gimp-quit 0)"
and I got no of gimp errors

INIT: gimp_load_config
Parsing '/home/web-dev/.gimp-2.6/unitrc'
Parsing '/etc/gimp/2.0/gimprc'
Parsing '/home/web-dev/.gimp-2.6/gimprc'
gimp_composite: use=yes, verbose=no
Processor instruction sets: +mmx +sse +sse2 -3dnow -altivec -vis
INIT: gimp_initialize
INIT: gimp_real_initialize
INIT: gimp_restore
Parsing '/home/web-dev/.gimp-2.6/parasiterc'
Parsing '/home/web-dev/.gimp-2.6/templaterc'
INIT: gimp_real_restore
Parsing '/home/web-dev/.gimp-2.6/pluginrc'
Querying plug-in: '/usr/lib/gimp/2.0/plug-ins/file-uri'

(file-uri:24278): Gtk-WARNING **: cannot open display:

(gimp:24274): LibGimpBase-WARNING **: gimp: gimp_wire_read(): error
Terminating plug-in: '/usr/lib/gimp/2.0/plug-ins/file-uri'
Writing '/home/web-dev/.gimp-2.6/pluginrc'
Starting extension: 'extension-script-fu'
GIMP-Error: Opening '/var/www/socialapps/macgregor/facebook/spiderman_comic/test_delete/(round_the_corners "toby.jpg")' failed: No such file or directory

No batch interpreter specified, using the default 'plug-in-script-fu-eval'.
batch command experienced an execution error
EXIT: gimp_exit
EXIT: gimp_real_exit
Terminating plug-in: '/usr/lib/gimp/2.0/plug-ins/script-fu'
Terminating plug-in: '/usr/lib/gimp/2.0/plug-ins/script-fu'
Writing '/home/web-dev/.gimp-2.6/templaterc'
Writing '/home/web-dev/.gimp-2.6/parasiterc'
Writing '/home/web-dev/.gimp-2.6/unitrc'
EXIT: batch_exit_after_callback

I appreciate if you guyz plz help me out with this.
Your command line is wrong. The -b argument MUST have the script-command immediately after it NOT the -verbose argument (which is also wrong as it should be 2 dashes, see ).

gimp -i -f -d ---verbose -b '(round_the_corners "toby.jpg")' -b "(gimp-quit 0)"

Reference URL's