Post Reply 

Script Fu to scale and round corners?

Jan 10, 2012, 19:37
Post: #1
Script Fu to scale and round corners?
I'm looking to use script-fu to automate a process I do at work.

What I do is find images, paste them into GIMP, scale them down, and round the corners.

I've been playing around with script fu to make it automatically scale the image and round the corners, but I've run into problems with the image variable needing to be changed each time something is pasted.

Is there a way I can automate this, perhaps some code that will set the image variable to whatever the current window is, or am I stuck doing "manual labor"?
Find all posts by this user
Quote this message in a reply
Jan 10, 2012, 20:47
Post: #2
RE: Script Fu to scale and round corners?
I need to make a pizza icon. So I google "pizza" and find an image that looks like it will scale well. I then "Copy Image" from the web and paste into GIMP. What I would then do is scale it, then apply rounded corners. While not too tedious, I'd like it if I could do both with the push of 1 button, as the scale size and rounded corner parameters never change.

What I've made thus far is this little script. The problem is X, which is the image variable. When I put it to 1, it works well the first time. However, after saving an image and closing the active window, then pasting a new image into GIMP, the image ID (?) now becomes 2. This means for me in my script that I have to change the x from 1 to 2. Is there a way I can tell script-fu to look at the image ID of whatever image is currently open?... Does that make more sense?

Here's my little...line of script-fu:
(gimp-image-scale x 104 91)(script-fu-round-corners TRUE x 10 10 FALSE 8 8 15 FALSE FALSE)
Find all posts by this user
Quote this message in a reply
Jan 10, 2012, 21:30 (This post was last modified: Jan 10, 2012 21:38 by Mookler.)
Post: #3
RE: Script Fu to scale and round corners?
(Jan 10, 2012 21:19)paynekj Wrote:  Are you typing your "script" into the script-fu console? rather than creating a script file and calling it from a menu?

Here's what I would do - save this code into a file - say mookler.scm in your personal script folder (see Edit>>Preferences>>Folders>>Scripts for your script folders)
(define (script-fu-mookler image drawable)
  (let* ()
    (gimp-image-scale image 104 91)
    (script-fu-round-corners image drawable 10 FALSE 8 8 15 FALSE FALSE)

(script-fu-register "script-fu-mookler"
                    "Mookler's Script"
                    "Script by Mookler"
                    "Copyright (C) 2011 Mookler"
                    "Version 0.1"
                    SF-IMAGE "Input Image" 0
                    SF-DRAWABLE "Input Drawable" 0

(script-fu-menu-register "script-fu-mookler" "<Image>/Mookler")

Then either re-start GIMP or select Filters>>Script-Fu>>Refresh Scripts

You should then have a "Mookler>>Mookler's Script menu entry

This is going to sound dumb, probably because I have no coding experience, but what I had done in the past was just take that short line I provided and saved it into a .scm. You're script that you provided does exactly what I want it to do...thanks a hundred times over!
Find all posts by this user
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Run script on action rchav 2 1,328 Aug 13, 2018 14:57
Last Post: rchav
  Script Fu Errors Gimp 2.10.4 lightsaber jd3481 1 882 Aug 2, 2018 05:13
Last Post: paynekj
  Script-fu script to conversion pdf to image 4ever 12 14,774 Jul 17, 2018 16:01
Last Post: paynekj
  Problems with a bat script :( ThaUnknown_ 1 672 Mar 26, 2018 21:14
Last Post: paynekj
  Script-fu ordered file list vnicent 1 500 Mar 19, 2018 17:33
Last Post: paynekj

Forum Jump:

GIMP ForumPortalArchiveContactTermsRSS