I'm doing some research before I write a script for Photoshop CS3. I want to write the script in Photoshop with JavaScript.
I have looked through the Photoshop JavaScript Guide, but I can't find any way to get layer style information for a layer (stroke, gradient, outer glow, etc).
There is a way to set layer styles, but I haven't been able to find anything that lets you get the information.
I only have Photoshop CS3, so I'm looking for a solution that will suit that.
Open the Adobe ExtendScript Toolkit. In the menu go to Help > Object-Model Viewer (or similar, mine is in german).
Inside the Object-Model browser in the "Browser" side-tab select Photoshop. Now you can search with the search field on the top right corner.
See the image below for ArtLayer
's deifinition and ArtLayer.applyStyle()
:
http://i.stack.imgur.com/UEmj6.png
Search around, it's much better than adobe's documentation.
I hope I am not too late, I reat your post, because I had the same problem and I found a solution on http://www.rags-int-inc.com/PhotoTechStuff/CollageTemplate/index.html. This guy has a script called "Layer Effects Options". You can download the source at the bottom.
Well it's only a panel to apply Effects, but if you browse through the code you can extract what you need.
Here is a little exsample (what I needed) for applying an stroke effect an the active layer
function newStrokeEffect(strokeSize, strokeColor, strokePosition) {
var effectDescriptor = new ActionDescriptor();
var effectColor = new ActionDescriptor();
var strokeOpacity = 100.0; // 0 - 100 %
var strokeBlend = "Nrml"; // Normal[Nrml], ColorBurn[CBrn], SoftLight[SftL}, Color[Clr ]
effectDescriptor.putBoolean(charIDToTypeID("enab"), true);
effectDescriptor.putEnumerated(charIDToTypeID("Styl"), charIDToTypeID("FStl"), charIDToTypeID(strokePosition));
effectDescriptor.putEnumerated(charIDToTypeID("PntT"), charIDToTypeID("FrFl"), charIDToTypeID("SClr"));
effectDescriptor.putEnumerated(charIDToTypeID("Md "), charIDToTypeID("BlnM"), charIDToTypeID(strokeBlend));
effectDescriptor.putUnitDouble(charIDToTypeID("Opct"), charIDToTypeID("#Prc"), strokeOpacity);
effectDescriptor.putUnitDouble(charIDToTypeID("Sz "), charIDToTypeID("#Pxl"), strokeSize);
effectColor.putDouble(charIDToTypeID("Rd "), strokeColor.rgb.red);
effectColor.putDouble(charIDToTypeID("Grn "), strokeColor.rgb.green);
effectColor.putDouble(charIDToTypeID("Bl "), strokeColor.rgb.blue);
effectDescriptor.putObject(charIDToTypeID("Clr "), charIDToTypeID("RGBC"), effectColor);
return(effectDescriptor);
}
var tmpC = new SolidColor();
tmpC.rgb.hexValue = "FF00FF";
var layerOptions = new ActionDescriptor();
var refr01 = new ActionReference();
var layerProperties = new ActionDescriptor();
layerOptions.putUnitDouble(charIDToTypeID("Scl "), charIDToTypeID("#Prc"), 400.0);
var layerEffects = newStrokeEffect(2, tmpC, "InsF");
layerOptions.putObject(charIDToTypeID("FrFX"), charIDToTypeID("FrFX"), layerEffects);
refr01.putProperty(charIDToTypeID("Prpr"), charIDToTypeID("Lefx"));
refr01.putEnumerated(charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt"));
layerProperties.putReference(charIDToTypeID("null"), refr01);
layerProperties.putObject(charIDToTypeID("T "), charIDToTypeID("Lefx"), layerOptions);
try {
executeAction(charIDToTypeID("setd"), layerProperties, DialogModes.NO);
} catch(ex) {
if (ex != "Error: User cancelled the operation")
alert(scriptName + " newLayerEffect() exception caught? line[" + ex.line + "] " + ex);
}
I did not know the exact meaning of all lines (it is mainly copy & paste), but it works :-) (only tested it on Photoshop CS5)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With