Finding bounds of nested clipping paths...

This topic has been touched on before, muppet & sonic have pointed me in the right direction, but I'm stuck right now....
Seeing as how "saveMultipleArtboards = false" is broken in CS4, and scripting any kind of epsSave results in the artboard size being the bounding box, I am trying to see if I can find out if the "visible to the eye" bounds of artwork exceed the artboard size.
I can easily find non-clipped objects hanging outside the artboard by comparing the document's visible bounds to the artboard size.
Likewise the "visible to the eye" bounds of clipped objects :
var docRef = app.activeDocument;
docRef.rulerOrigin = [0,0];
////Get size of artboard
var myDocsizeArray = [0,0,docRef.width,docRef.height]
////Check for items on page
if(docRef.pageItems.length != 0){
/////Find out if top item is clipping mask
if(docRef.pageItems[0].typename == "GroupItem"){
if(docRef.pageItems[0].pathItems[0].clipping == true){
////Compare its bounds to doc bounds
var myClipArray = docRef.pageItems[0].pathItems[0].visibleBounds
if((myClipArray[1] >  myDocsizeArray[3]) || (myClipArray[2] >  myDocsizeArray[2]) || (myClipArray[0] < 0) || (myClipArray[3] < 0)){
alert("Outside of artboard")
However, this doesn't work if clipping paths are part of a nested groups. Is there a way to see if a clipping path's parent group is within bounds, or parent's parent group etc. is within bounds. I need to find the topmost clipping path that trumps all the others in any nested group.
Is that what recursive functions are for? ,,,,,,,,,,,
Something that can keep looking in a loop within itself?  Very instrospective!
thx

Does this help? I use these to position and find bounds based upon what is visible.
function getRealVisibleBounds(grp) {
     var outerBounds = [];
     for(var i = grp.pageItems.length - 1; i >= 0;i--)  {
          var bounds = [];
          if(grp.pageItems[i].typename == 'GroupItem') {
               bounds =  getRealVisibleBounds(grp.pageItems[i]);
          else if((grp.pageItems[i].typename == 'PathItem' || grp.pageItems[i].typename == 'CompoundPathItem')
               && (grp.pageItems[i].clipping || !grp.clipped)) {
               bounds = grp.pageItems[i].visibleBounds;
          if (bounds.length > 0) {
               outerBounds = maxBounds(outerBounds,bounds);
     return (outerBounds.length == 0) ? null : outerBounds;
function maxBounds(ary1,ary2) {
     var res = [];
     if(ary1.length == 0)
          res = ary2;
     else if(ary2.length == 0)
          res = ary1;
     else {
          res[0] = Math.min(ary1[0],ary2[0]);
          res[1] = Math.max(ary1[1],ary2[1]);
          res[2] = Math.max(ary1[2],ary2[2]);
          res[3] = Math.min(ary1[3],ary2[3]);
     return res;
function positionVisible(grp,x,y)
     var bounds = getRealVisibleBounds(grp);
     var newX = x + (grp.left - bounds[0]);
     var newY = y + (grp.top - bounds[1]);
     grp.position = [newX,newY];

Similar Messages

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

  • Importing SVG with nested clip-path

    I'm having serious issues in Illustrator CS5 trying to import SVG files with nested clip-path properties.
    Illutrator seems to create unnecessary groups, and messes up with group parents, effectively screwing things up.
    Here is a minimal example :
    <?xml version="1.0" encoding="utf-8"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" [<!ENTITY ns_svg "http://www.w3.org/2000/svg"><!ENTITY ns_xlink "http://www.w3.org/1999/xlink">]>
    <svg version="1.1" id="main" overflow="visible" xmlns="&ns_svg;" xmlns:xlink="http://www.w3.org/1999/xlink">
      <g id="piece-1">
        <g clip-path="url(#cpform)" id="form1">
          <g clip-path="url(#cplogo)" id="logo1">
                        <rect fill="#FF0000" x="10" y="10" width="1000" height="1000" />
          </g>
        </g>
      </g>
      <g transform="matrix(1,0,0,1,200,0)" id="piece-2">
        <g clip-path="url(#cpform)" id="form2">
          <g clip-path="url(#cplogo)" id="logo2">
                        <rect fill="#FF0000" x="10" y="10" width="1000" height="1000" />
          </g>
        </g>
      </g>
      <clipPath id="cpform">
              <rect x="0" y="0" width="150" height="150">
              </rect>
      </clipPath>
      <clipPath id="cplogo">
              <rect x="0" y="0" width="100" height="100">
              </rect>
      </clipPath>
    </svg>
    Such a valid SVG file displays fine in Chrome, IE, Opera, Firefox, but Illustrator fails loading it properly, because it creates two groups between "main" and "piece-1" (which is in itself not too bad), and sets piece-1 as a brother of another unnecesarry group from which piece-2 will descend. piece-2 and piece-1 are then clipped with piece-1 clip-path, which is just plain wrong and screws display.
    Note that you can move piece-2 to the root of the document, which restores the display. But save this fixed file, and open it again : it"s back to its broken state.
    Does anoyone know if this is fixed in CS6 ? If there is a workaround ?

    AI doesn't care for the original structure of an SVG. It will merely try to retain the appearance based on its own internal logic, which of course matches how you would create a normal AI file. So no, you can't probably avoid it.
    Mylenium

  • CS6 clipping path for layer group

    Hi
    In PS cs6 i cant find how to create clipping path for layer group (apply to folder from some shape layer with alt + drag&drop) created with pen, rectangle etc tools.
    Here is how it should look in cs6 but i don't know how to do that
    Thanx in advance

    Shape Layers’ Vector Masks don’t appear in the Layers Panel in CS6 (seems like a bad idea to me, but that’s the way it is now), so you could still select the Shape Layer with a Path Tool, select the Paths, copy, select the Group, paste, Layer > Vector Mask > Current Path or command-click the Layer Mask icon in the Layers Panel.

  • Unwanted nested groups and clipping paths

    Can anyone tell me why when I embed one Illustrator file inside another Illustrator file it creates repeating nested groups with clipping paths? The original file did not have clipping paths or nested groups.

    An Illustrator file has two parts and when placing you just access the wrong part for your purpose. What you want to do is open the other file and then copy/paste.
    See about Illustrator files:
    http://vimeo.com/117691712

  • Converted clipping path to frame (InDesign CS2)

    I am working with files where the person has converted clipping paths to frames for the images. I need to resize the images but it leaves a blank silhouette of the hollowed out space (where the image was) and a view in the background of the full image, including the background. I'm new to InDesign and need to find out how to resize these images or how to undo the convert clipping path to frame. Any help would be appreciated.
    Thanks.

    How are you trying to resize the frames now? Try Pressing Ctrl + Shift BEFORE you click the mouse on a sizing handle and drag. (you shouldn't need to press the keys first, but there was a bug in CS3 and I think it may still be in CS4 on the Windows platform).
    You can also use the scale tool (hold shift to size proportionally) or use the SCALE fields -- the third set from the left, not the second set which are height and width of the frame only -- on the control panel or in the transform panel. These scale both content and container together.
    By default the scale fields will say 100% after any transformation, and ID expects you to input percentage values in them and interprets numbers without units as per cent, but you can enter any value you like as long as you specify the units, so you can put 3in into the width field and the frame will become 3 inches wide. Scaling using the control panel is relative to the control point in the proxy on the left end, so if you select the upper left point, the upper left point of the bounding box will remain stationary and everything else will move toward or away from that.
    Peter

  • Clipping Path Problem in CS4

    First let me say that I'm am still new to this program and this was so much easier to do in Freehand.
    When you use clipping mask in Illustrator to insert a JPEG into a shape it looks good until you see it on your desktop or open it in Photoshop, the border of the original size of the JPEG still shows up as white area, so I have to take the time open these clipped images in Photoshop just to crop out all that extra white area. I hope this is an easy fix or some simply step I'm missing?
    I asked an old friend who uses Illustrator all the time and he said that's the way it has always been, clip a photo in Illustrator then open it up in
    Photoshop to fix the clipping problem.
    I have attached JPEG to help explain what I need and what's happening to the photos.
    If anyone could help it would save me a TON of work.
    Thank You,
    Indyrebel

    indyrebel,
    You may do the otherwise dirty destructive deed in Illy:
    With the Clipping Mask selected:
    1) In the Transparency palette/panel dropdown select anything but Normal (Multiply is fine);
    2) Object>Flatten Transparency (just leave it at 100% vector and other defaults).
    This will rid you of the parts outside the Bounding Box of the path that shapes the Clipping Mask: a rectangle, even in case of other shapes such as ellipses, which does not hurt in your case.
    If you do it to (especially stroked) vector artwork, it may hurt.
    Obviously, the serious issue is with JPEG, not with PNG/GIF when transparency is applied; but it may be inconvenient in any case, having outlying parts selectable.

  • How do I save a clipping path in Photoshop so that Quark gives me the option to change the path opti

    I created a clipping path on a photo, clipping out a person's head so that I can have the person's head show up over the masthead on a cover.
    But when I save the photo in Photoshop and then import it into Quark, the option where it says I can change the clipping options in Quark is greyed out.
    This is what it says to possibly fix it on the Quark help page:
    "You may want to choose "None" from the Clipping path pop-up menu when you save the image from Adobe Photoshop, so you can specify which path to use as the clipping path when you import the image into QuarkXPress. Or, you may want to choose a path from the Clipping path pop-up menu, so you can be sure only that path will be used to clip the image."
    I don't understand what that refers to....I can't find anything like that in the Photoshop options.
    My goal is to have the person's head over the text, with the rest of the photo still retained in the background. As it is now, I just get an import of the clipping path alone, with Quark substituting the background part of the photo with a white box.
    Thanks!

    <a href="http://www.pixentral.com/show.php?picture=1RxvmnVOUk55QdqS9tN4g7h79Bgef0" /></a>
    <img alt="Picture hosted by Pixentral" src="http://www.pixentral.com/hosted/1RxvmnVOUk55QdqS9tN4g7h79Bgef0_thumb.gif" border="0" />
    <br />
    <br />
    <a href="http://www.pixentral.com/show.php?picture=17oVBzeqvr2YeN0BkvJUS0rFTjMqHh" /></a>
    <img alt="Picture hosted by Pixentral" src="http://www.pixentral.com/hosted/17oVBzeqvr2YeN0BkvJUS0rFTjMqHh_thumb.gif" border="0" />

  • [AS][Photoshop] Checking if there is any paths or clipping paths

    Hey guys,
    I would like to determine if there is any paths or clipping paths in the files dropped onto the droplet. Then sort them into different folders. One folder for files with paths and one for without paths. Getting the files to move I think I can manage, but I can't get checking for the paths to work. Anyone got a clue? This is how far I have got.
    > on open fileList
    > tell application "Adobe Photoshop CS3"
    > activate
    >
    >
    > repeat with thisFile in fileList
    > open thisFile showing dialogs never
    >
    > set CountOfPaths to count of path items
    > display dialog CountOfPaths
    >
    > end repeat
    >
    > end tell
    end open

    Solved it! :D
    on open fileList
    tell application "Adobe Photoshop CS3"
    activate
    -- DO WITH EVERY FILE DROPPED ONTO THE DROPLET
    repeat with thisFile in fileList
    open thisFile showing dialogs never
    tell current document
    -- CHECK FOR PATHS
    set CountOfPaths to every path item
    if CountOfPaths is equal to {} then
    -- IF THERE'S NO PATH
    tell application "Finder"
    -- MAKE RED IN FINDER
    set the label index of thisFile to 2
    end tell
    else
    -- IF THERE IS A _CLIPPING PATH_
    if exists (every path item whose kind is clipping) then
    tell application "Finder"
    -- MAKE GREEN IN FINDER
    set the label index of thisFile to 6
    end tell
    else
    -- IF THERE IS A PATH BUT _NO_ CLIPPING PATH
    tell application "Finder"
    -- MAKE PURPLE IN FINDER
    set the label index of thisFile to 5
    end tell
    end if
    end if
    end tell
    -- CLOSE THE FILE
    close current document saving no
    end repeat
    end tell
    end open

  • 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

  • Cutting out images in indesign, clipping path problems

    Hi,
    I have been putting images of my drawings from photoshop onto indesign for my portfolio,  after looking around the only way I can seem to find to cut them out is using clipping path/detect edges.
    The problem I have is because they are scanned sketches this method produces really inacurate and shoddy results and no matter how much I play around with the threshold and tollerance this means I still have to mess around with the pen and arrow tool for ages on each image.
    Is there a quicker solution to cutting them out like the magic wand or lasoo tool on indesign?
    It has taken days now in in design , I have all the images already cut out from their original pages on photoshop but the white box always comes around again when I drag or place the images in indesign.
    I have been shorcutting some pages and doing layout on photoshop and placing the image behind which works fine sometimes but is really inconviiant when I want to move the layout around text ot anything...... i have attatched some pictures to show you what I mean.
    Thanks for your help in advance
    Leo

    Well Thats 2 days of my life Ill never get back!
    Thankyou very much! cant belive I was that stupid

  • Jpeg and PDF clipping paths not showing up in Keynote

    I am using Keynote '08 and my boss is using an earlier version. He wants to place a jpeg or pdf in his file and see the clipping path. He has pdfs on his machine that open in his keynote document with the clipping path intact, you don't see the white background of the image. When he places the jpegs and pdfs I have sent him, with clipping paths I created, in the same keynote document, mine show up with the white backgrounds.
    Help!

    The previous designer here saved jpegs and pdfs with clipping paths that apparantly he can open. I give him a jpeg with a clipping path (created by someone else) as well as save it as a PDF with clipping path and he cannot see the clipping path. He specifically wants to use jpegs or pdfs because that is what he has been using and that is what has been working for him until I sent him jpegs and pdfs that aren't working. So far it is just this one photo as a jpeg and saved as a pdf. I cannot find any difference between these two and the ones he is able to see clipping paths on.
    Message was edited by: heatherlor

  • Why does Illustrator CS4 save pdfs with clipping paths and make rasters of gradient areas

    I am on a IMAC and upgraded to 10.6.8 Jan 2014. I am using CS4 Illustrator to create with. When i save my work as a pdf then reopen the pdf in Ill to make changes, the whole page has:
    A.) Multiple clipping paths around it
    B.) Most text has now become outlined. Not editable anymore.
    C.) Gradient areas have multiple clipping paths of the single gradient area
    D.) The gradient areas now become rasterized.
    This is very frustrating as now all of my marketing files, some 300+, are worthless. I don't know where to look anymore to find the problem.
    Please help.
    Thank you very much

    John,
    I have the presets as you have shown. I had been editing the supplied items as you suggested. Then figured i should ask the questions of those who are better than I.
    But still a bit confused as to why the new save places clipping paths around the document.
    Thank you John and Monika for your help.
    why does Illustrator CS4 save pdfs with clipping paths and make rasters of gradient areas
    created by John Mensinger in Illustrator - View the full discussion
    I do a save as "pdf" in the format pull down tab. I save to a folder on the hard drive. Where is the "Illustrator editability" check box? I presumed it is in Acrobat some where
    but i seem to be lost.
    It is in Illustrator's Save Adobe PDF dialog, which pops up before the saved file is written.
    https://forums.adobe.com/servlet/JiveServlet/downloadImage/2-6439399-644928/450-397/Untitl ed-1.jpg
    Sorry i didn't mention this, but this seems to have occurred when using images and text from provided pdfs.
    That's a critical fact. If you didn't do the original save, the above is moot, and it's too late to exercise any control over the save process. Someone else failed to save for editability. The only thing you can do is clean up/repair the content, (release clipping masks, rebuild rasterized elements, expand objects, etc.), and save correctly as AI. Then, if necessary, re-save as PDF with the correct settings.
    Please note that the Adobe Forums do not accept email attachments. If you want to embed a screen image in your message please visit the thread in the forum to embed the image at https://forums.adobe.com/message/6439399#6439399
    Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page:
    To unsubscribe from this thread, please visit the message page at . In the Actions box on the right, click the Stop Email Notifications link.
    Start a new discussion in Illustrator by email or at Adobe Community
    For more information about maintaining your forum email notifications please go to http://forums.adobe.com/thread/416458?tstart=0.

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

  • Clipping Path vs Alpha Channel

    Not sure if this is the right place to ask, but wondering which is better for outlined images (no soft transitions, just hard outline.)
    I've used both and don't see an advantage to either EXCEPT when converting an InDesign file to PDF. Files with PSDs with clipping paths seem to make much larger pdfs than same file using PSD with alpha channel. Not important for a final press file, but when I have to email screen proofs, then it's a big deal.
    Anyone care to weigh in? Thanks.
    Ringo

    Hi, there,
    I found this discussion during a search for alpha channels vs. clipping paths for clipping (for a job I'm working on), and thought I'd offer my own feedback based on my own experiences w/ similar files. I can't really offer a printer perspective, however, although we do work closely with many and also print film fairly regularly for local printers who are not yet Direct-To-Plate.
    For what it's worth, I use paths, myself, and save the file as a TIFF. Then I use the Object: Clipping Path menu in InDesign to select the path (I don't specifically designate a path as an actual clipping path in Photoshop anymore, as sometimes an image will have more than one path to isolate different elements).
    I find that alpha channels don't look very good when used in InDesign. They're just not that smooth/precise, in my admittedly limited use.
    I've uploaded a quick sample to http://i486.photobucket.com/albums/rr222/Xiebinrui/Alpha_vs_Clipping.jpg -- it's pretty self-explanatory, but the left side shows the bottom of an image using an alpha channel created from the original clipping path (cmd-click on the path to create a selection and then click the "create channel" button in the Channels tab, which automatically creates an "Alpha 1" channel), with the original clipped version on the right. I've tried adjusting the threshold and tolerance in InDesign, but it just always looks bad.
    I also haven't used the behemoth Photoshop EPS format since my QuarkXPress/Mac OS 9 days (even then, it eventually became possible to use TIFFs w/ clipping paths -- I could finally see my photo correctly instead of with the horrible Quark EPS preview).
    Anyway, re: alpha channels, maybe it's just that I don't know the right way to use them, but they don't seem to be very smooth when importing into InDesign (I was working on a job yesterday and today for which I had to download hi-res images from the client -- many of which used alpha channels instead of actual paths, but they're used on white backgrounds in InDesign, so I just didn't use the channels).
    So, anyway, I personally use and recommend paths (vector masks, as Artdirectorringo mentioned, seem to work fine, too) as opposed to standard pixel-based alpha channels, in general, if you're going to be placing the file into InDesign.

Maybe you are looking for

  • Apple TV brought by Santa

    I just hooked up the Apple TV and after a bit have it working with everything except sound through my Bose sound system. It plays audio through the TV speakers but I cannot get audio out of the Bose. I can play movies, music, podcasts, etc but no aud

  • The iphone "iphone" could not be restored

    Hello, I'v tried to update my Iphone to the new OS 3.1.3 and when it started to restore the iphone with the new OS i got this error: the iphone "iphone" could not be restored I tried restarting my computer and almost everything i found on the net and

  • Hosting iWeb entry pages on .Mac & video files on own server

    Hi I am trying to establish whether there is any real point in hosting a podcast on .Mac because of the bandwidth cost. Is there a point in publishing the podcast entry pages to .Mac, but hosting the video files on another server where I can get chea

  • Passing ICM peripheral variables from Agent to IVR

    Hello, I need to know if this is possible since i can't manage to make it work. The call-flow is : VG->CVP->ICM->Agent While the call is in the ICM script , i saved the ICM peripheral variable 4 as the language the customer chooses at the beginning o

  • Calculating price with qty in query

    Hi , I have requirement like this . User enter material price in the selection screen of my report and then i need to calculate the value in $ by multiply qty with price(which was enterd in selection screen) . Please can any body help to resolve this