Mobile app version of vmapp.org
Login or Join
Ogunnowo857

: Automate Adding Individual Reveal All Mask to Many Layers in Photoshop? In Adobe Photoshop CC, what's a fast way to add individual default masks (Reveal All) to every layer in a document with

@Ogunnowo857

Posted in: #AdobePhotoshop #Automation #Layers #Mask #PhotoshopScripting

In Adobe Photoshop CC, what's a fast way to add individual default masks (Reveal All) to every layer in a document with a large layer count (say 100 layers)?

I need individual masks, not group masks.

I can manually ALT+drag to duplicate a mask to other layers, or simply scroll through selected each layer and then clicking the mask button at the bottom of the Layers pane, but I'm trying to create an automated process hence those are not desirable options.

Perhaps there's a script solution to add individual full reveal masks to all open layers?



Backstory

Per the workaround here to export en masse png-24 images of a common size to png-8 w/ partial transparency, I'm doing File > Scripts > Load Files Into Stack, selecting all layers, right-clicking on the selection, and lastly choosing Quick Export as png-8 from the click options menu that comes up.

The only problem is that the Quick Export as png-8 saves a cropped copy, disregarding the canvas size. Going individually into Export As will work if I manually change the canvas size, but selecting all layers and putting a common canvas size centers the images...

But I've found a way to get the right click Quick Export... to respect the canvas position & not crop -- add a 100% fill mask (so all white). This has no affect on the image other than to preserve the transparent bounding box from cropping upon Quick Export... / Export As.

However, adding individual masks negates individual time savings. Hence I need to find a way to add them to each layer quickly (group mask doesn't work).

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Ogunnowo857

2 Comments

Sorted by latest first Latest Oldest Best

 

@Gloria351

I found a script which adds a 'Hide All' layer mask to every layer here

So I did a little more digging and figured out how to change it from 'Hide All' to 'Reveal All'.

Here you go:

// RevealMask-AllLayers – Adds a 'Reveal All' mask to all layers
#target photoshop

if(app.documents.length>0){
var docRef = activeDocument;
var layerNum = docRef.layers.length;

for(var i=0;i<layerNum;i++){
docRef.activeLayer = docRef.layers[i];
if(!docRef.activeLayer.isBackgroundLayer){
try{addMask ()}
catch(e){}
}
}
}
else{alert('There are no open files')};

function addMask(){
var idMk = charIDToTypeID( "Mk " );
var desc2 = new ActionDescriptor();
var idNw = charIDToTypeID( "Nw " );
var idChnl = charIDToTypeID( "Chnl" );
desc2.putClass( idNw, idChnl );
var idAt = charIDToTypeID( "At " );
var ref1 = new ActionReference();
var idChnl = charIDToTypeID( "Chnl" );
var idChnl = charIDToTypeID( "Chnl" );
var idMsk = charIDToTypeID( "Msk " );
ref1.putEnumerated( idChnl, idChnl, idMsk );
desc2.putReference( idAt, ref1 );
var idUsng = charIDToTypeID( "Usng" );
var idUsrM = charIDToTypeID( "UsrM" );
var idHdAl = charIDToTypeID( "RvlA" );
desc2.putEnumerated( idUsng, idUsrM, idHdAl );
executeAction( idMk, desc2, DialogModes.NO );
}

10% popularity Vote Up Vote Down


 

@Murray976

I think the easiest way would be to create an action with an F key assigned. You still have to tap a key... but it would be faster.


Highlight the top most layer in the stack
Create a new Action and assign it an F key, start recording
Choose Layer > Layer Mask > Reveal All
Hold the Option/Alt key down and tap the left bracket key ([) -- This should highlight the next layer down in the layer stack
Stop recording the action


Now highlight a layer tap the F key you assigned... and keep tapping until you reach the bottom of the layer stack.



I'm sure this could be scripted as well, but that's out of my wheelhouse.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme