Copy link to clipboard
Copied
Hi there,
I've been making actions for a while, but I have a need for something more advanced than what actions can achieve.
Basically I have a lot of images with multiple paths. What i'd like to do is have a script that selects the top path and converts it to a clipping path. Could someone point me in the right direction? I've found a few muddled examples by googling, but some either don't work or I can't make any sense out of. I'm hoping to add this script as part of an action so I don't want it to ask for a folder location, just to affect the document that is currently open.
Any help would be greatly appreciated and maybe I can learn some JS along the way!
Thanks
Jason
Copy link to clipboard
Copied
This problem was my first need for a
PS script. If I recall correctly actions
record the name and not index.
When working with supplied images
from all over the place...
You will need script to do this part.
Sent from my iPhone
Copy link to clipboard
Copied
Hi Mark,
Yes that's exactly the case. Because I'm working with a variety of images the paths aren't named the same across different documents, so I'll need to select the index of the path to ensure I select the first path (i'm assuming it will be 0) but having little JS knowledge i'm really struggling.
Thanks
Jason
Copy link to clipboard
Copied
#target photoshop
processPaths();
// Use clipping path else use path 1 even if its a work path
function processPaths() {
var i, count = app.activeDocument.pathItems.length;
if ( count >= 2 ) {
for ( i = 0; i < count; i++) {
if ( app.activeDocument.pathItems.kind == PathKind.CLIPPINGPATH ) {
app.activeDocument.pathItems.makeClippingPath(0.5);
};
};
};
if ( count == 1 ) {
if ( app.activeDocument.pathItems[0].kind == PathKind.WORKPATH ) {
app.activeDocument.pathItems[0].name = "Clipping Path"
};
app.activeDocument.pathItems[0].makeClippingPath(0.5);
};
};