问题
I am trying to load my selection like the picture below, where the marching ants go around the edges of my object:
However, i only know how to select the whole layer using this code:
doc.selection.selectAll();
Also, i want to contract the selection by a few pixels and paste it into a channel layer. Any help with that would be great but the most important thing is how to load the selection in the first place.
回答1:
If you look up in the Javascript Scripting Reference document in your Photoshop install directory you'll see that there are a number of methods available on the selection object to do what you need.
var doc = app.activeDocument;
var channelRef = doc.channels.getByName("TestSelection");
doc.selection.load(channelRef, SelectionType.REPLACE);
doc.selection.contract(new UnitValue(20, 'px'));
来源:https://stackoverflow.com/questions/25665405/how-to-load-a-selection