Copy link to clipboard
Copied
Hi all,
I'd like to automate remove background for image from selected clipping path name for example "Path1".
I made action script that works, but it stopped if image have no clipping path "Path1". Because I have hundred of images, and some of them need to have bacground removal, others not. With action script, I cannot say to photoshop if there's no clipping path "Path1", it doens't matter, do nothing close the image and continue to others, you see what I mean ? So I think it is possible with Javascript, but I don't know how to do it.... If I could have a little help, I appreciate,
Thanks in advance,
Christian
Copy link to clipboard
Copied
The following conditional script code (thanks to Chuck, the syntax was killing me) will run a specified action if there is a path named "Path 1" in the file.
Replace "Molten Lead" with your action name and "Default Actions.atn" with your action set name.
// Play specified action if 'Path 1' exists
// Special thanks to Chuck Uebele for the majority of the following code
// Sript for deleting path
//community.adobe.com/t5/photoshop/sript-for-deleting-path/m-p/10819422
#target photoshop
// Save the current dialog display settings
var savedDisplayDialogs = app.displayDialogs;
app.displayDialogs = DialogModes.NO;
var doc = app.activeDocument;
var pLen = doc.pathItems.length
var pArray = [];
var actionName = "Molten Lead"; // Action to run
var actionSet = "Default Actions.atn"; // Action set to run
for (var i = 0; i < pLen; i++) {
pArray.push(doc.pathItems[i].name)
}
for (var i = 0; i < pLen; i++) {
var curPath = doc.pathItems.getByName(pArray[i]);
if (curPath.name == "Path 1") {
// Play action if Path 1 exists
app.doAction(actionName,actionSet);
} else {
// Do something else
}
}
// Restore the dialogs
app.displayDialogs = savedDisplayDialogs;
https://prepression.blogspot.com/2017/11/downloading-and-installing-adobe-scripts.html
Copy link to clipboard
Copied
Hi Stephen, I'm going to download it and test with my action,
Thanks for your prompt answer !
Regards,
Christian
Copy link to clipboard
Copied
wrong login!
Copy link to clipboard
Copied
So, how did the script go?
Copy link to clipboard
Copied
There are several ways to remove the background on an image. One of them is the use of online applications more https://ogasite.com/edit-background/
Copy link to clipboard
Copied
@Masoga22419522pn12 - Do you need to disclose any commercial affiliation with this site?
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more