Photoshop: Apply mask to selected layers

  • 2
  • Idea
  • Updated 2 weeks ago
  • (Edited)
In my job, we quite often need to apply a layer mask to a psd containing lots of layers/folders. Currently the only way to apply the same mask (for example a mask of the entire workspace) is to either apply it individually to each layer, or to create the mask on one layer and alt-drag copying it to the next layers. It would be a big time saver and less fiddly to be able to select all the layers needing the mask, and then when you hit the mask button, it applies to all selected layers. Seems like something so simple, so I'm wondering why it's not possible?
Photo of Drew Bristow

Drew Bristow

  • 8 Posts
  • 0 Reply Likes

Posted 3 months ago

  • 2
Photo of Jerry Syder

Jerry Syder

  • 496 Posts
  • 226 Reply Likes
The other way is to create a group of your layers(CTRL + G of selected layers) and mask that group. That gives more flexibility in the event that you need to fine-tune the mask, you won't have to do this 20 times but once to the group... 
Photo of Drew Bristow

Drew Bristow

  • 8 Posts
  • 0 Reply Likes
Unfortunately I'd still need to manually go and switch on or off the groups within that group. Typically a psd file will contain anything between 1-20 groups, those groups will have a screen ID as their name, and with will be the image and anything associated with editing that image (like adjustment layers etc.)
Photo of Jeffrey Tranberry

Jeffrey Tranberry, Sr. Product Manager, Digital Imaging

  • 17043 Posts
  • 2892 Reply Likes
This is probably doable with scripting if you're handy with JavaScript. Or check with some folks here to see if anyone has already written one: https://www.ps-scripts.com
Photo of christoph pfaffenbichler

christoph pfaffenbichler, Champion

  • 1530 Posts
  • 307 Reply Likes
I see a noticeable risk in the »semitransparent edge pixels» (due to Feathering, Anti-Aliasing, ...) when a Mask is applied to multiple Layers as compared to a Group containing those Layers. 
It may be irrelevant for you and unnoticeable in many cases but for some combinations it could become a nuisance. 
Photo of Max Johnson

Max Johnson, Champion

  • 624 Posts
  • 338 Reply Likes
Totally untested, but check out this script... it should let you run an action on all selected layers... so if you make a named layer called "actionmask" and record an action for:
  1. Select pixels on "actionmask" layer (ctrl-click the layer thumbnail)
  2. Create mask
You should then be able to play that action on all selected layers and win at masks?
https://github.com/Paul-Riggott/PS-Scripts/blob/master/Run%20Action.jsx
(Edited)
Photo of Drew Bristow

Drew Bristow

  • 8 Posts
  • 0 Reply Likes
Ooooh that sounds good! Thanks Max, I'll give it a go asap!
Photo of Drew Bristow

Drew Bristow

  • 8 Posts
  • 0 Reply Likes
Hi Max! I never got round to trying this but I've reached a point I need to again, that link takes me to a bunch of code - how do I use it?
Photo of Stephen Marsh

Stephen Marsh

  • 110 Posts
  • 28 Reply Likes
Hi Drew, take a look at the following blogpost for more on saving and running scripts:

https://prepression.blogspot.com/2017/11/downloading-and-installing-adobe-scripts.html?m=1
Photo of Drew Bristow

Drew Bristow

  • 8 Posts
  • 0 Reply Likes
Thanks Stephen, that helped! Managed to save off and install the script, it didn't actually do what I needed it to do, but at least now I know how to get scripts working :)