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.

Similar Messages

  • 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"; 

  • [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

  • See all motion paths at once

    I have a slide that has multiple elements moving around. It would be super-helpful if I could see all the motion paths at one time to adjust positions and alignment. Is this possible?

    I totally understand what you mean, but AFAIK that is not possible

  • 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);

  • How do you apply color fx to all clips in timeline?

    and also how can you fast scroll along the timeline? when i use the mouse ball it doesnt scrub left or right past what is in view to get to end or beginning of timeline?

    To answer the question in the header, its too bad there is no "apply to all" button in the ColorFX controls. There may not be a way to do it, but try to select all the clips on the timeline (quickie group or simply select all in either the shots bin or use a select first clip / shift_click on the last clip in the timeline and then double click on the saved FX tree in the selection menu. Might not work. If there are no other corrections in the timeline yet, you could save the COLORFX tree as a grade and apply that to all clips in the normal fashion.
    As far as scrolling/scrubbing in the timeline, a) you are operating a "three-button" mouse, right? and b) combinations of the buttons, dragging, etc., is the way to expand/contract, scrub and scroll through the timeline. Its covered in the book. It has become a muscle memory for me, so miming the action here at my word processor, I'm thinking a right button drag expands and contracts the timeline and its a middle button drag that scrolls the timeline, while its a left button click that scrubs the content in pseudo playback. Sitting here thinking about it, I don't recall the timeline updates the way FCP does to go beyond the user interface viewer... it hasn't been a show stopper for me.
    jPo

  • Trouble with clipping paths and expanding

    Hey y'all. Okay, so I have a Illustrator element that uses a clipping path.
    Even after I run "Expand Appearance" on it, it's not trimming the art to the bounds of the path.
    It's making for difficult to position correctly when copying into Photoshop as a Smart Vector or Shape Layer:
    And it isn't correct in After Effects either.

    What you are describing is just another example of the very common need to trim artwork (including filled, unfilled, open, and/or closed paths) without wrecking its already-applied Attributes, Appearances.
    As has been discussed many many times here, Illustrator simply does not provide that basic functionality...neither by its horribly-designed cutting tools nor through its problematic and caveat-riddled Pathfinders. Expanding a Clipping Path doesn't serve as a workaround for this long-missing functionality; nor does flattening transparency. You can't do it without resorting to the workarounds you've already tried or others that will no doubt be suggested.
    Once again:
    NONE of Illustrator's cutting tools (Knife, Scissor) can cut across artwork that includes multiple open, unfilled paths. Open unfilled paths are ignored by the Knife cut. The Scissor cannot cut across multiple paths at once.
    Illustrator's recently-added, very poorly implemented Eraser tool comes nearest to the needed functionality. It can at least cut multiple unfilled open paths without their becoming converted to unstroked, closed fills. But it unpredictably alters the shapes of remaining portions and has no means by which to accurately control a cutting shape other than rectangular.
    This is a prime example (there are others) of how Illustrator confuses and clutters the interface with multiple under-powered tools designed for similar functions, none of which measure up to a single tool properly designed for the same purposes in most other programs.
    Pathfinders are riddled with ridiculous caveats. Those which come close to providing the needed functionality are incapable of ommitting the unwanted deadwood and/or wreck strokes by outlining them.
    Illustrator needs a feature that allows any given path to be employed as either a selection marquee or a cutting path. And the cutting operation needs to act as expected regarding strokes as well as fills--as common in any other drawing program that does provide the long-missing functionality (most do; Illustator never has).
    JET

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

  • Linking Photoshop EPS Files with Clipping Paths

    I'm running InDesign CS4 6.0.3 on a dual 2GHz G5 with Mac OS X 10.5.7.
    We have a workflow that involves Photoshop EPS files being placed in InDesign with the object's clipping path set to Photoshop Path.  If the link is updated or relinked, InDesign no longer restricts the image to the boundaries of the path—either on screen or on export to PDF—even though choosing Object -> Clipping Path -> Options still shows the type set to Photoshop Path.  The only way that I have found to get the clipping path to fully apply to the image is to change the type from Photoshop Path to None and back to Photoshop Path, all while the Preview check box is on.  I tried different combinations of turning the Apply Photoshop Clipping Path option on and off at the time of initial placement and at the time of relinking with no effect on this behavior.
    Assuming that using a format other than EPS and using transparency rather than clipping paths are not in play at the moment, my questions are:
    1.  Is this a know issue with InDesign CS4?  If so, can we expect a fix soon?
    2.  Is there anything that can be done on the user side that is less cumbersome than the workaround described above?

    @Mark
    Photoshop PSD is fine for all raster work. But if you have vector masks, vector shapes or text in the file then saving as PDF would be the better option, you can choose to remove the white background when importing the PDF in the Show Options of the Place Dialog box.
    And that's null point anyway, as soon as you open a photoshop EPS file in Photoshop it rasterises everything. So what I said isn't a viable solution for this project. But to keep in mind that PSD will output as raster only and PDF can have transparency and raster + vector data.
    Just thought I'd through that out there.

  • Illustrator CS6: deleting unwanted items outside a clipping path

    Hi everyone,
    I'm creating a logo that employs a stippled texture (a half-tone) in various sections of objects comprising the logo. I've placed the stipple where I want it, created a clipping path to capture the area. Now I have all these other points that I don't need that I want to delete.
    Is there anyway short of releasing the clipping path, manually delete unwanted sections of the stipple and then re-apply the clipping path again? It would be like 'Applying Mask' in photoshop.

    You can enter isolation mode without releasing the clipping mask. Beyond that I don't see a way to do this automatically unless you want to make your stipples a compound path or group and use Pathfinder operations. Unfortunately AI doesn not have inside/ outside detection for these kinds of scenarios that wouzld allow to quickly select separate objects in this fashion...
    Mylenium

  • Clipping path - automation

    Hello,
    For some time I have been trying to figure out a problem I am having with a script.
    I have succeeded to write a script that does exactly what I want, wich is having Photoshop opening selected files, then apply the clipping path and finaly save as .png
    The only problem I am experiencing is when Photoshop (CS 5.5) opens the selected number of files, it only applies the script to the first opened file, while the others remain unedited...
    I was hoping to find some help and or a solution in solving this problem.
    Thanks a lot in advance!
    Kind regards,
        #target photoshop
    //Input selection
    var myInputFolder = Folder.selectDialog ("INPUT");
    if(myInputFolder!=null){
        var myFiles = myInputFolder.getFiles(/.(jpg|psd|tif|png)$/i);
        for(var fileIndex=0;fileIndex<myFiles.length;fileIndex++){
            var tempDoc = app.open(myFiles[fileIndex]);
    //Track
    docs = app.documents;
    for (i=0; i < docs.length; i++) {
        doc = docs[i];
        app.activeDocument = doc;
    //Unlock Layer
    docLay=app.activeDocument.layers;
    l=app.activeDocument.layers.length;
    while (l>0) {
        l--;
        docLay[l].isBackgroundLayer = false;
        docLay[l].allLocked = false;
    //Clipping path
        if (app.documents.length > 0) {
        if (app.activeDocument.pathItems.length > 0) {
        var thePath = app.activeDocument.pathItems[0];
        app.activeDocument.selection.selectAll();
        thePath.makeSelection(0, true, SelectionType.DIMINISH);
    //Clear Selection
    try {
    app.activeDocument.selection.clear();
    } catch(e) {
    alert("Sorry, dit document bevat geen pad!");
    //Resolution
       var doc = activeDocument;
       var res = doc.resolution;
       doc.resizeImage(undefined, undefined, 150, ResampleMethod.BICUBIC);
    //Trim
    app.activeDocument.trim()
    //Save PNG
    var doc = app.activeDocument;
    var Path = doc.path;
    var Name = doc.name.replace(/\.[^\.]+$/, '');
    var Suffix = "_DSok";
    var saveFile = File(Path + "/" + Name + Suffix + ".png");
    SavePNG(saveFile);
    function SavePNG(saveFile){
        pngSaveOptions = new PNGSaveOptions();
    activeDocument.saveAs(saveFile, pngSaveOptions, true, Extension.LOWERCASE);
    activeDocument.close(SaveOptions.DONOTSAVECHANGES);

    I didn't have how you set up your files to test this, so I hope it works.
    #target photoshop
    //Input selection
    var myInputFolder = Folder.selectDialog ("INPUT");
    if(myInputFolder!=null){
        var myFiles = myInputFolder.getFiles(/.(jpg|psd|tif|png)$/i);
        for(var fileIndex=0;fileIndex<myFiles.length;fileIndex++){
            var tempDoc = app.open(myFiles[fileIndex]);
    //Track
    //declare all variables.
    var doc, res, Path, Name, Suffix, saveFile
    var docs = app.documents;
    for (i=0; i < docs.length; i++) {
        doc = docs[i];
        app.activeDocument = doc;
    //Unlock Layer
    docLay=app.activeDocument.layers;
    l=app.activeDocument.layers.length;
    while (l>0) {
        l--;
        docLay[l].isBackgroundLayer = false;
        docLay[l].allLocked = false;
    };//end while loop
    //Clipping path
        if (app.documents.length > 0) {
        if (app.activeDocument.pathItems.length > 0) {
        var thePath = app.activeDocument.pathItems[0];
         app.activeDocument.selection.selectAll();
        thePath.makeSelection(0, true, SelectionType.DIMINISH);
            }//end if app.activeDocument.pathItems.length
        };//end if app.documents.length
    //Clear Selection
    try {
    app.activeDocument.selection.clear();
    } catch(e) {
    alert("Sorry, dit document bevat geen pad!");
    }//end catch
    //Resolution
       doc = activeDocument;
       res = doc.resolution;
       doc.resizeImage(undefined, undefined, 150, ResampleMethod.BICUBIC);
    //Trim
    app.activeDocument.trim()
    //Save PNG
    doc = app.activeDocument;
    Path = doc.path;
    Name = doc.name.replace(/\.[^\.]+$/, '');
    Suffix = "_DSok";
    saveFile = File(Path + "/" + Name + Suffix + ".png");
    SavePNG();//removed saveFile since it's global, you don't need it here.
    };//end for loop that sets each document as active.
    function SavePNG(){
        pngSaveOptions = new PNGSaveOptions();
    activeDocument.saveAs(saveFile, pngSaveOptions, true, Extension.LOWERCASE);
    activeDocument.close(SaveOptions.DONOTSAVECHANGES);
    };//end function SavePng

  • Exporting Images and Clipping Paths

    I ran into a problem exporting images the was previously reported by Ruvan Fernando on Jan 25, 2006, but nobody had responded, so I'm trying again...
    I'm using the SDK to open images and then save them back out with different colorspaces, resolution, etc. When I have an image that has a clipping path in it, when it's saved, the clipping path is missing.
    I am copying all the source image attributes to the destination image attributes.
    Any help would be appreciated.

    I tried dragging it, and it gave the original version.
    At Share there are; Print, Email, Desktop, HomePage, .Mac Slides, Order prints, Send to iDVD, Burn Disk, Export
    I tried Desktop and it put the current image do my wallpaper.

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

  • Clipping paths from magic wand selection

    I've been looking through dozens of tutorials but even the one's that mention this they all assume you know how to do it. All I would like to do is turn a selection made using either the magic wand tool or the other selection tools/methods and turn that into a clipping path.
    This is the selection i've made with the magic wand tool:
    http://img414.imageshack.us/img414/9307/screen28qd.jpg
    Also is their any way to turn a whole layers contents into clipping paths? For example I have that image on it's own layer with no background, could I turn everything on that layer into a clipping path?
    Clipping paths for this kind of thing as far as i'm aware is the only way to import images into quarkxpress with no backgrounds.
    thanks
    sam

    Hey Sam, if I'm not mistaken you simply have to make your selection, then select make "work path" from the Path window, next you save the path and then select "clipping path" from the Path window and select the saved path's name.
    I would think this would work with layer selections as well.
    Hope this helps...
    Dan

  • Bring in another .psd file with the clipping path

    Okay, this client has a very odd request. They want a collage of images put together in one file and they want the clipping paths to be attached. Then it's to be saved as an eps file. I'd like to do this in InDesign and am going to be posting this same question there as well. I like that in InDesign, the clipping path stays attached to the image when you move it. However, is there a way to do this in Photoshop? I don't know how to bring .psd files into Photoshop along with their clipping paths. If there is a way to do this, is there a way to link the clipping path to the layer so that when I move the individual layers, the clipping path moves with it?
    Help would be greatly appreciated! Thank you!

    In Photoshop "Clipping Path" is a special kind of Path and limited to one per image and not linked to one Layer.
    A work-around to combine multiple images with individual Clipping Paths into one psd file with a combined Clipping Path could be
    • applying the Clipping Paths as Vector Masks to the images (flattened to one Layer or converted to a Smart Object each),
    • combining them and after positioning/transforming/…
    • copy/pasting the individual Vector Masks into one new Clipping Path.

Maybe you are looking for