Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Need help for javascript : remove background with selected clippingpath

Participant ,
Feb 14, 2020 Feb 14, 2020

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

TOPICS
Actions and scripting
1.0K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Community Expert ,
Feb 15, 2020 Feb 15, 2020

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

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Feb 17, 2020 Feb 17, 2020

Hi Stephen, I'm going to download it and test with my action,

Thanks for your prompt answer ! 

Regards,

Christian

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Feb 29, 2020 Feb 29, 2020

wrong login!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 29, 2020 Feb 29, 2020

So, how did the script go?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 27, 2021 Dec 27, 2021

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/

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 29, 2021 Dec 29, 2021
LATEST

@Masoga22419522pn12 - Do you need to disclose any commercial affiliation with this site?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines