I am writting a script-fu that uses the gimp-by-color-select function.  The 
trouble I am having is that the function only works the way that I expect 
when the drawable that I pass to it has an open display.  If the drawable has 
no open display then the result is that it selects the entire image, not just 
the color that I want.

Example - 

The following script works as predicted:

(define (redglow inImage inLayer)
  (let*
      (
        ; define local vars
       (
       (thePaste)
       (bounds)
       (x)
       (y)
       )
        ; the script
    (gimp-by-color-select inLayer '(255 255 80) 60 2 1 0 0 1)
    (set! bounds (gimp-selection-bounds inImage))
    (set! x (cadr bounds))
    (set! y (caddr bounds))
    (gimp-edit-copy inLayer)
    (gimp-selection-grow inImage 2)
    (gimp-selection-feather inImage 4)
    (gimp-palette-set-background '(255 80 255))
    (gimp-edit-fill inLayer 1)
    (set! thePaste (car(gimp-edit-paste inLayer 0)))
    (gimp-layer-set-offsets thePaste x y)
    (gimp-floating-sel-anchor thePaste)
)
)

However, the following script does not produce the same result:

(define (redglow inImage inLayer)
  (let*
      (
     ; define local vars
       (theImage (car (file-png-load 0 "buttons/n_button_0_2.png" 
"buttons/n_button_0_2.png")))
       (theLayer (aref (cadr (gimp-image-get-layers theImage)) 0) )
       (thePaste)
       (bounds)
       (x)
       (y)
       )
                                        ; do it
    (gimp-by-color-select theLayer '(255 255 80) 60 2 1 0 0 1)
    (set! bounds (gimp-selection-bounds theImage))
    (set! x (cadr bounds))
    (set! y (caddr bounds))
    (gimp-edit-copy theLayer)
    (gimp-selection-grow theImage 2)
    (gimp-selection-feather theImage 4)
    (gimp-palette-set-background '(255 80 255))
    (gimp-edit-fill theLayer 1)
    (set! thePaste (car(gimp-edit-paste theLayer 0)))
    (gimp-layer-set-offsets thePaste x y)
    (gimp-floating-sel-anchor thePaste)
)
)

Unless I add "(gimp-display-new theImage)" before the call to 
gimp-by-color-select, then it works again.  This solution is not optimal 
since I am hoping to run this in batch mode with no displays.

I have searched gimp.org deja.com etc., but I can't find any reference to a 
similar problem.  Any hints on what I am doing wrong would be much 
appreciated.

I am using gimp 1.2.2 from the FreeBSD 4.5 ports collection.

Thanks,

/Nathan.
_______________________________________________
Gimp-user mailing list
[EMAIL PROTECTED]
http://lists.xcf.berkeley.edu/mailman/listinfo/gimp-user

Reply via email to