It is currently Fri Mar 29, 2024 10:38 am


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 25 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: [SOLVED] I need a script to convert a layer in a layer mask
PostPosted: Mon Feb 27, 2012 7:47 pm  (#1) 
Offline
GimpChat Member

Joined: Apr 12, 2010
Posts: 5870
GIMP Version: 2.7.5
Operating System: Windows
OS Version: XP - SP3
GIMP Experience: Basic Level



I forgot it!
i have a bw image that i need to paste as layermask...should be simple but i am stuck i even look the help but didn't helped much :gaah

PS i loaded the image i want copy as layermask as layer, it has same size of the other layer

_________________
My 3D Gallery on Deviantart http://photocomix2.deviantart.com/
Main gallery http://www.flickriver.com/photos/photocomix-mandala/
Mandala and simmetry http://www.flickriver.com/photos/photocomix_mandala/

Image

Mrs Wilbress


Last edited by PhotoComix on Thu Mar 22, 2012 1:43 pm, edited 2 times in total.

Share on Facebook Share on Twitter Share on Orkut Share on Digg Share on MySpace Share on Delicious Share on Technorati
Top
 Post subject: Re: How copy a layer as layer mask
PostPosted: Mon Feb 27, 2012 7:53 pm  (#2) 
Offline
GimpChat Member

Joined: Apr 12, 2010
Posts: 5870
i see but is cumbersome:
i entered in quickmask mode
pasted over the quickmask,
then saved as a channel,
then finally transferred as layermask

i remember was a script maybe from saulgoode to avoid this but i can't see in his site

_________________
My 3D Gallery on Deviantart http://photocomix2.deviantart.com/
Main gallery http://www.flickriver.com/photos/photocomix-mandala/
Mandala and simmetry http://www.flickriver.com/photos/photocomix_mandala/

Image

Mrs Wilbress


Top
 Post subject: Re: How copy a layer as layer mask
PostPosted: Mon Feb 27, 2012 8:39 pm  (#3) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4726
PhotoComix wrote:
i see but is cumbersome:
i entered in quickmask mode
pasted over the quickmask,
then saved as a channel,
then finally transferred as layermask

i remember was a script maybe from saulgoode to avoid this but i can't see in his site

Sightly simpler:
- Open as layer
- Make it the only visible (already the case if on top and as big as the image)
- Drag any of the RGB color channels down in the general channels list
- Delete layer
- Init layer mask to this channel

_________________
Image


Top
 Post subject: Re: How copy a layer as layer mask
PostPosted: Mon Feb 27, 2012 8:54 pm  (#4) 
Offline
Script Coder
User avatar

Joined: Apr 23, 2010
Posts: 1553
Location: not from Guildford after all
PhotoComix wrote:
i see but is cumbersome:
i entered in quickmask mode
pasted over the quickmask,
then saved as a channel,
then finally transferred as layermask


A bit easier:
    Enter Quickmask
    Paste
    Exit Quickmask (your pasted layer is now the selection)
    Add Layer Mask initialized to "Selection"

_________________
Any sufficiently primitive technology is indistinguishable from a rock.


Top
 Post subject: Re: How copy a layer as layer mask
PostPosted: Mon Feb 27, 2012 9:06 pm  (#5) 
Offline
GimpChat Member

Joined: Apr 12, 2010
Posts: 5870
yes that is quicker

Quote:
Add Layer Mask initialized to "Selection"


I am wrong or i may initialize the layermask only when i creating it ?

_________________
My 3D Gallery on Deviantart http://photocomix2.deviantart.com/
Main gallery http://www.flickriver.com/photos/photocomix-mandala/
Mandala and simmetry http://www.flickriver.com/photos/photocomix_mandala/

Image

Mrs Wilbress


Top
 Post subject: Re: How copy a layer as layer mask
PostPosted: Mon Feb 27, 2012 9:10 pm  (#6) 
Offline
GimpChat Member
User avatar

Joined: May 16, 2010
Posts: 14709
Location: USA
Cant you just create a new layer add a mask and select the other layer and copy and paste the layer into the mask?
Jolie actually has a tutorial on this at her YouTube channel. :) (the remove bg tutorial)

_________________
Image
Edmund Burke nailed it when he said, "The only thing necessary for the triumph of evil is for good men to do nothing."


Top
 Post subject: Re: How copy a layer as layer mask
PostPosted: Mon Feb 27, 2012 9:15 pm  (#7) 
Offline
GimpChat Member
User avatar

Joined: Mar 02, 2011
Posts: 1850
Location: Michigan
easiest way yet ask at gimp chat get 4+ different ways to do one thing :D
it always amazes me how many ways one thing can be done in gimp

_________________
Image
I'm back I think


Top
 Post subject: Re: How copy a layer as layer mask
PostPosted: Mon Feb 27, 2012 9:29 pm  (#8) 
Offline
GimpChat Member

Joined: Apr 12, 2010
Posts: 5870
Rod wrote:
Cant you just create a new layer add a mask and select the other layer and copy and paste the layer into the mask?
Jolie actually has a tutorial on this at her YouTube channel. :) (the remove bg tutorial)


that was what i planned but copy and paste on the layermask doesn't work (that just create a floating selection)

Ofnuts and Saulgoode suggestions simplify the process, ..still i would prefer direct copy and paste

but at least now i may do quickly

PS
Saulgoode i am wrong or you wrote (maybe years ago for a previous gimp version) a sort of "paste as layermask" script (name was different but that was the main function )

_________________
My 3D Gallery on Deviantart http://photocomix2.deviantart.com/
Main gallery http://www.flickriver.com/photos/photocomix-mandala/
Mandala and simmetry http://www.flickriver.com/photos/photocomix_mandala/

Image

Mrs Wilbress


Top
 Post subject: Re: How copy a layer as layer mask
PostPosted: Mon Feb 27, 2012 10:59 pm  (#9) 
Offline
Script Coder
User avatar

Joined: Apr 23, 2010
Posts: 1553
Location: not from Guildford after all
PhotoComix wrote:
PS
Saulgoode i am wrong or you wrote (maybe years ago for a previous gimp version) a sort of "paste as layermask" script (name was different but that was the main function )

I probably did, way back when. Rather than revisit that, here is a script which might simplify your task a little while being a bit more general in its utility.

It is largely based upon the GAP's "Copy layer mask from layer above" function in the Frames Modify command.

Here is the description:

;; This script adds a layermask to the active layer based upon
;; the layermask of the visible layer above it in the layer stack.
;; Specifically,
;;   If the active layer already has a mask, it is replaced.
;;   If the above layer has a mask, that mask is added to the active layer.
;;   If the above layer does not have a mask, a grayscale copy of the
;;     above layer is added as a mask to the active layer.
;;   If there is no visible layer above the active one, a mask is added
;;     initialized from the selection (avoiding the dialog popup).


The command, "Copy Layer Mask From Above", is added to both the "Layer->Mask" menu and the Layers context menu (that appears when you right-click on a layer).

With this script installed, you could dragon drop your mask layer from the other image onto the target image, placed above the layer to which it is to be added as a mask. You will have to remove the layer (or hide it) after running the script so it doesn't save that many steps, but I think it is generally an approach that should prove useful in other situations (I have used a similar script for a few years now -- for some reason I find copy-n-paste to be a bit tedious).

_________________
Any sufficiently primitive technology is indistinguishable from a rock.


Last edited by saulgoode on Tue Feb 28, 2012 4:31 am, edited 1 time in total.

Top
 Post subject: Re: How copy a layer as layer mask
PostPosted: Tue Feb 28, 2012 12:33 am  (#10) 
Offline
Script Coder
User avatar

Joined: Feb 18, 2011
Posts: 4827
Location: Bendigo Vic. Australia
Saulgoode Ive been watching this thread becouse I to had this problem with a folder full of layer masks I found difficult to use. Your script works a treat.

_________________
Image
No matter how much you push the envelope, it'll still be stationery.


Top
 Post subject: Re: How copy a layer as layer mask
PostPosted: Tue Feb 28, 2012 2:53 am  (#11) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4726
PhotoComix wrote:
Rod wrote:
Cant you just create a new layer add a mask and select the other layer and copy and paste the layer into the mask?
that was what i planned but copy and paste on the layermask doesn't work (that just create a floating selection)

Hehe.... actually you were on the right track... it creates a floating selection but if you are working on a layer mask, anchoring the selection puts it in the mask. So it's actually quite simple :)

_________________
Image


Top
 Post subject: Re: How copy a layer as layer mask
PostPosted: Tue Feb 28, 2012 5:04 am  (#12) 
Offline
Script Coder
User avatar

Joined: Apr 23, 2010
Posts: 1553
Location: not from Guildford after all
I have made a minor revision of the script to better handle text layers. If the above layer is a text layer and it has a layermask then there is no change in the behavior; that layermask is added to the active layer.

However, if the above layer is a text layer without a layermask (a fairly common occurrence for text layers), then the layermask will be created from the text itself, regardless of the color of the text.

The reason for this change is that the transparent background of a layer gets converted to black when copied to a mask. For a text layer this generally is not how you want the mask to be created. For example, if you have black text then the resulting mask would be entirely black. Other colors except for pure white would be some shade of gray. The script now assumes that you want the text part of the mask to be white.

Here is the new link (I've also updated my previous post):
http://chiselapp.com/user/saulgoode/rep ... from-above

_________________
Any sufficiently primitive technology is indistinguishable from a rock.


Top
 Post subject: Re: How copy a layer as layer mask
PostPosted: Tue Feb 28, 2012 6:56 am  (#13) 
Offline
GimpChat Member
User avatar

Joined: Sep 06, 2011
Posts: 368
Location: US, Ohio
PhotoComix wrote:
GIMP Version: 2.7.5
Operating System: Windows
OS Version: XP - SP3
GIMP Experience: Basic Level



I forgot it!
i have a bw image that i need to paste as layermask...should be simple but i am stuck i even look the help but didn't helped much :gaah

PS i loaded the image i want copy as layermask as layer, it has same size of the other layer



I usually paste the image as a layer, and then right click on the newly created layer and click "add layer mask."

I then initialize the layer mask to "grayscale copy of layer."

After that I right-click on the newly created layer mask and click "mask to selection"

I the right click on the layer I want my mask on and click "add layer mask"
I initialize the mask to selection.


Top
 Post subject: Re: How copy a layer as layer mask
PostPosted: Tue Feb 28, 2012 1:25 pm  (#14) 
Offline
GimpChat Member
User avatar

Joined: May 16, 2010
Posts: 14709
Location: USA
Yes i imagine i should have mentioned "anchor the layer" :)

_________________
Image
Edmund Burke nailed it when he said, "The only thing necessary for the triumph of evil is for good men to do nothing."


Top
 Post subject: Re: How copy a layer as layer mask
PostPosted: Tue Feb 28, 2012 6:49 pm  (#15) 
Offline
Script Coder
User avatar

Joined: Feb 18, 2011
Posts: 4827
Location: Bendigo Vic. Australia
Saulgoode on the layer above if the text is black with transparent background the layer mask created is still all black.

_________________
Image
No matter how much you push the envelope, it'll still be stationery.


Top
 Post subject: Re: How copy a layer as layer mask
PostPosted: Tue Feb 28, 2012 6:59 pm  (#16) 
Offline
Script Coder
User avatar

Joined: Apr 23, 2010
Posts: 1553
Location: not from Guildford after all
Graechan wrote:
Saulgoode on the layer above if the text is black with transparent background the layer mask created is still all black.

Did you download the updated version of the script mentioned in this post? It is possible I've made a mistake (I made one once before, back in 1993), so let me know if you have the updated version and are still seeing the behavior you describe.

_________________
Any sufficiently primitive technology is indistinguishable from a rock.


Top
 Post subject: Re: How copy a layer as layer mask
PostPosted: Wed Feb 29, 2012 2:00 am  (#17) 
Offline
Script Coder
User avatar

Joined: Feb 18, 2011
Posts: 4827
Location: Bendigo Vic. Australia
Just redownloaded and installed, top layer is black text, selected bottom layer is gray background color, there is no mask on either, I run script bottom layer has all black mask. Script has not changed.

_________________
Image
No matter how much you push the envelope, it'll still be stationery.


Top
 Post subject: Re: How copy a layer as layer mask
PostPosted: Wed Feb 29, 2012 6:02 am  (#18) 
Offline
GimpChat Member

Joined: Apr 12, 2010
Posts: 5870
ofnuts wrote:
PhotoComix wrote:
Rod wrote:
Cant you just create a new layer add a mask and select the other layer and copy and paste the layer into the mask?
that was what i planned but copy and paste on the layermask doesn't work (that just create a floating selection)

Hehe.... actually you were on the right track... it creates a floating selection but if you are working on a layer mask, anchoring the selection puts it in the mask. So it's actually quite simple :)


That it what i thought !
but no matter how much i tried the floating selection accepted only to be pasted on the layer below not on its mask (yes i click on the mask in the layer windows to be sure it was active)

PS this using gimp2.7.5 from partha i didn't try with the stable version

_________________
My 3D Gallery on Deviantart http://photocomix2.deviantart.com/
Main gallery http://www.flickriver.com/photos/photocomix-mandala/
Mandala and simmetry http://www.flickriver.com/photos/photocomix_mandala/

Image

Mrs Wilbress


Top
 Post subject: Re: How copy a layer as layer mask
PostPosted: Wed Feb 29, 2012 6:58 am  (#19) 
Offline
Script Coder
User avatar

Joined: Apr 23, 2010
Posts: 1553
Location: not from Guildford after all
Graechan wrote:
Just redownloaded and installed, top layer is black text, selected bottom layer is gray background color, there is no mask on either, I run script bottom layer has all black mask. Script has not changed.

Hmmm, strange.
Attachment:
copymask.gif
copymask.gif [ 310.05 KiB | Viewed 1277 times ]


What version of GIMP are you using?

_________________
Any sufficiently primitive technology is indistinguishable from a rock.


Top
 Post subject: Re: How copy a layer as layer mask
PostPosted: Wed Feb 29, 2012 6:18 pm  (#20) 
Offline
Script Coder
User avatar

Joined: Feb 18, 2011
Posts: 4827
Location: Bendigo Vic. Australia
Saulgoode I am using 2.6.11 but here is the bug I think, look at the text layer I used.

Image

_________________
Image
No matter how much you push the envelope, it'll still be stationery.


Top
Post new topic Reply to topic  [ 25 posts ]  Go to page 1, 2  Next

All times are UTC - 5 hours [ DST ]


   Similar Topics   Replies 
No new posts Add layer mask hides the entire layer

3

No new posts How do I script a new white layer to the bottom of the layer stack

7

No new posts Create Layer Mask From

8

No new posts Attachment(s) PYTON-FU-CREATE-LAYER-MASK-FROM...

3

No new posts Automating Layer mask application

4



* Login  



Powered by phpBB3 © phpBB Group