color overlay to specific layer(s) jsx script
hello! i'm new to jsx scripting, although i have fair experience with javascript. now my photoshop version is old and so i'm not using uxp. i want to loop through all layers and apply various blending options (are those called fx by any chance?) like color overlay, for instance. after a bit of googling, i found a solution that seems to be working:
applyColorOverlay(
{
r: 255,
g: 0,
b: 0,
})
function applyColorOverlay(color)
{
var desc6 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putProperty(charIDToTypeID('Prpr'), charIDToTypeID('Lefx'));
ref1.putEnumerated(charIDToTypeID('Lyr '), charIDToTypeID('Ordn'), charIDToTypeID('Trgt'));
desc6.putReference(charIDToTypeID('null'), ref1);
var desc7 = new ActionDescriptor();
var desc8 = new ActionDescriptor();
desc8.putBoolean(charIDToTypeID('enab'), true);
desc8.putBoolean(stringIDToTypeID('present'), true);
desc8.putBoolean(stringIDToTypeID('showInDialog'), true);
desc8.putEnumerated(charIDToTypeID('Md '), charIDToTypeID('BlnM'), charIDToTypeID('Nrml'));
var desc9 = new ActionDescriptor();
desc9.putDouble(charIDToTypeID('Rd '), color.r);
desc9.putDouble(charIDToTypeID('Grn '), color.g);
desc9.putDouble(charIDToTypeID('Bl '), color.b);
desc8.putObject(charIDToTypeID('Clr '), charIDToTypeID('RGBC'), desc9);
desc8.putUnitDouble(charIDToTypeID('Opct'), charIDToTypeID('#Prc'), 100.000000);
desc7.putObject(charIDToTypeID('SoFi'), charIDToTypeID('SoFi'), desc8);
desc6.putObject(charIDToTypeID('T '), charIDToTypeID('Lefx'), desc7);
executeAction(charIDToTypeID('setd'), desc6, DialogModes.NO);
};
i got that from here:
https://graphicdesign.stackexchange.com/questions/120623/how-to-change-in-photoshop-script-color-of-smart-object-layer-or-rasterized-ima
now for one it's totally gibbrish for me, and for second, i want to add it to multiple layers based on my defined logic, so those leyers i want to put effects on won't be pre-selected, and this seems to be applying on a single and selected layer only.
so i'm looking forward to a solution to achieve that. thanks!
