Post Reply 

A script fu (rounded corners) from the command line...

May 4, 2012, 21:07
Post: #1
A script fu (rounded corners) from the command line...
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:
Code:
(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"
                    "Alex"
                    "Version 0.1"
                    "RGB*"
                    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:
Code:
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!
Find all posts by this user
Quote this message in a reply
May 5, 2012, 07:17
Post: #2
RE: A script fu (rounded corners) from the command line...
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:
Code:
(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: http://gimpforums.com/thread-batch-despe...37#pid8937

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.

Kevin
Visit this user's website Find all posts by this user
Quote this message in a reply
May 5, 2012, 11:46
Post: #3
RE: A script fu (rounded corners) from the command line...
Thanks a lot Smile
After a bit of searching in your code I managed to make it work.
This is the final code:
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:
Code:
gimp -i -f -d -b '(round_the_corners "1.png")' -b "(gimp-quit 0)"
Find all posts by this user
Quote this message in a reply
Oct 11, 2012, 08:32
Post: #4
RE: A script fu (rounded corners) from the command line...
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.
Find all posts by this user
Quote this message in a reply
Oct 11, 2012, 09:41 (This post was last modified: Oct 11, 2012 09:42 by paynekj.)
Post: #5
RE: A script fu (rounded corners) from the command line...
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 http://www.gimp.org/tutorials/Basic_Batch/ ).

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

Kevin
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  How do you make a line and shape on Gimp? hibi 3 142 Jul 5, 2014 15:19
Last Post: hibi
  line art layer selection arnisd 1 125 Jun 8, 2014 21:06
Last Post: ofnuts
  How to draw a straight line with the GIMP. sepoto 14 1,608 May 31, 2014 07:12
Last Post: iForStyle007
  Cleaning up a low rez [coloring book] line drawing. nyxythepixy 2 347 Apr 12, 2014 22:24
Last Post: nyxythepixy
  Color replacement from the command line blue1 1 178 Feb 17, 2014 23:58
Last Post: ofnuts

Forum Jump:


GIMP ForumPortalArchiveContactTermsRSS