Copy link to clipboard
Copied
In InDesign CS4, is there a way to check all images at once and reset their clipping paths to "none?" I work on catalogs that have several thousand photos (tif, Photoshop, and a few jpg files) in each one. We break the catalogs into approximately 10 sections/documents then organize them into a book file/palette, so there are only a few hundred images in each section/document. Originally a clipping path was applied to the photos (either a Photoshop clipping path or a "detect edges" path), but we now save them with transparency, so I'd like to be able to turn them all of at once (especially the "detect edges" paths).
Any suggestions? I know basically nothing about scripting, so writing a script wouldn't work in this case.
I appreciate any help...
Thanks,
Lloyd
Copy link to clipboard
Copied
I've moved this to the scripting forum. You may not know scripting, but these guys do, and I'm pretty sure one of them will help you out.
Copy link to clipboard
Copied
here you go:
# target indesign
function main() {
var docs = app.documents.everyItem().getElements(),
l = docs.length;
while(l--) {
try {
docs
.rectangles.everyItem().images.everyItem().clippingPath.clippingType = ClippingPathType.NONE; } catch(e) {
alert(e);
}
alert('All done! You can go outside and play now!')
}
}
app.doScript('main()', undefined, undefined, UndoModes.entireScript, 'Reset Clipping');
it works for all opened indesign files. I don't think it will work if you gave grouped pictures, buut i'm a bit short on time to tweak it now
Copy link to clipboard
Copied
Vamitul,
WOW, that was quick and, apparently, easy. My only question is: what do I do with it? I copied the text and pasted it into a WordPad document (yes, unfortunately I'm working in Windows) then saved it using a .jsx extension. I then loaded it into the Scripts folder within InDesign and it showed up in the palette ... smooth! But when I tried it, I got an error message that said:
JavaScript Error!
Error Number: 8
Error String: Syntax error
File: C:\Documents and Settings\[my folder]\Application Data\Adobe\InDesign\Version 6.0\en_GB\Scripts\Scripts Panel\delete_clipping_paths.jsx
Line 1:
Source: # target indesign
What did I do wrong?
Lloyd
Copy link to clipboard
Copied
Remove the space between the hash sign and target
Copy link to clipboard
Copied
Larry,
Thanks for the info. I removed the space, and the script ran, but it didn't do anything. All the images that had clipping paths applied to them still have them. I even added a few to check and they weren't removed.
I appreciate the help, though.
Lloyd
Copy link to clipboard
Copied
Hi vamitul,
we've got a array here:
docs
😉
Copy link to clipboard
Copied
actualy (aldo the Adobe's documentation says it's an array), it is not.
check out Marc's fantastic post on the subject:
Copy link to clipboard
Copied
I'm not sure.
Isn't it a collection up to this:
docs
from this point it's got a length:
docs
So this works here:
#target indesign
function main() {
var docs = app.documents.everyItem().getElements(),
l = docs.length;
while(l--) {
try {
cPaths = docs
pl = cPaths.length;
while(pl--){
cPaths[pl].clippingType = ClippingPathType.NONE;
}
} catch(e) {
alert(e);
}
alert('All done! You can go outside and play now!')
}
}
app.doScript('main()', undefined, undefined, UndoModes.entireScript, 'Reset Clipping');
Have a nice day
Hans-gerd Claßen
Copy link to clipboard
Copied
Hm. For now we target only rectangle objects put straight on spreads. That would not affect images in other shapes, left alone images that are anchored or inside cells of tables.
If we assume that all images are showing up in the links panel, we could target really all images in the document from there.
Here an example that sets back all clipping paths of all images regardless of their container types of all open documents:
app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll;
app.doScript(resetAllClippingPathsToNone, ScriptLanguage.JAVASCRIPT, [], UndoModes.ENTIRE_SCRIPT, "Reset all Clipping Paths of all open Documents to None");
function resetAllClippingPathsToNone(){
var allOpenDocs = app.documents;
for(var m=0;m<allOpenDocs.length;m++){
var d=allOpenDocs
; var linksIDs = d.links.everyItem().id;
for(var n=0;n<linksIDs.length;n++){
try{
d.links.itemByID(linksIDs
).parent.parent.graphics[0].clippingPath.clippingType = ClippingPathType.NONE; }catch(e){};
};
};
};
Tested in InDesign CS5.5, but should work in InDesign CS4 as well.
Uwe
Copy link to clipboard
Copied
hm.. maby use document.allGraphics, iterate, test each if hasownProperty("clippingPath"); if yes, reset.
I hate my computer right now; indesign is working on some files for an hour or so, and it's not even at 20%.
Copy link to clipboard
Copied
@Vamitul – yeah, that would include pasted graphics, too…
Thank you to remind me that we could test for hasOwnProperty("clippingPath").
That would work very well:
app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll;
app.doScript(resetAllClippingPathsToNoneAllDocs, ScriptLanguage.JAVASCRIPT, [], UndoModes.ENTIRE_SCRIPT, "Reset all Clipping Paths of all Open Documents to None");
function resetAllClippingPathsToNoneAllDocs(){
var allOpenDocs = app.documents;
for(var m=0;m<allOpenDocs.length;m++){
var d=allOpenDocs
; var allGraphicsInDoc = d.allGraphics;
for(var n=0;n<allGraphicsInDoc.length;n++){
if(allGraphicsInDoc
.hasOwnProperty("clippingPath")){allGraphicsInDoc .clippingPath.clippingType = ClippingPathType.NONE}; };
};
};
Uwe
Copy link to clipboard
Copied
I know the OP was interested in turning off clipping paths in many files at once, but I think it would be more useful for some people if the script were limited to just the active file. How hard is that to achieve?
Copy link to clipboard
Copied
@Peter – not hard at all:
app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll;
app.doScript(resetAllClippingPathsToActiveDoc, ScriptLanguage.JAVASCRIPT, [], UndoModes.ENTIRE_SCRIPT, "Reset all Clipping Paths of the Active Document");
function resetAllClippingPathsToActiveDoc(){
var d=app.activeDocument;
var allGraphicsInDoc = d.allGraphics;
for(var n=0;n<allGraphicsInDoc.length;n++){
if(allGraphicsInDoc
.hasOwnProperty("clippingPath")){allGraphicsInDoc .clippingPath.clippingType = ClippingPathType.NONE}; };
};
Uwe
Copy link to clipboard
Copied
does it work? Still can't test.. 48%..
Copy link to clipboard
Copied
@Vamitul – it does… 🙂
Uwe
Copy link to clipboard
Copied
Seems to work in CS6...
Copy link to clipboard
Copied
@Peter – it should work all the way down to CS4.
Uwe
Copy link to clipboard
Copied
Super.
Copy link to clipboard
Copied
I guess I should have said in my original question (although I originally did NOT ask the question in this "scripting" forum) that all the images are anchored to the text and even though most are in square or rectangular frames, a few might be in round frames.
Even so, I tried the script in 11.Laubender and it seemed to have worked.
I appreciate all the input and help.
Happy hiolidays!
Lloyd
Copy link to clipboard
Copied
I have a variation on this problem.
I need to be able to choose a large number of image boxes on a page and change all the clipping paths specified from Path 1 to Path 1 copy.
My company does a lot of catalogues for a particular client and it takes hours to change all of them by hand. Can this be done and can it be applied to only items I have selected rather than a global change through the job?
Cheers!
Brenton
Copy link to clipboard
Copied
Thanks.
Copy link to clipboard
Copied
This works great, but can we get one to just remove clipping paths from SELECTED frames containing images etc?
Thanks again, almost there towards having the perfect clipping path removal script.
Thanks everyone.