You are here

Double border

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
Rate this item!
AttachmentSize
double-border.scm5.54 KB

Creates two borders around the outside of your image with a shadow layer in between.

Code License: 
GIMP Version: 
Scripting Engine: 

Comments

Thanks for a very useful tool. It works very well.

hello

i found this script quite useful and tried to tweak it to add batch processing capability and therefore tried to introduce gimp-file-load and gimp-file-save commands to the script while keeping files in predefined location, ("F:\my.jpg" here) so that if this be success then i can make amendments to that script as shown in this tutorial

http://www.gimp.org/tutorials/Basic_Batch/

first i came across an error message regarding group undo function. so i removed it by making those lines comments and after that my modified script runs perfectly but still no output was provided (no change was made at all to original image) but yet i can see new layers are build as shadow, inner etc, in layers panel.

 later i added

(set! drawable (car (gimp-image-get-active-layer theImage)))

line to script to see what happens as mentioned in the tutorial in above link, it produced shadow layer as the output and not the processed image as its supposed to do :( since it wasnt a success i substituted above line with

(set! drawable (car (gimp-image-flatten theImage)))

it now flattens the set of layers but without the image and the shadow with inner and outer borders together are produced as the output file (gets saved to above location) but no original image.

 i cannot figure out any flaw in code either and is extremely confused any help in this matter would be highly appreciated.  given below is the code with my modifications

thank you

============================== 

; Last changed: 7 August 2007

; Copyright (C) 2007 Harry Phillips <script-fu@tux.com.au>

; --------------------------------------------------------------------

(define (layer-add-fill width

height

label

opacity

colour

image)

 

(let* ((newLayer (car (gimp-layer-new image width height 1 label opacity 0))))

;Set the background colour

(gimp-context-set-background colour)

 

;Add the layer

(gimp-image-add-layer image newLayer 100)

 

;Fill the shadow layer

(gimp-drawable-fill newLayer 1)

newLayer))

 

;let is closed and define is closed

;following define if begin and let again closes at the end at registration

; in below define theImage is a parameter

 

(define (script-fu-dil-batch theImage

theLayer

innerColour

innerSize

outerColour

outerSize

shadowColour

shadowSize

shadowBlur

shadowOpacity

shadowInclude)

 

    ;Check that the outer size is larger than the required sie for the shadow

    (if (< outerSize (+ shadowSize shadowBlur))

;Outer size is too small

(gimp-message "Outer size needs to larger than shadow size plus shadow blur")

;Outer size is large enough

(begin

 

 

    ;Start an undo group so the process can be undone with one undo

   ;temp (gimp-image-undo-group-start theImage)

;add

 

;add

    (let* 

    (

;initialise variables

(theImage (car (gimp-file-load RUN-NONINTERACTIVE "F:\my.jpg" "F:\my.jpg")))

(drawable (car (gimp-image-get-active-layer theImage)))

;Read the current colours

(myForeground (car (gimp-context-get-foreground)))

(myBackground (car (gimp-context-get-background)))

 

;Read the image width and height

(imageWidth (car (gimp-image-width theImage)))

(imageHeight (car (gimp-image-height theImage)))

 

;Calculate the size of the inner layer

(innerWidth (+ imageWidth (* innerSize 2)))

(innerHeight (+ imageHeight (* innerSize 2)))

 

(shadBlur (+ shadowSize shadowBlur)) 

(innerLayer)

(outerLayer)

(shadowLayer)

 

(outerWidth (+ innerWidth (* outerSize 2)))

(outerHeight (+ innerHeight (* outerSize 2)))

(outerTemp)

 

 

    )

 

    ;Select none

    (gimp-selection-none theImage)

 

    ;Resize image

    (gimp-image-resize theImage innerWidth innerHeight innerSize innerSize)

 

 

    ;Add the inner layer to the image

    (set! innerLayer (layer-add-fill innerWidth innerHeight "Inner" 100 innerColour theImage))

 

    ;Add the shadow layer to the image

    (set! shadowLayer (layer-add-fill innerWidth innerHeight "Shadow" shadowOpacity shadowColour theImage))

 

    ;Check to see if the extra outer is wanted

(if (= shadowInclude TRUE)

(begin

(set! outerWidth (+ outerWidth shadBlur))

(set! outerHeight (+ outerHeight shadBlur))

)

()

)

 

 

    ;Resize image

    (gimp-image-resize theImage outerWidth outerHeight outerSize outerSize)

 

    ;Resize the shadow layer

    (gimp-layer-resize shadowLayer (+ innerWidth shadBlur) (+ innerHeight shadBlur) 0 0)

 

    ;Move the shadow

    (gimp-drawable-offset shadowLayer TRUE 0 shadowSize shadowSize)

 

    ;Blur the shadow layer

    (if (> shadowBlur 0)    

(plug-in-gauss 1 theImage shadowLayer shadowBlur shadowBlur 0)

()

    )

 

    ;Add the outer layer to the image

    (set! outerLayer (layer-add-fill outerWidth outerHeight "Shadow" 100 outerColour theImage))

 

    ;Reset the background colour

    (gimp-context-set-background myBackground)

 

 

    ;Finish the undo group for the process

    ;temp(gimp-image-undo-group-end theImage)

 

 

;my add

(set! drawable (car (gimp-image-flatten theImage)))

;(set! drawable (car (gimp-image-get-active-layer theImage)))

 

(gimp-file-save RUN-NONINTERACTIVE theImage drawable "F:\my.jpg" "F:\my.jpg")

 

;my add

 

    ;Ensure the updated image is displayed now

    (gimp-displays-flush)

 

 

 

)))

)

 

 

(script-fu-register "script-fu-dil-batch"

            _"<Image>/Script-Fu/Misc/Dileepa Batch..."

            "Gives two border with a drop shadow"

            "Harry Phillips"

            "Harry Phillips"

            "30 July 2007"

            "*"

            SF-IMAGE "Image"     0

            SF-DRAWABLE "Drawable"  0

            SF-COLOR "Inner colour" '(255 255 255)

            SF-ADJUSTMENT _"Inner size"     '(25 0 1024 1 10 1 0)

            SF-COLOR "Outer colour" '(217 217 217)

   SF-ADJUSTMENT _"Outer size"      '(50 0 1024 1 10 1 0)

            SF-COLOR "Shadow colour" '(0 0 0)

   SF-ADJUSTMENT _"Shadow size"         '(10 5 1024 1 10 0 1)

   SF-ADJUSTMENT _"Shadow blur"    '(10 0 1024 1 10 0 1)

   SF-ADJUSTMENT _"Shadow opacity"        '(80 0 100 1 10 0 0)

   SF-TOGGLE     _"Outer border is full width past shadow"       FALSE

 

)            

 

Instead of pasting an entire script onto a post's thread, perhaps save the .scm to Pastebin or another code hosting site, and provide the link?

Subscribe to Comments for "Double border"