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

Reset multiple images' clipping paths to "None"

Guest
Dec 19, 2012 Dec 19, 2012

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

TOPICS
Scripting

Views

5.2K

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
Community Expert ,
Dec 19, 2012 Dec 19, 2012

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.

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
Advisor ,
Dec 20, 2012 Dec 20, 2012

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

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
Guest
Dec 20, 2012 Dec 20, 2012

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

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
Community Expert ,
Dec 20, 2012 Dec 20, 2012

Copy link to clipboard

Copied

Remove the space between the hash sign and target

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
Guest
Dec 20, 2012 Dec 20, 2012

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

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
Enthusiast ,
Dec 20, 2012 Dec 20, 2012

Copy link to clipboard

Copied

Hi vamitul,

we've got a array here:

docs.rectangles.everyItem().images.everyItem().clippingPath

😉

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
Advisor ,
Dec 20, 2012 Dec 20, 2012

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:

http://www.indiscripts.com/post/2010/06/on-everyitem-part-1

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
Enthusiast ,
Dec 21, 2012 Dec 21, 2012

Copy link to clipboard

Copied

I'm not sure.

Isn't it a collection up to this:

docs.rectangles.everyItem().images.everyItem()

from this point it's got a length:

docs.rectangles.everyItem().images.everyItem().clippingPath

So this works here:

#target indesign

function main() {

          var docs = app.documents.everyItem().getElements(),

                    l = docs.length;

          while(l--) {

                    try {

                            cPaths =  docs.rectangles.everyItem().images.everyItem().clippingPath;

                            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

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
Community Expert ,
Dec 21, 2012 Dec 21, 2012

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

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
Advisor ,
Dec 21, 2012 Dec 21, 2012

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%.

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
Community Expert ,
Dec 21, 2012 Dec 21, 2012

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

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
Community Expert ,
Dec 21, 2012 Dec 21, 2012

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?

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
Community Expert ,
Dec 21, 2012 Dec 21, 2012

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

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
Advisor ,
Dec 21, 2012 Dec 21, 2012

Copy link to clipboard

Copied

does it work? Still can't test.. 48%..

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
Community Expert ,
Dec 21, 2012 Dec 21, 2012

Copy link to clipboard

Copied

@Vamitul – it does… 🙂

Uwe

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
Community Expert ,
Dec 21, 2012 Dec 21, 2012

Copy link to clipboard

Copied

Seems to work in CS6...

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
Community Expert ,
Dec 21, 2012 Dec 21, 2012

Copy link to clipboard

Copied

@Peter – it should work all the way down to CS4.

Uwe

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
Community Expert ,
Dec 21, 2012 Dec 21, 2012

Copy link to clipboard

Copied

Super.

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
Guest
Dec 21, 2012 Dec 21, 2012

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

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 ,
Sep 10, 2015 Sep 10, 2015

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

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
Community Expert ,
Dec 21, 2012 Dec 21, 2012

Copy link to clipboard

Copied

Thanks.

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
Explorer ,
Aug 10, 2017 Aug 10, 2017

Copy link to clipboard

Copied

LATEST

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.

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