Sign up now! · Forgot password?
RSS/Atom feed Twitter

gimp-by-color-select trouble

This discussion is connected to the gimp-user-list.gnome.org mailing list which is provided by the GIMP developers and not related to gimpusers.com.

2 of 2 messages available
Toggle history

Please log in to manage your subscriptions.

gimp-by-color-select trouble Nathan Hackett 11 Apr 20:43
  gimp-by-color-select trouble Nathan Hackett 11 Apr 21:46
Nathan Hackett
2002-04-11 20:43:56 UTC (over 19 years ago)

gimp-by-color-select trouble

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.

Nathan Hackett
2002-04-11 21:46:17 UTC (over 19 years ago)

gimp-by-color-select trouble

If I change the last parameter to gimp-by-color-select (sample-merged) to false, then it works. Now if I can figure out how to put all the hair that I pulled out back in, I'll be in good shape.

/Nathan.

On Thursday 11 April 2002 11:43 am, Nathan Hackett wrote:

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.