Loading a layer mask as Selection in Script

If you have a layer (Layer 1), that has a mask on it, if you look at the Channel list in Photoshop, you will see a channel named "Layer 1 Mask" of which you can load the selection using the "Load Selection..." dialog.
If a layer has a mask, even if the layer is the active layer, the mask is not a channel object in script. At least, it not exposed.
activeDocument.channels.length returns the number of component channels plus any alpha channels. In an RGB image with only the layer mask it returns 3.
activeDocument.channels.getByName("Layer 1 Mask") throws an error.
So I don't see a way to tell if a layer already has a mask or how to load that mask as a selection, apply or discrad the mask, or turn the mask off without using scriptlistner.
I personally am using C#, and I tried the following which worked:
curDoc.Selection.Load(curDoc.Channels["Blue] ,null, null);
But this doesn't:
curDoc.Selection.Load(curDoc.Channels["Layer 1 Mask"] ,null, null);
Any help would be appreciated
Carl

As far as I know scriptlistner is the only way to deal with a layer's channel masks. A vector mask is part of the pathItems collection when the layer is active.

Similar Messages

  • Command-clicking layer name does not load layer as a selection (Photoshop CS2)

    Q: Why does Cmd-clicking a layer name not load the layer as a selection in Photoshop CS2?
    A: You must Cmd-click the layer thumbnail, not the layer name, to load the the layer as a selection.
    In Photoshop CS2 Cmd-clicking the layer name in the Layers Palette selects the layer. To select multiple layers use the following keystrokes:
    1. Multiple contiguous layers = Shift+click layer name
    2. Multiple non-contiguous layers = Cmd+click layer name
    See also Adobe Knowledgebase
    Document 329005

    It works for me and doesn't seem to care what tool i have selected or anything like that to make a difference. Maybe you should reset your preferences as it may be a glitch.
    Hold Ctrl+Alt+Shift as soon as you tell photoshop to startup, and it will ask you if you want to delete the preferences, just click yes. (If you have a custom UI that you want to save, goto Windows>Workspace>Save Workspace, and then just reload it after resetting prefs.)

  • Load layer as an selection

    Is it possible in Applescript or JavaScript to load a layer as an selection, the way you do manually with
    pressing-and-hold the Command (PC: Ctrl) key and click on the layer's thumbnail?

    Here is the javascript version.
    function loadLayerTransparencyToSelection() {
        var desc = new ActionDescriptor();
            var ref = new ActionReference();
            ref.putProperty( charIDToTypeID('Chnl'), charIDToTypeID('fsel') );
        desc.putReference( charIDToTypeID('null'), ref );
            var ref = new ActionReference();
            ref.putEnumerated( charIDToTypeID('Chnl'), charIDToTypeID('Chnl'), charIDToTypeID('Trsp') );
        desc.putReference( charIDToTypeID('T   '), ref );
        executeAction( charIDToTypeID('setd'), desc, DialogModes.NO );

  • Selecting a layer mask?

    Somehow I set something in PS CS 5 that is not allowing me to click on the layer mask to select it. I can select the mask via the mask panel but that's annoying and I would really like to figure out what I set to reset it back to the normal way I work. This does not seem to be set off for photoshop in general as I can open some files and can select  the mask via rolling the curser over it and clicking, but there are specific images I am working on currentily that seem to have this setting applied to them.  Any ideas or suggestions would be very appreciated. 
    thanks,  jeff

    Layers palette flyout menu >> layer panel options >> choose a larger thumbnail
    can you slect the mask now.
    Can you cmd click on a layer mask, to select the pixels.

  • Saving adjustment layers with layer mask

    Hello -
    I need to be able to save a curves adjustment layer WITH its layer mask.
    I have written a longish automatic applescript to process image files that are all identical in pixel dimension. Part of the script relies on Photoshop, where a number of actions take place. In one of the Photoshop actions, I need to load an adjustment layer with a precise layer mask. I realize that if a layer mask file is open I could write an action to load a selection from that file, but I very much want to avoid keeping a second file open, or forcing PS to open and close that file.
    Is there a simple way to "load" a layer mask into an adjustment layer?
    Thanks,
    - M

    Maybe you could do something like this...
    if(documents.length){
    CurveLayer();
    colourMask();
    function colourMask(){
    selectMask(true);
    var black = new SolidColor();
    black.rgb.hexValue = '000000';
    var Width = activeDocument.width.as('px');
    var Height = activeDocument.height.as ('px');
    var stripWidth = Width/12;
    var Left = 0;
    var Top = 0;
    var Right =stripWidth;
    var Bottom = Height/2;
    for (var a =0;a<12;a++){
        activeDocument.selection.select([[Left,Top],[Right,Top],[Right,Bottom],[Left,Bottom]], SelectionType.REPLACE, 0, false);
       if( a % 2) activeDocument.selection.fill(black);
        Left +=stripWidth;
        Right +=stripWidth;
    var Left = 0;
    var Top = Height/2;
    var Right =stripWidth;
    var Bottom = Height;
    for (var a =0;a<12;a++){
        activeDocument.selection.select([[Left,Top],[Right,Top],[Right,Bottom],[Left,Bottom]], SelectionType.REPLACE, 0, false);
       if(a % 2){}else{ activeDocument.selection.fill(black);}
        Left +=stripWidth;
        Right +=stripWidth;
    activeDocument.selection.deselect();
    selectMask(false);
    function CurveLayer() {
        var desc3 = new ActionDescriptor();
            var ref1 = new ActionReference();
            ref1.putClass( charIDToTypeID('AdjL') );
        desc3.putReference( charIDToTypeID('null'), ref1 );
            var desc4 = new ActionDescriptor();
                var desc5 = new ActionDescriptor();
                desc5.putEnumerated( stringIDToTypeID('presetKind'), stringIDToTypeID('presetKindType'), stringIDToTypeID('presetKindDefault') );
            desc4.putObject( charIDToTypeID('Type'), charIDToTypeID('Crvs'), desc5 );
        desc3.putObject( charIDToTypeID('Usng'), charIDToTypeID('AdjL'), desc4 );
        executeAction( charIDToTypeID('Mk  '), desc3, DialogModes.NO );
    function selectMask(BOOL) {
        var desc184 = new ActionDescriptor();
            var ref84 = new ActionReference();
            ref84.putEnumerated( charIDToTypeID('Chnl'), charIDToTypeID('Chnl'), charIDToTypeID('Msk ') );
        desc184.putReference( charIDToTypeID('null'), ref84 );
        desc184.putBoolean( charIDToTypeID('MkVs'), BOOL );
        executeAction( charIDToTypeID('slct'), desc184, DialogModes.NO );

  • Why is my Layer Mask filling with Grey

    I'm working in a multi layered CS5.1 Photoshop project (I did not create it). One of the adjustment layers in the project needs a layer masks, and when I create one it is not working properly. I make my selection that I want to mask off and create the layer mask it creates it with White and a 50% gray insted of black. Likewise when I alt click to create a layer mask it fills it in with black and 50% gray. The layer did have a 87% opacity to it so I thought this was causing the gray to happen, but when I turned the Opacity to 100% the mask was still being created with gray.
    I use the fill tool to fill the gray with Black or White (Fill settings are opacity 100 and fill 100) it fills the mask more like my fill opacity is set to 50%. Likewise it does this for the pant brush as well. I have messed with every layer setting I can find including the layer mask panel and the adjustment layer panel, and nothing seem to work.  Please help.
    P.S. I'm doing this for work and so I cant take any screen shots to show what is going on.

    Gsmith98 wrote:
    JJMack:  I control click the layer mask to select everything in it. The original layer does have some fethering to the file but i cant see why it would fill everythign the same shade of gray, and then not let me paint over it with black. This normally works for me and this issue is quite new.
    Ctl+Clicking on the layer's layer mask icon in the layers palette should work and load the layer mask as a selection.  Have you tried resetting your Photoshop preferences. Also ALT+Clicking on the layer's layer mask icon in the layers palette should display the grayscale of the selection in the image window.

  • Bug report: [layer mask] editing colors

    Sometimes it appears that the white/black color combination that is automatically selected in layer mask editing may override the selected color combination outside of layer mask editing.
    Example:
    1) Open Photoshop.
    2) Select two colors: white/white.
    3) Create two blank documents, each with an empty Layer 1.
    4) In one document, add a layer mask to Layer 1. The colors should have been automatically switched to black/white as the layer mask is selected.
    5) In this document, use the gradient tool to fill the layer mask with black/white.
    6) Switch to the other document, and notice that the color selection is again white/white.
    7) In this other document, use the gradient tool to fill Layer 1. Notice that the layer is filled with black/white instead of white/white as selected.
    Tested on: PS CS6, Windows 7, 64-bit.

    On further testing I think the issue may not be directly related to layer masks at all.
    Basically the issue is that the Gradient tool colors don't update to the 'default foreground/background colors' in cases where it seems that they should.
    One example of such a case (as illustrated in the original post) is when the Gradient tool keeps the black/white color combo used for a layer mask in a previous document after switching to the current document where a non-masked layer is targeted and the default fg/bg colors have correctly reverted to white/white.
    Example:
    layer mask targeted in doc1 - notice synchronised Gradient and default fg/bg colors
    after switching to non-masked layer in doc2, Gradient is still black/white although default fg/bg colors have reverted appropriately to white/white
    Bug or not, it's something I wanted to point out as it seems inconsistent.

  • Photoshop Elements 9 Layer Mask Difficulties

    Hi,
    I am trying to use the Photoshop Elements 9 layer mask tool but every time I brush over my image to hide sections of it, the image merely becomes faded-out, as if I were using a brush with a low opacity. However, my brush opacity is at 100%, as is the opacity for the layer mask itself. I have made sure that I am using a black brush, that my brush mode is set on normal, that the layer mask mode is set on normal, that the image's color mode is RGB, and that the layer mask is selected when I am painting on it. I have reset all the tools to their default settings, and have gotten rid of all other layers except for the image in question and the background layer so that nothing is obstructing my view. Whenever I paint on the layer mask, the thumbnail shows the black areas in which I painted, as it should; however, the image is still apparent. Meanwhile, when I use the eraser tool, areas I erase disappear just fine. What am I doing that is causing the layer mask tool to behave in this way?
    Thanks!

    Could you post a screenshot?
    If you press the D key then the X key, does that make any difference when you paint on the layer mask?

  • Layer Mask Transparency not White

    When I go to make a selection in Photoshop CS6 and then click on layer mask from the background layer, the inverse selection is trasparent, rahter than white. How do I change this? Thank you!

    Sorry for not describing it in better detail. Here is another example. When I go to crop image and expand my canvas beyond the borders and click ok, the background should be white, instead it is transparent.
    When I try to convert a selection from my background image into a layer mask by selecting and then clicking on the mask icon, my background is transparent rather than white. I have cleared all my settings and am totally stumped on what I should do. Any help would be much appreciated!

  • Painting on Shape layer mask not working correctly

    I created a Gradient layer and assigned a vector mask. I then added a mask channel. When I activate the mask channel the forground/background color switch to black and white, but if I attempt to swap the colors, either by clicking the "Swap colors" icon or "Shift-X" the LAYER color changes to black. I am unable to simply paint with black or white on the mask channel. Am I doing something wrong or is there a bug in PSCC 14.2?
    This process works as expected n PSCS6.

    Am I doing something wrong or is there a bug in PSCC 14.2?
    Is the question meant seriously?
    Is the Layer Mask actually selected in the Layers Panel?
    Could you please post a screenshot with the pertinent Panels visible?

  • Can't select or edit layer mask in CS5.1 extended

    In our class, we have photoshop CS5 on MACs
    I  started a project in class which involves creating a layer mask. I was about done with the mask, but  brought it home to finish. I opened the file on my WIN XP running  photoshop CS5.1 extended, which I installed this morning. In class I was  able to click on the mask to select it, then use the brush to edit the  details, painting black or white as needed to refine the edge.
    When I brought the .psd file home and opened  it in the newer version of Photoshop, it won't allow me to select the  mask for editing. I selected the layer then clicked on the mask thumbnail in the layer pallette but didn't see the corner  outlines that usually show when the layer thumbnail is selected. When I  tried brushing on what I thought was the mask (of the layer selected) I  got the pink overlay as is usually seen in quickmask. (fore and  background colors were black and white).
    Does v5.1 behave  differently with masks from v5.0? I didn't change any of the factory  default settings and in class it is standard practice to reset to the  default when we begin.
    any ideas?

    sweet. That did the trick Noel.
    I didn't turn quickmask on. I just loaded the file from my flash drive and first thing I tried was to select the layer mask. I'll have to try another file to see if PS is starting in quickmask mode itself.
    I had an inkling I was in quickmask mode from the pink painting, but hadn't selected it and didn't know about the q hotkey. newbie here just a few weeks into the intro course.
    again, thanks for the fast reply. I just might be able to finish this assignment yet tonight.

  • Apply selection to layer mask

    Hello,
    iam looking for a solution to apply a previeuws
    selction to a layer mask of a adjustment layer.
    My code mange to select the mask - but when i apply the
    selection it creates layer above.
    I need to go into the layer mask (alt and click) and then paste.
    Then go out.
    Scriptlistender isnt helping so much.
    app.activeDocument.selection.selectAll(); //selects stuff on the preview layer
    app.activeDocument.selection.copy();  //copy that stuff - to paste it into the mask later
    var adjLayer = doc.layerSets.getByName("ao").artLayers.getByName("ao");  //searching for a group and specific layer
    var mask = ExtendedLayer.selectLayerMask(adjLayer); // extern function wich selects the mask (does not go "into" the mask - just selects it)
    pastMask = function()
    // Selectin recorded by Script listender
    var idslct = charIDToTypeID( "slct" );
        var desc321 = new ActionDescriptor();
        var idnull = charIDToTypeID( "null" );
            var ref212 = new ActionReference();
            var idChnl = charIDToTypeID( "Chnl" );
            var idChnl = charIDToTypeID( "Chnl" );
            var idMsk = charIDToTypeID( "Msk " );
            ref212.putEnumerated( idChnl, idChnl, idMsk );
        desc321.putReference( idnull, ref212 );
        var idMkVs = charIDToTypeID( "MkVs" );
        desc321.putBoolean( idMkVs, false );
    executeAction( idslct, desc321, DialogModes.NO );
    // paste, recorded by script listender
    var idpast = charIDToTypeID( "past" );
        var desc322 = new ActionDescriptor();
        var idAntA = charIDToTypeID( "AntA" );
        var idAnnt = charIDToTypeID( "Annt" );
        var idAnno = charIDToTypeID( "Anno" );
        desc322.putEnumerated( idAntA, idAnnt, idAnno );
    executeAction( idpast, desc322, DialogModes.NO );
    pastMask();
    Any help would be really nice.!
    Thanks alot
    Alpha

    app.activeDocument.selection.selectAll(); //selects stuff on the preview layer 
    app.activeDocument.selection.copy();  //copy that stuff - to paste it into the mask later 
    var adjLayer = activeDocument.layerSets.getByName("ao").artLayers.getByName("ao");  //searching for a group and specific layer 
    activeDocument.activeLayer = adjLayer;
    pastMask = function() 
    // Selectin recorded by Script listender 
    var idslct = charIDToTypeID( "slct" ); 
        var desc321 = new ActionDescriptor(); 
        var idnull = charIDToTypeID( "null" ); 
            var ref212 = new ActionReference(); 
            var idChnl = charIDToTypeID( "Chnl" ); 
            var idChnl = charIDToTypeID( "Chnl" ); 
            var idMsk = charIDToTypeID( "Msk " ); 
            ref212.putEnumerated( idChnl, idChnl, idMsk ); 
        desc321.putReference( idnull, ref212 ); 
        var idMkVs = charIDToTypeID( "MkVs" ); 
        desc321.putBoolean( idMkVs, true ); 
    executeAction( idslct, desc321, DialogModes.NO ); 
    // paste, recorded by script listender 
    var idpast = charIDToTypeID( "past" ); 
        var desc322 = new ActionDescriptor(); 
        var idAntA = charIDToTypeID( "AntA" ); 
        var idAnnt = charIDToTypeID( "Annt" ); 
        var idAnno = charIDToTypeID( "Anno" ); 
        desc322.putEnumerated( idAntA, idAnnt, idAnno ); 
    executeAction( idpast, desc322, DialogModes.NO ); 
    pastMask();

  • How to select copy and paste an image that has a layer mask

    Hi,
    when I select, copy and paste the image it still has the content that I removed using the layer mask.
    I want to paste it over another psd whilst maintaing the transparency.
    Any help would be much appreciated.
    PSD is at
    http://sdrv.ms/16DoRft
    The small jpg is because I don't know what you will see in the skydrive psd
    Michael

    Wow that was so easy!
    Thanks!
    I spent at least half and hour trying to figure out why it wouldn't work.
    Michael

  • Am I Missing Something Obvious? Layer Mask Not Confined to Selection.

    Hello, I really hope I am not missing anything obvious.
    I am working on a .psd in Photoshop CC in which I used a selection to precisely remove a portion of a layer in a layer mask. The problem is that it is removing a percentage of the opacity in the non selected area. The brush has 100% Opacity, 100% Flow and is in Normal Mode. The layer has 100% Opacity, 100% Fill, and is in Normal Mode. I have tried restarting Photoshop and starting over from scratch. Here is an image of the issue.
    My only other concern is that on Friday we had a power outage due to lightning and PS CC closed unexpectedly. Could my PS CC be corrupted? My computer has restarted since then. Any suggestions would be wonderful. Thanks!

    The power outage should not have corrupted your Photoshop to cause this to happen. Worst that could have happened is Photoshop was forced to quit and your preferences did not get save for yourt panel layout and prefertence settings.
    Is your brush filled with 100 black, the swatch looks dark but you may be at 90% black.? Your screenshot looks fine though as if the mask is working correctly, can you post a screenshot that better shwos the problem.

  • How to select a layer mask (not its contents) and another layer/folder at the same time?

    I can do one or another, but both at the same time?
    It is annoying because a mask selection turns into layer selection when you select a second layer/folder.

    Well a layer mask is just that for that layer. If you want to apply that mask to a new layer, you can drag it or alt drag to drag a copy to the new layer. Then it will have its own layer mask. When your done, if needed you can then remove that mask from that new layer, if for some reason you only wanted to see a temporary mask.

Maybe you are looking for

  • Burn in itunes using external optical drive imac 2009

    My Matsushita optical drive (2009 iMac) no longer works.  Is there an external optical drive that I can purchase for burning music CD's?.  I already have Maverick, but I believe the operating system is not the problem.  The external optical drive has

  • Hp 8500 wireless, cant use tray 2 to feed photo paper

    I have tried defaulting to tray 2 to print a high quality photo on HP Advanced Photo Paper Glossy photo but it will only take paper from tray 1 How do I fix this??? Thanks in advance.

  • GNOME Desktop Too Bare!

    I love Arch and I love GNOME.  The problem is - the default GNOME desktop that comes with Arch is EXTREMELY BARE!  Even after I change the wallpaper and add some new icons.  It just feels so empty.  Do you guys have any suggestions on how I can fix t

  • Appliaction Server 9.2 Daylight Saving Time Patch

    We have an older Oracle Application Server 9.2. Do I need to apply Daylight Saving Time Patch. Thanks in advance! Robert

  • Installing ERP2005 SR2 on MSSQL Server 2008?

    Hi Hoping all the experts here can help me. We are creating a new system via system copy. Our source is ERP2005 SR2 on AIX/DB2 and our target is Windows 2008 Server and MSSQL Server 2008. We have taken the export of the source db. The installation ki