Skip to main content
Participant
April 28, 2010
Question

Saving adjustment layers with layer mask

  • April 28, 2010
  • 2 replies
  • 917 views

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

This topic has been closed for replies.

2 replies

Inspiring
April 28, 2010

If you're doing this in sequence, you would only need to open the original file once to get the info, then close it and process through your documents.

You can copy alpha channels to the clipboard and paste them back in.

You could theoretically do this with any image file type as long as the dimensions are the same and it's in grayscale. I won't guarantee this as I've never tried it this way, but it should work.

iblinked2Author
Participant
April 28, 2010

There will be hundreds, even thousands of images over the course of many months, with multiple people using the computers, copying and pasting at will. I definitely can not use the clipboard for this. At the moment, I plan to work around this by automatically opening a default image that contains the masking layer, loading it as a selection (in the image that needs to be corrected, of course)  and then filling the selection with black in the active adjustment layer mask. Not very elegant, but it should work.

Paul Riggott
Inspiring
April 28, 2010

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 );
};

Inspiring
April 28, 2010

If I understand what you are asking then the answer is no. In order to use a channel as a mask it needs to be in an open document. Either as a channel in the doc that needs the mask or in another document ideally the same size as the doc that needs the mask.

iblinked2Author
Participant
April 28, 2010

I was afraid of that. I could convert it into a path, or a vector shape. Still, I do not see any way to "load" it without a second open image, unless I action the creation of the mask.

Inspiring
April 28, 2010

Yes, even a path or shape layer would need to be open before you could use that for a layer mask.

I guess that if the mask was a simple one you could select the mask, make selections, and fill with black or white, then deselect both the selection and mask.