8 Replies Latest reply on Apr 28, 2010 10:59 AM by iblinked2

    Saving adjustment layers with layer mask

    iblinked2 Level 1

      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

        • 1. Re: Saving adjustment layers with layer mask
          Michael L Hale Level 5

          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.

          • 2. Re: Saving adjustment layers with layer mask
            iblinked2 Level 1

            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.

            • 3. Re: Saving adjustment layers with layer mask
              Michael L Hale Level 5

              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.

              1 person found this helpful
              • 4. Re: Saving adjustment layers with layer mask
                iblinked2 Level 1

                I guess I have a new feature request!

                 

                ;-)

                • 5. Re: Saving adjustment layers with layer mask
                  jugenjury Level 2

                  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.

                  • 6. Re: Saving adjustment layers with layer mask
                    iblinked2 Level 1

                    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.

                    • 7. Re: Saving adjustment layers with layer mask
                      Paul Riggott Level 6

                      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 );
                      };
                      
                      1 person found this helpful
                      • 8. Re: Saving adjustment layers with layer mask
                        iblinked2 Level 1

                        That looks pretty good! I'll have to put in all the exact locations -- tedious that -- but it might work. For the moment, I will use my workaround. There was less of a performance hit than I was expecting, so I might leave this as is, at least for the moment. Back to work....