Skip to main content
Participant
June 10, 2025
Question

Set InDesign image Clipping Path to NONE

  • June 10, 2025
  • 1 reply
  • 325 views

I'm new to scripts in InDesign, and need a script to switch selected images Clipping Path to type NONE.

 

I have found a great script that switches the clipping path on if there is a photoshop clipping mask saved in the image, but I don't know enough to back engineer it. Any help greatly appreciated.

 

Here is the script to switch clipping paths on:

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')
}

1 reply

brian_p_dts
Community Expert
Community Expert
June 10, 2025

In your loop, just need this line, probably wrapped in a try/catch block.

 

cur_obj[i].graphics[0].clippingPath.clippingType = ClippingPathType.NONE;

Participant
June 10, 2025

Thank you Brian,

I have absolutely no experience in writing scripts. Would you be able explain where I would insert that and what I would need to remove from the original script?

brian_p_dts
Community Expert
Community Expert
June 10, 2025

If you just want to do it for a selection, you can use this one line (assuming the containing rectangle, not the image itself, is selected). 

 

try { app.selection[0].graphics[0]..clippingPath.clippingType = ClippingPathType.NONE; } catch(e) {}

If you want to do it for all graphics in a doc, then you'd use that loop you posted with this change: 

function main(){
var graphics = app.activeDocument.allGraphics;
for(var i = 0; i < graphics.length; i++){
try{
graphics[i].clippingPath.clippingType = ClippingPathType.NONE;
}
}
catch(e){}
}
}