RSS/Atom feed Twitter
Site is read-only, email is disabled

Knockout layers

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.

This is a read-only list on gimpusers.com so this discussion thread is read-only, too.

3 of 3 messages available
Toggle history

Please log in to manage your subscriptions.

Knockout layers Jorge Antunes 08 Jan 10:40
  Knockout layers Scott Bicknell 08 Jan 12:12
   Knockout layers Jorge Antunes 08 Jan 13:40
Jorge Antunes
2007-01-08 10:40:36 UTC (over 17 years ago)

Knockout layers

Hi,
I'm new to Gimp and i'm trying to find a way to duplicate in gimp a procedure that I've used in Photoshop. In photoshop I use extensively the layer grouping because layer's advanced blending knockout options.
I know that layer grouping is not possible in Gimp, but I also can´t find similar options to knockout blending. How can I, using Gimp, set a knockout layer? Best Regards,
Jorge Antunes

Scott Bicknell
2007-01-08 12:12:56 UTC (over 17 years ago)

Knockout layers

On Monday 08 January 2007 1:40 am, Jorge Antunes wrote:

Hi,
I'm new to Gimp and i'm trying to find a way to duplicate in gimp a procedure that I've used in Photoshop. In photoshop I use extensively the layer grouping because layer's advanced blending knockout options. I know that layer grouping is not possible in Gimp, but I also can´t find similar options to knockout blending. How can I, using Gimp, set a knockout layer? Best Regards,
Jorge Antunes

You can achieve the same result using layer masks. Unfortunately, there is not a simple built-in way of copying a layer mask to multiple layers or of applying a layer mask to multiple layers. There is a script-fu plugin that will do that. I don't know where I got it. It doesn't seem to be in the Gimp's plugin repository. So here it is:

; This program is free software; you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation; either version 2 of the License, or
; (at your option) any later version. ;
; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ; GNU General Public License for more details.

(define (script-fu-copy-mask-to-layers image drawable) (define (visible-layers img)
(let* (
(all-layers (gimp-image-get-layers img)) (i (car all-layers))
(viewable ())
(tmp FALSE))
(set! all-layers (cadr all-layers)) (while (> i 0)
(set! tmp (car (gimp-drawable-get-visible (aref all-layers (- i 1)))))
(if (= tmp TRUE)
(set! viewable (append viewable (cons (aref all-layers (- i 1))))))
(set! i (- i 1)))
viewable))
(let* (
(active-layer (car (gimp-image-get-active-layer image))) (source-layer)
(source-mask)
(layers)
(mask))
(set! layers (visible-layers image)) (gimp-image-undo-group-start image) (set! source-layer (car (gimp-layer-new-from-drawable active-layer image)))
(gimp-image-add-layer image source-layer -1) (set! source-mask (car (gimp-layer-get-mask source-layer))) (if (= source-mask -1)
(begin
(set! source-mask (car (gimp-layer-create-mask source-layer ADD-COPY-MASK)))
(gimp-layer-add-mask source-layer source-mask))) (while (car layers)
(if (= (car (gimp-layer-get-mask (car layers))) -1) (if (= (car (gimp-drawable-has-alpha (car layers))) 1) (set! mask (car (gimp-layer-add-mask (car layers) source-mask)))))
(set! layers (cdr layers)))
(gimp-image-remove-layer image source-layer) (gimp-image-undo-group-end image)
(gimp-displays-flush)))

(script-fu-register "script-fu-copy-mask-to-layers" "/Script-Fu/_Copy mask"
"Copy the mask from the current layer to all visible layers" "Saul Goode"
"Saul Goode"
"6/14/2006"
""
SF-IMAGE "Image" 0
SF-DRAWABLE "Drawable" 0
)

Just copy that to a separate file, name it with a .scm extension and place it in your Gimp script-fu directory. You can find it on your image Window's Script-fu menu at the bottom.

It will copy a layer mask to all visible layers, replacing any masks that already exist, so be careful. You can create a mask that punches a hole in one layer and use this plugin to apply the same mask to all the other layers of an image.

