I’m trying to write a script in which any open image is made to have a rounded corner frame.
The physical way of doing things that I’m tryingto translate would be
Select all
Modify Border by 20 pixels
Inverse selection
Modify Selection > Feather by 5pix
Enter quick mask
Adjust with curves (points (0,227), (255,227)
Exit Quick mask
convert background layer to a layer
apply the selection as a layer mask.
I would like to perform this without the use of GUI scripting and as little javascript from the JS listener plugin as possible.
I’ve gotten thus far:
set Slect2Channel to "var idDplc = charIDToTypeID( "Dplc" );
var desc3 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref1 = new ActionReference();
var idChnl = charIDToTypeID( "Chnl" );
var idfsel = charIDToTypeID( "fsel" );
ref1.putProperty( idChnl, idfsel );
desc3.putReference( idnull, ref1 );
var idNm = charIDToTypeID( "Nm " );
desc3.putString( idNm, "Border Channel" );
executeAction( idDplc, desc3, DialogModes.NO );
"
– enable GUI short name for Photoshop in case I need to do key commands
tell application “System Events”
set PSProcess to name of application id “com.adobe.Photoshop”
end tell
tell application “Adobe Photoshop CS4”
activate
change mode of current document to RGB
-- make sure the document is flattened
tell current document
try
flatten
end try
-- make the background layer into a regular layer
if background layer exists then
set background layer of art layer 1 to false
end if
end tell
set z to 0.1
tell application "Adobe Photoshop CS4"
activate
tell current document
set theWidth to width
set theheight to height
select region {{z, z}, {theWidth - z, z}, {theWidth - z, theheight - z}, {z, theheight - z}} feather amount 10 without antialiasing
-- I didn't want to but I can not figure out how to convert a selection to a channel
do javascript Slect2Channel show debugger on runtime error
(* I can't seem to be able to select a channel and then apply a curve
adjust channel "Border Channel" of the current document using curves ¬
with options {class:curves, curve points:{{0, 0}, {255, 147}}}
*)
end tell
end tell
end tell
Any help is much appreciated.