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

clipping path script for selected images indesign

New Here ,
Apr 08, 2020 Apr 08, 2020

Copy link to clipboard

Copied

Hello everybody.

I'm looking for someone that might be able to help me with my inquiry – which might be as "easy" as adapting the following script.

I would need a script that automatically chooses the photoshop clipping mask for all SELECTED IMAGES IN INDESIGN.
The script I found comes pretty close but it automatically clips ALL images in a document which is almost what I want but it'd help me a lot if I would be able to choose the images I want to clip first and then run the script for only the selected images.

Is there anyone here that might be able to fix this Problem for me?

This is the script I found and tested:

var allImages = app.selection[0].allGraphics;
app.selection[0] = null;
l = allImages.length;
while(l--)
{
var currImage = allImages[l];
var pathName = currImage.clippingPath.photoshopPathNames[0];
if(pathName != undefined) currImage.clippingPath.appliedPathName = pathName;
}

 

THANKS SO MUCH

in advance my good JAVA-knowing-people ^^




 

TOPICS
Scripting

Views

1.7K

Translate

Translate

Report

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

correct answers 1 Correct answer

Participant , Apr 09, 2020 Apr 09, 2020

hello, try this:

function main(){
	for(var i = 0; i < cur_obj.length; i++){
		try{
			if(typeof cur_obj[i].graphics[0].clippingPath.photoshopPathNames[0] != 'undefined'){
				cur_obj[i].graphics[0].clippingPath.appliedPathName = cur_obj[i].graphics[0].clippingPath.photoshopPathNames[0]
			}
		}
		catch(e){}
	}
}

try{var cur_obj = app.selection}
catch(e){exit()}

if(typeof cur_obj != 'undefined' && cur_obj.length != 0){
	app.doScript('main()', ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIR
...

Votes

Translate

Translate
Participant ,
Apr 09, 2020 Apr 09, 2020

Copy link to clipboard

Copied

hello, try this:

function main(){
	for(var i = 0; i < cur_obj.length; i++){
		try{
			if(typeof cur_obj[i].graphics[0].clippingPath.photoshopPathNames[0] != 'undefined'){
				cur_obj[i].graphics[0].clippingPath.appliedPathName = cur_obj[i].graphics[0].clippingPath.photoshopPathNames[0]
			}
		}
		catch(e){}
	}
}

try{var cur_obj = app.selection}
catch(e){exit()}

if(typeof cur_obj != 'undefined' && cur_obj.length != 0){
	app.doScript('main()', ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, 'clip')
}

 

Votes

Translate

Translate

Report

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 ,
Apr 09, 2020 Apr 09, 2020

Copy link to clipboard

Copied

LATEST

Hello SychevKA,

 

It seems to work properly 🙂

Thank you so much!! Yay.

Cheers

Votes

Translate

Translate

Report

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