Jorge Antunes
2007-01-08 13:40:52 UTC (over 17 years ago)

Knockout layers

Hi
@ Scott,
Thank you very much for the script. I will give it a try.

@ David A knockout, in general terms, is a layer that 'makes' a hole in the beneath layers allowing to show the background layer. Picture this: you've a background layer with an image, a layer that covers the background layer with a color and a third layer, above all, that will punch a hole in the middle layer allowing the background layer to appear. More explicit here: http://teched.vt.edu/gcc/HTML/VirtualTextbook/PDFs/AdobeTutorialsPDFs/Photoshop/PhotoshopKnockout.pdf and
here:
http://www.samspublishing.com/articles/article.asp?p=26131&seqNum=4&rl=1 Best regards,
Jorge

2007/1/8, Scott Bicknell :

On Monday 08 January 2007 1:40 am, Jorge Antunes wrote:

Hi,
I'm new to Gimp and i'm trying to find a way to duplicate in gimp a procedure that I've used in Photoshop. In photoshop I use extensively the layer grouping because layer's advanced blending knockout options. I know that layer grouping is not possible in Gimp, but I also can´t find similar options to knockout blending. How can I, using Gimp, set a knockout layer? Best Regards,
Jorge Antunes

You can achieve the same result using layer masks. Unfortunately, there is not a simple built-in way of copying a layer mask to multiple layers or of applying a layer mask to multiple layers. There is a script-fu plugin that will do that. I don't know where I got it. It doesn't seem to be in the Gimp's plugin repository. So here it is:

; This program is free software; you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation; either version 2 of the License, or
; (at your option) any later version. ;
; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ; GNU General Public License for more details.

(define (script-fu-copy-mask-to-layers image drawable) (define (visible-layers img)
(let* (
(all-layers (gimp-image-get-layers img)) (i (car all-layers))
(viewable ())
(tmp FALSE))
(set! all-layers (cadr all-layers)) (while (> i 0)
(set! tmp (car (gimp-drawable-get-visible (aref all-layers (- i 1)))))
(if (= tmp TRUE)
(set! viewable (append viewable (cons (aref all-layers (- i 1))))))
(set! i (- i 1)))
viewable))
(let* (
(active-layer (car (gimp-image-get-active-layer image))) (source-layer)
(source-mask)
(layers)
(mask))
(set! layers (visible-layers image)) (gimp-image-undo-group-start image) (set! source-layer (car (gimp-layer-new-from-drawable active-layer image)))
(gimp-image-add-layer image source-layer -1) (set! source-mask (car (gimp-layer-get-mask source-layer))) (if (= source-mask -1)
(begin
(set! source-mask (car (gimp-layer-create-mask source-layer ADD-COPY-MASK)))
(gimp-layer-add-mask source-layer source-mask))) (while (car layers)
(if (= (car (gimp-layer-get-mask (car layers))) -1) (if (= (car (gimp-drawable-has-alpha (car layers))) 1) (set! mask (car (gimp-layer-add-mask (car layers) source-mask)))))
(set! layers (cdr layers)))
(gimp-image-remove-layer image source-layer) (gimp-image-undo-group-end image)
(gimp-displays-flush)))

(script-fu-register "script-fu-copy-mask-to-layers" "/Script-Fu/_Copy mask"
"Copy the mask from the current layer to all visible layers" "Saul Goode"
"Saul Goode"
"6/14/2006"
""
SF-IMAGE "Image" 0
SF-DRAWABLE "Drawable" 0
)

Just copy that to a separate file, name it with a .scm extension and place it in your Gimp script-fu directory. You can find it on your image Window's Script-fu menu at the bottom.

It will copy a layer mask to all visible layers, replacing any masks that already exist, so be careful. You can create a mask that punches a hole in one layer and use this plugin to apply the same mask to all the other layers of an image. --
73, AC7ZZ
http://counter.li.org/
Linux User #246504