Clipping path script

Hi all,
I would like to know if there is a script solution that automatticly aplies a clipping path throughout the whole document instead of selection each container by hand and choose Path 1.
Thanks
Phillip

Thanks Kasyan,
But i had a syntax error on yours. But in the topic i used the following script. It does what is need to do but Indesign crashes. Do you got any idea?
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[m];
        var linksIDs = d.links.everyItem().id;
        for(var n=0;n<linksIDs.length;n++){
            try{
                d.links.itemByID(linksIDs[n]).parent.parent.graphics[0].clippingPath.clippingType = ClippingPathType.PHOTOSHOP_PATH;
            }catch(e){};

Similar Messages

  • Clipping Path Script from lowres to hires

    Hello all. I am trying to find out if there is a script that can transfer a clipping path from a low resolution to a high resolution image. Perhaps from one folder of low res images to another folder of high resolution images of the same file name.
    Does anyone know of anything out there that can do this?
    Love to know.
    Thanks in advance!

    //This will copy all the paths from one document to another.
    #target photoshop
    app.bringToFront;
    var doc = app.documents[0];
    var doc2 = app.documents[1];
    activeDocument = doc;
    for( var q =0; q< doc.pathItems.length; q++ ) {
    copyPath( doc, doc2, doc.pathItems[q].name );
    activeDocument = doc;
    function copyPath( From, To, PathName){
    // Select source document
    activeDocument = From;
    // define function
    cTID = function(s) { return app.charIDToTypeID(s); };
    // Select path
    var desc = new ActionDescriptor();
    var ref = new ActionReference();
    ref.putName( cTID( "Path" ), PathName);
    desc.putReference( cTID( "null" ), ref );
    executeAction( cTID( "slct" ), desc, DialogModes.NO );
    // Copy path
    executeAction( cTID( "copy" ), undefined, DialogModes.NO );
    // Select destination document
    activeDocument = To;
    // Paste path
    executeAction( cTID( "past" ), undefined, DialogModes.NO );
    // Deselect path
    desc.putReference( cTID( "null" ), ref );
    executeAction( cTID( "Dslc" ), desc, DialogModes.NO );

  • Make a clipping Path while retaining it's appearance - script

    This has been a long standing wish of mine, and I've devised this script that "kind of" works.
    This script takes your selection, copies appearance attributes, and pastes them to the top object after clipping.
    It's currently limited in a few ways:
    • It does not accept compound paths as clipping object (and I don't know how to test for it, nor how to iterate down said compound clipping object to set each path object to clipping separately)
    • It only works with a single stroke or fill
    • It does not understand "no fill" it will fill your object with white instead *FIXED*
    • I'm hoping to use the "graphicStyle" property to copy the appearance, since that sounds way cleaner. But I don't understand how to.
    Even with these limitations, I bound this to CMD+7 using fastscripts - I'm *already* used to it working this way!
    Carlos Santos, thank you for writing the base of what became this script
    I'd be much obliged if anyone can help me out with any of those limitations / wishes.
    #target Illustrator
    //  script.name = Clip Retaining Color.jsx;
    //  script.required = at least two paths selected, top most path is the clipping mask;
    //  script.parent = Herman van Boeijen, www.nimbling.com // 30/11/13;
    //  *** LIMITED TO A SINGLE STROKE AND/OR FILL OF THE CLIPPING OBJECT***
    //  Here's hoping to use the "graphicStyles" property to copy over the appearance.
    if ( app.documents.length > 0 ) {
        idoc = app.activeDocument;
    }else{
        Window.alert("You must open at least one document.");
    var idoc = app.activeDocument; // get active document;
    var sel = idoc.selection; // get selection
    var selectedobjects = sel.length;
    function ClipRetainingColour(idoc){
        var lay = activeDocument.activeLayer
        if(lay.locked || !lay.visible){
            alert("Please select objects on an unlocked and visible layer,\nthen run this script again.");
            return;
        var igroup = lay.groupItems.add(); // add a group that will be the clipping mask group
        var imask = sel[0]; // the mask is the object on top
        var clipcolors = [];
        //copy appearance
        if(imask.filled)     {clipcolors.fillColor = imask.fillColor;}
        if(imask.stroked)    {
            clipcolors.stroked = imask.stroked;
            clipcolors.strokeWidth = imask.strokeWidth;
            clipcolors.strokeColor = imask.strokeColor;
        for (var i = selectedobjects-1 ; i > 0 ; i--){
            var ipath = sel[i];
            ipath.move(igroup, ElementPlacement.PLACEATBEGINNING);
        imask.move (igroup, ElementPlacement.PLACEATBEGINNING);
        //enable clipping
        igroup.clipped = true;
        imask.clipping = true;
        //paste appearance
        if(clipcolors.fillColor)    {imask.fillColor = clipcolors.fillColor;}
        if(clipcolors.stroked)      {
            imask.stroked = clipcolors.stroked;
            imask.strokeWidth = clipcolors.strokeWidth;
            imask.strokeColor = clipcolors.strokeColor;
    if (selectedobjects){
        ClipRetainingColour(idoc);

    *FIXED IT* - it's working!
    I bound this to CMD+7 using the excellent Fastscripts
    My clipping paths will be so much more colorful from now on!
    Yay!
    #target Illustrator
    #targetengine main
    //  script.name = Clip Retaining Color.jsx;
    //  script.required = at least two paths selected, top most path is the clipping mask;
    //  script.parent = Herman van Boeijen, www.nimbling.com // 07/12/13;
    //  *** LIMITED TO A SINGLE STROKE AND/OR FILL OF THE CLIPPING OBJECT***
    //  Big thanks to CarlosCanto and MuppetMark on the Adobe Illustrator Scripting Forums, and my pal Niels Bom for showing me the debugger (...)
    if ( app.documents.length > 0 ) {
        var curDoc = app.activeDocument;
    }else{
        Window.alert("You must open at least one document.");
    var sel = curDoc.selection; // get selection
    var selectedobjects = sel.length;
    var clipobject = sel[0]; // the mask is the object on top
    var clipcolors = [];
    //var pathItems = [];
    var container = curDoc.activeLayer;
    //Only if there are objects selected
    if (selectedobjects){
        if(container.locked || !container.visible){
            alert("Please select objects on an unlocked and visible layer,\nthen run this script again.");
        }else{
        ClipRetCol(curDoc);
    function ClipRetCol(curDoc){
        //IF COMPOUND CLIPPING PATH
            if (clipobject.typename === "CompoundPathItem") {
                //copy appearance
                sel = curDoc.selection;
                clipobject = sel[0].pathItems[0];
                CopyAppearance(clipobject);
                //MAKEMASK
                app.executeMenuCommand ('makeMask');
                //Since making the clipping path changed the selection, set variable for selection again
                sel = curDoc.selection;
                clipobject = sel[0];
                clipobject = clipobject.pageItems[0].pathItems[1];
                PasteAppearance(clipobject);
        //IF REGULAR PATH
            else {
                //copy appearance
                CopyAppearance(clipobject);
                //MAKEMASK
                app.executeMenuCommand ('makeMask');
                //paste appearance
                PasteAppearance(clipobject);
    }//ClipRetCol END
    function CopyAppearance(clipobject) {
                if(clipobject.filled)  {
                    clipcolors.fillColor = clipobject.fillColor;}
                if(clipobject.stroked) {
                    clipcolors.stroked = clipobject.stroked;
                    clipcolors.strokeWidth = clipobject.strokeWidth;
                    clipcolors.strokeColor = clipobject.strokeColor;}
    }//CopyAppearance END
    function PasteAppearance(clipobject) {
                if(clipcolors.fillColor)    {
                    clipobject.fillColor = clipcolors.fillColor;}
                if(clipcolors.stroked)      {
                    clipobject.stroked = clipcolors.stroked;
                    clipobject.strokeWidth = clipcolors.strokeWidth;
                    clipobject.strokeColor = clipcolors.strokeColor;}
    }//PasteAppearance END

  • Script to Sort Images with/without Clipping Paths?

    I've searched for a while and can't find a script that will sort a folder of images into two new folders that contain images with and without clipping paths. Anyone have or know of a script that will do this for me? I'd would greatly appreciate it. W7, PS CS5 32 and 64 bit.
    Thanks in advance!
    Andy

    Hi Andy, Mike has a function to check for clipping groups but requires the file to be open...
    // Function: clippingPathIndex
    // Description: Gets the index of the activeDocument's clipping path
    // Usage: clippingPathIndex()
    // Input: None
    // Return: Index as Integer. -1 if there is no clipping path
    function clippingPathIndex(){
         var ref = new ActionReference();
              ref.putEnumerated( charIDToTypeID("Dcmn"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
         var desc = executeActionGet( ref );
         var clippingPath =  desc.getObjectValue(charIDToTypeID("Clpg"));
         return  clippingPath.getInteger(charIDToTypeID("ClpI" ));
    I think it should be possible to check the files without opening them using Bridge, looking at the Photoshop File Format it says....
    If the file contains a resource of type 8BIM with an ID of 2999, then this resource contains a Pascal-style string containing the
    name of the clipping path to use with this image when saving it as an EPS file. 4 byte fixed value for flatness and 2 byte fill rule.
    0 = same fill rule, 1 = even odd fill rule, 2 = non zero winding fill rule. The fill rule is ignored by Photoshop.
    I will see if I have time today to put something together for you.

  • We need a script that will select clipping path for multiple images in indesign

    this is what we have, but it's not working:
    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[n].hasOwnProperty("clippingPath")){allGraphicsInDoc[n].clippingPath.c lippingType = ClippingPathType.PHOTOSHOP_PATH};
                allGraphicsInDoc[n].clippingPath.appliedPathName = "Path 1"; 

    this is what we have, but it's not working:
    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[n].hasOwnProperty("clippingPath")){allGraphicsInDoc[n].clippingPath.c lippingType = ClippingPathType.PHOTOSHOP_PATH};
                allGraphicsInDoc[n].clippingPath.appliedPathName = "Path 1"; 

  • Open pictures in Camera RAW and still have paths/clipping paths?

    Hello
    A big problem in Bridge is that I can not open my pictures in Camera RAW and still have my paths left. I work in a place where we get loads of product photos from many different companies and they almost always have a clipping path in it. Many of the pictures do we have to fix like colour, exposure etc and this is here Bridge comes in as the best solution to batchfix them. But now I have to take the long way through Photoshop. Is there a solution for this?, an update from Adobe or a script or something.
    Have a nice day!

    You do know that you can deconfigure Camera Raw from opening TIFFs and JPEGs, right?
    These are the settings I've chosen.  Done this way, JPEGs and TIFFs just open right into Photoshop, and their clipping paths would be intact.
    -Noel

  • JS that applies all clipping paths at once?

    Hello,
    I found the thread that contains the Applescript for this, but would love to have a Javascript that works the same. Anyone have or know of one for ID CS5 that will apply all clipping paths for a group of objects at once?
    Thanks in advance, as always
    Andy

    So it's all Photoshop paths? Yes, it ought to work. Perhaps you also need to specify which path ... Try with this line added:
    app.selection[i].images[0].clippingPath.appliedPathName = app.selection[i].images[0].clippingPath.photoshopPathNames[0];
    inside the try { .. } catch block. This ought to set the clipping path to the very first one in the file.
    It's important to do operations such as these inside a try .. catch block, because this construction shields you from errors. Without the try .. catch, the script would issue an error for the very first image it encounters that has zero paths (and thus "the first", which is numbered #0, is not valid) and then stop with the error alert. Now it will still signal the error but the 'error handler' (the second curly-bracketed part) ensures it does nothing with that information, and so it will ignore the error and continue with the next image.
    And yes, a Javascript needs to be saved as ".jsx" to work. Otherwise InDesign doesn't recognize it as a valid script.

  • Possible bug in Clipping Path - weird behaviour

    I've got a bunch of images with clipping paths. All the same size. They're all book covers from a series.
    Well I applied a clipping path to all of them.
    Some when placed into InDesign will place fine with the clipping path applied.
    Others will not - and the only difference I can see is that:
    The images that import with the clipping path applied - in Photoshop they are as Layer 1 and a Background Layer
    The images that import without a clipping path applied - in Photoshop they are flattened.
    Is that the same behaviour for everyone else - would you consider it a bug?
    InDesign CS5 - Fully Patched
    Photoshop CS2 - Fully Patched
    Photoshop File Type> TIFF

    Yeh I can apply the Path after placing - Jongware wrote me script to apply the photoshop path.
    But I just think it's odd behaviour.
    On most of them that are flattened - there is no option to Apply the Photoshop Clipping Path - it's greyed out.
    Then on the ones with layers - the option is selectable.

  • Clipping Path Assigner

    Hey All,
    I export high-res pdfs from indesign, and one of the biggest problems I have is during our preflight. Each image we have linked has to be "told" to use it's photoshop path, or else it will not use it upon export (leaving big white boxes).
    For every image, We have to choose Object - Clipping Path - Options: Then Photoshop Path, which automatically selects the available path, then Hit OK. And It won't let us do multiple images at once.
    So the question of a document script comes to mind. Would it be easy to create a script like this?:
    For each visible image:
        Do:
            Object - Clipping Path - Options
                Photoshop Path (will always be named "Path 1" (no quotes) if you need to specify a path name)
        End Do;
    End For;
    Popup - Finished
    I looked for an "Actions" feature of sorts, to record menu actions like photoshop, but it just doesn't exist. Thoughts?
    (I have pretty much zero scripting knowledge, so either a 'for dummies' instruction, or someone to help is in order...)

    Just select the frame and move it...
    What sort of difficulty are you having?

  • [CS2] [JS]  Apply photoshop clipping path

    Hi,
    Does anyone know how to apply the photoshop clipping path to all images in a document, If the image contains one ?
    I can't find a clipping path property of the graphic object in the reference manual...
    The loop structure itself is not a problem...
    for (var j = app.activeDocument.allGraphics.length - 1; j >= 0; j--) {
    Thanx
    Tim

    Hi Peter,
    I've just tried using...
    for (var j = app.activeDocument.allGraphics.length - 1; j >= 0; j--) {
    try
    var theEPSItem = app.activeDocument.allGraphics[j];
    var theClippingPath = theEPSItem.clippingPath;
    if ( ( theClippingPath.clippingType != ClippingPathType.photoshopPath ) &&
    ( theClippingPath.photoshopPathNames.length > 0 ) )
    theClippingPath.clippingType = ClippingPathType.photoshopPath;
    catch ( e )
    ... something strang happens when running the script. The clipping path settings of the EPS-files are changed and are correct. However, the result is not yet visible. So I still have to open the clipping path settings menu and click on the ok button... Then the result is displayed.
    Any idea's ?
    Tim

  • Need to find if Images applied clipping path(detect Edges)

    Hi Scripters,
    How to find Images applied with clipping path(detect Edges) in Indesign document.
    Could anybody please share a code/script with me.
    Yours,
    Jerome

    No problem -- a document's "allGraphics" property lists all of the imported graphics in the document. Just check each of them one by one. This little script alerts you with the name:
    for (img=0; img<app.activeDocument.allGraphics.length; img++)
    if (app.activeDocument.allGraphics[img].clippingPath.clippingType == ClippingPathType.DETECT_EDGES)
      alert (app.activeDocument.allGraphics[img].itemLink.name);

  • Clipping Path info

    Hello guys,
    Again I am coming with a need for help now.
    I need a automation or plugin or script for spotting error on Photoshop paths.
    I tried photoshop scripts, searched for options in indesign and other softwares like pdf preflights. I couldn't find any idea.
    I will be working with lots of images more or less 100 images a day. I want to get the infos of clipping paths created in photoshop like path name, clipping flatness and open paths if any, all details in a log file or an log display window. Not an issue whether it works inside photoshop or outside like automation along with other softwares. But I simply need to spot the open path and clipping path name exactly.
    Need help!!!
    Thank you in advance!
    Regards,
    Purushoth...

    function clippingPathIndex(){// returns -1 if no clipping path
      var ref = new ActionReference();
      ref.putEnumerated( charIDToTypeID("Dcmn"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
      var desc = executeActionGet(ref);
      return desc.getObjectValue(stringIDToTypeID('clippingPathInfo')).getInteger(stringIDToTypeID('clippingPathIndex'));};
    function getClippingPathFlatness(){ 
      var ref = new ActionReference()
      ref.putEnumerated( charIDToTypeID("Dcmn"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
      var desc = executeActionGet(ref);
       if( desc.getObjectValue(stringIDToTypeID('clippingPathInfo')).getInteger(stringIDToTypeID('clippingPathIndex')) != -1  ){
         return (desc.getObjectValue(stringIDToTypeID('clippingPathInfo')).getInteger(stringIDToTypeID('clippingPathFlatness'))/65536);
      }else{
        return -1;
    var pathIndex = clippingPathIndex();
    if(pathIndex != -1 ){
      var pathName = app.activeDocument.pathItems[pathIndex].name;
      var flatness = getClippingPathFlatness();
      var closed = app.activeDocument.pathItems[pathIndex].subPathItems[0].closed;
      alert(pathName+': '+flatness+': '+closed);

  • Reset multiple images' clipping paths to "None"

    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

    I'm not sure.
    Isn't it a collection up to this:
    docs[l].rectangles.everyItem().images.everyItem()
    from this point it's got a length:
    docs[l].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[l].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

  • How do I transform a clipping path and layer at same time?

    I have a bunch of images with clipping paths that need to be altered. Most images need skewed or distorted, and I can't figure out how to transform the path at the same time I transform the layer - so I do not have to create new paths. Thanks
    Working in Photoshop CS2

    I’m afraid You will have to employ a workaround.
    I would recommend applying the Path as a Vector Mask to the Layer (with the Path selected command-click on the Add Layer Mask-button in the Layers-panel), then transforming, subsequently duplicating the Vector Mask and removing it from the Layer.
    Or copy-paste it into the existing Clipping Path and then remove it.
    Some part of the procedure may be automate-able with Actions or Scripts and hopefully it will still save at least some time.

  • Help! Getting clipping paths back on exported lightroom images!

    A bit of a problem.
    I have 22,000 images, half of which were colour corrected in lightroom, but all 22,000 were exported from lightroom.
    So, out of the 22,000 exported files I don't know which ones were colour corrected or not, which is not important until I realise that non of my clipping paths stayed with the exported files.
    There were clipping paths on about 6,000 of these images.
    So first, is there any way of finding from the exported files which ones were worked on in lightroom?
    Secondly, is there a clever scripty way of bringing a clipping path from one photoshop file to another photoshop file (pixel perfect).... preferbly maybe having a folder full of doner files that have the clipping paths that a script gets their clipping paths and puts them onto the photoshop files in the second folder (the two folders will have files with same file names?)

    Unless you specifically set Lr to overwrite the original export creates anew file, which doesn't include layers, clipping paths, Smart Objects and a bunch of other Ps stuff. Hopefully, your original with clipping paths is still around because that's the only way you're getting them back.
    BTW: as you've discovered, editing an image in Lr after t's been edited in Ps is leaving yourself open to a world of hurt, especially when the image includes editing features that Lr doesn't support.

Maybe you are looking for

  • Date Variable in Carryover jobs

    Is there a way to lock a date variable, in the parameter, for specific jobs that occasionally carryover?  The goal is to keep the date from flipping when a few specific jobs carryover.                  

  • BBC Radio is no longer available on BT Internet Ra...

    I am receiving a message on each BBC station on my BT Internet Reciva radio device that Real Media stream is no longer available from the end of May. Can anyone advise how I get to use my internet radio again?

  • TMSADM: Initial password expired

    Dear community, I've a urgent question, because the SAP support hasn't answered yet and I have got to fix the problem. Because of security reasons we changed the following instance Parameters: login/password_max_new_valid = 1 (The initial password of

  • Making invoice for the open items

    Dear Gurus, My requirement is, user has created a sale order, suppose say for 100 qty and the delivered qty is only 50 because unavailabilty of the material,and the invoice has already created for these 50 qty. Now user wants to create the delivery a

  • Access Central SLD Error

    Hi Experts, We are using the SLD SOLMAN and we and the ideia is to use it as Central SLD. In order to allowed PI indentifed the Central SLD we must appllied few oss notes like; 939592, 768148 and 720717, but much as we try it to import we got few err