Copy link to clipboard
Copied
Hello,
Within my Photoshop script, I have a function to rasterize all layers. It's working well, but I noticed that processing this way ignores blend modes of layer groups...
function rasterizeAllLayers(){
runMenuItem(stringIDToTypeID("selectAllLayers"));
var d = new ActionDescriptor();
var r = new ActionReference();
r.putEnumerated(stringIDToTypeID("layer"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
d.putReference(stringIDToTypeID("null"), r);
d.putEnumerated(stringIDToTypeID("what"), stringIDToTypeID("rasterizeItem"), stringIDToTypeID("layerStyle"));
executeAction(stringIDToTypeID("rasterizeLayer"), d, DialogModes.NO);
runMenuItem(stringIDToTypeID("selectNoLayers"));
}
So I was wondering how to edit this function to rasterize each group instead of each layer. I'm guessing the new code should also includes some way to rasterize layers that don't belong to any group...
Thank you so much in advance for your time and help !
Oh ! I actually tried with the following :
var idrasterizeAll = stringIDToTypeID( "rasterizeAll" );
executeAction( idrasterizeAll, undefined, DialogModes.NO );
And it works perfectly ! I guess I should have tried something easier from the beginning...
Thank you again @Stephen Marsh for your time !
Copy link to clipboard
Copied
Can you post a before/after screenshot of the layers panel with a group selected before/after?
Do you have groups nested inside groups? Or is it just all top-level layers or groups that need to be rasterised?
If groups needs to be handled differently than layers, then how so?
Copy link to clipboard
Copied
Hello ! Thank you for your answer !
Nested groups can exist, but just taking care of top-level layers should be enough. I just don't want to lose some blend mode info.
Groups and isolated layers don't have to be treated differently.
I have done some tests and it seems like the blend mode of layer groups are applied, but it is actually blend mode of smart objects that are being ignored...
Also, when I use Layer > Rasterize > All Layers it actually does work the way I expect (blend modes are conserved), maybe there is a simpler way in the script code ?
Copy link to clipboard
Copied
Oh ! I actually tried with the following :
var idrasterizeAll = stringIDToTypeID( "rasterizeAll" );
executeAction( idrasterizeAll, undefined, DialogModes.NO );
And it works perfectly ! I guess I should have tried something easier from the beginning...
Thank you again @Stephen Marsh for your time !
Copy link to clipboard
Copied
Glad you got the result that you wanted!