How to determine if the layers overlap?

I am trying to find a way to determine if the different layers have pixels that overlap.  The layers are formed at random and need to fit as closely as possible, so using the limits to check the overlap would not work.  I'm basically looking for a way to detect duplication based on pixels that are 100% opac.  Is there an easy way to do this in a script?

I had some free time at work so here is my implementation, only problem I do not know how to remove the "no dialogue selected pixels.

Alert (checkOverlapping ());

function checkOverlapping()

{

var selectedLayers = getSelectedLayersIdx();

If (selectedLayers.length! = 2) {alert ("Please select the two layers you want to check"); return null ;}}

makeActiveByIndex(selectedLayers[0]);

selectActivePixels();

makeActiveByIndex(selectedLayers[1]);

intersectActivePixels();

activeDocument.quickMaskMode = true;

activeDocument.activeLayer.threshold (128);

activeDocument.quickMaskMode = false;

Try

{

activeDocument.selection.bounds;

}

catch (e)

{

return false

}

activeDocument.selection.deselect ();

Returns true;

}

function cID (inVal) {return charIDToTypeID (inVal) ;}

function of the sID (inVal) {return stringIDToTypeID (inVal) ;}

function selectActivePixels()

{

var desc15 = new ActionDescriptor();

var ref8 = new ActionReference();

Ref8.putProperty (cID ('channel'), cID ("FSC"));

desc15.putReference (cID ("null"), ref8);

var ref9 = new ActionReference();

Ref9.putEnumerated (cID ('channel'), cID ('channel'), cID ("TN"));

desc15.putReference (cID ("T"), ref9);

executeAction (cID ("setd"), desc15, DialogModes.NO);

}

function intersectActivePixels()

{

var desc18 = new ActionDescriptor();

var ref13 = new ActionReference();

ref13.putEnumerated (cID ('channel'), cID ('channel'), cID ("TN"));

desc18.putReference (ref13 ("null"), cID);

var ref14 = new ActionReference();

ref14.putProperty (cID ('channel'), cID ("FSC"));

desc18.putReference (cID ("with"), ref14);

executeAction (cID ("Introduction"), desc18, DialogModes.NO);

}

function makeActiveByIndex (idx) {}

var / / desc = new ActionDescriptor();

Var ref = new ActionReference();

ref.putIndex (cID ("Lyr"), idx)

desc.putReference (cID ("null"), ref);

desc.putBoolean (cID ("MKV"), true);

executeAction (cID ("TPCV"), desc, DialogModes.NO);

};

function getSelectedLayersIdx() {}

var selectedLayers = new Array;

Var ref = new ActionReference();

ref.putEnumerated (cID ("Dcmn"), cID ("Ordn"), cID ("Trgt"));

var / / desc = executeActionGet (ref);

If (desc.hasKey (sID ("targetLayers"))) {}

DESC = desc.getList (sID ("targetLayers"));

var c = desc.count

var selectedLayers = new Array();

for (var i = 0; i)<>

try {}

activeDocument.backgroundLayer;

selectedLayers.push (desc.getReference (i). getIndex());

} catch (e) {}

selectedLayers.push (desc.getReference, (i), .getIndex () + 1);

}

}

} else {}

Var ref = new ActionReference();

ref.putProperty (cID ("Rprp"), cID ("ItmI'));

ref.putEnumerated (cID ("Lyr"), cID ("Ordn"), cID ("Trgt"));

try {}

activeDocument.backgroundLayer;

selectedLayers.push (executeActionGet (Ref), .getInteger (cID ("ItmI"))-1);

} catch (e) {}

selectedLayers.push (executeActionGet (Ref) .getInteger (cID ("ItmI")));

}

var vis = app.activeDocument.activeLayer.visible;

if(vis == true) app.activeDocument.activeLayer.visible = false;

var desc9 = new ActionDescriptor();

var list9 = new ActionList();

var ref9 = new ActionReference();

Ref9.putEnumerated (cID ('Lyr'), cID ('Ordn'), cID ('Trgt'));

list9.putReference (ref9);

desc9.putList (cID ('null'), list9);

executeAction (cID ("'Shw"), desc9, DialogModes.NO);

if(App.activeDocument.activeLayer.Visible == false) selectedLayers.shift ();

app.activeDocument.activeLayer.visible = live;

}

Return selectedLayers;

};

Tags: Photoshop

Similar Questions

  • How to choose among the layers

    I created a Keynote slide with several layers. Because the layers overlap or cover each other, how can I select a layer that is under one or more other layers if I want to organize or edit? Is it possible to see all the layers included on a given slide in order to choose the one I want to work on?

    I use Keynote 7.0 on macOS Sierra on a MacBook Pro.

    Thank you!

    option 1

    Click on the top layer of the set of objects to select, then press the button SHIFT and then on the tab on the keyboard to move to the bottom of the layer, press the tab key to move the layers

    option 2

    If your objects have an attached building you will see the object selected in the build order list

    If there is no attached effects, temporarily add an effect (blur has the least to impact on objects or melted)

    Inspector > animate > build order

    Click the object in the list of construction required to select:

  • How to determine whether the current operating system is windows, or MAC?

    How to determine whether the current operating system is windows, or MAC?

    CSparrow wrote:

    operatingSystem var = $.getenv ("OS");

    operatingSystem = operatingSystem.toString ();

    alert (operatingSystem);

    It gives me Windows NT Windows 10

    With the help of:

    alert($.os);
    

    works for me.

    (result: Windows/64 10.0)

    and the Silly-V code

    Folder.FS

    gives you the name of the operating system

  • How to determine that the user has purchased an article or not?

    Hello

    Can someone tell me how can I determine if the user has purchased an article or not?

    Until now, I add to the cart and then allow user to pay for this item through Paypal. But now, my goal is to show all these items that the user has already added, but not bought yet.so, whenever user logs in a/c, he can see the item in my cart.

    Please... help me

    This sounds like a question of PayPal, then you will want to check these forums. If you were using in-app purchases of BB, so yes, it has an API to check the previous in-app purchases.

  • How to determine if the rank of the acquired list focus?

    Hi all

    I have ListField with custom reminder.

    When the user change focus by the movement of the navigation, drawListRow() is called several times - for each focus-changed event.

    How can I determine in the method drawListRow() if current rank on the FOCUS_GAINED event?

    I can do that by following the path:

    public void focusChanged( Field field, int eventType )    {        mIsFocusGained = false;
    
            if( eventType == FOCUS_GAINED )        {            mIsFocusGained = true;        }    }
    
     public void drawListRow( ListField listField, Graphics graphics, int index, int y, int width )    {        int rowHeight = listField.getRowHeight();        int selectedIndex = getSelectedIndex();
    
            if( index == selectedIndex && mIsFocusGained )        {            drawHighlightRegion( graphics, HIGHLIGHT_FOCUS, true, 0, y, width, rowHeight );        }---------
    

    But I can do that directly in drawListRow()?

    Thank you

    I expected allows you to change your listener to update as follows:

    if ( eventType == FOCUS_GAINED )
    {
    mIsFocusGained = true;
    }
    else
    if ( eventType == FOCUS_LOST )
    {
    mIsFocusGained = false;
    }
    

    I think you should ignore FOCUS_CHANGED because the listField stil keep focus in these events.

    I'm not clear on what you mean by that:

    "is that a function is to determine/get current theme ceremony?

    I thought you did that with your FocusChange listener?

  • How to determine if the user of the mobile device is looking at a site office?

    Hello


    We have activated the Mobile support for a site.  So now, when a user on a mobile device go to the website they see mobile model.

    The mobile template includes a link to the user to view the full site: < a href = "/ index.html? visitorDeviceClass = desktop" > full view of the Site < /a >

    We want to add a link 'view the Mobile Site"on the Office site but only for users of mobile devices.

    We tried to {{globals.cookie}} and {{globals.visitor}} to see if there is something we can watch (using javascript) to determine if we have a mobile user who visits the site of the office.  But it looks like visitorDeviceClass and deviceClass are set to "desktop" for real desktop users and mobile users who clicked on the link "View Full Site.

    We believe that we could be able to watch her User Agent but do not know what OS is displayed for Windows phones and we are not dependent on not user agent.

    Question:

    Does anyone know of a way for us to determine if a mobile device user look at the desktop version of the site so that we can add a link 'view the Mobile site?

    Thank you

    sepyh

    Hey,.

    You can basically determine the device of the visitor to the site in two ways:

    Hope this helps,

    Mihai

  • How do you manage the layers and objects and to rear of the other

    I do not understand how it is possible to have many objects on the stage and be able to handle the motion tweens with each of them, but ALSO to manage the objects are in front and behind them. I have a boot animation and there are many ongoing action, and there are times where I need my guys to be in front of the objects, and the time when they need to be behind.

    I do not know how to handle things regarding the layers and the movements in a way so I can get the items in the order that I need them to be (as the element on which passes in front of the other).

    Someone at - it advice or a way that I can manage my objects and queries and be able to classify them on the stage so that I can arrange things how I need them to be investment and who should be in front of the other objects?

    Yes, if you want to animate 20 items, you must put each item in its own layer. There are a number of ways to make it a little less tedious. For example, if you place each element on the stage, in the same layer, and then name each instance, you can then select all the elements on the stage and then select the Edit menu and then the timeline and finally distribute to layers. This will place each item in a layer newly created at the same position on the stage and then name each layer to match the name of instance for this element.

    To change the Z-order of any given scene element, you can use a number of different methods. One method is to use Actionscript as I mentioned in my last post. ActionScript is the best method if you need to be able to respond to user input and show the changes that cannot be built in animation since the beginning. If you're just showing an animation preset, you can use a number of methods different timeline based.

    In your example, if you want to have a figure to move another object on the stage, you can do that by creating two layers of the same object. One on one with the figure between the two. So that you have the object to move around both in front and behind, the figure. When you want to display the number in front of the object, set the object in the layer that is on top is not not visible. Then you will see only the object that is at the origin and the figure in front of him. How you go about changing the visible property or the alpha property, of this object. You can use keyframes in the timeline panel or the simple ActionScript.

    You want to find a small pool in the basics of Flash or take a book to guide you. There are a number of very good tutorials on the basic available free animation: http://www.gotoandlearn.com, or at a cost: http://www.lynda.com .

  • How to determine if the device supports portrait / landscape views?

    Is there an easy way to determine if the screen of the device supports portrait / landscape views?

    (We need to provide different settings for the user)

    Until recently, we used check similar to the following:

    If OS > = "6.0" & AccelerometerSensor.isSupported)

    but this code does not work on the new Bold 9900 (which has the accelerometer, but has no landscape mode).

    We are looking for a solution that doesn't invlove by manually checking the models...

    Thanks in advance!

    You can use the DeviceCapability.isRotationSupported method to determine this.  This class has been added in BlackBerry Device Software version 6.0.

  • How to determine if the sound card on motherboard works?

    How can I determine if I have the card in her ascent to the motherboard is working or not?  My computer is an optiplex260

    A. you hear sounds?

    B. why you think you have an its own card?  As far as I know from the Dell site, the Optiplex GX260 integrated sound (i.e., the sound circuit is part of the motherboard).

    C. Manager devices open (start > run > devmgmt.msc > OK).  Click on the + sign next to "audio, video and game controllers".  Is there a warning symbol (yellow triangle with!) next to one of the entries?  If so,.

    • What entry?
    • Double-click on this entry.  What is all the contents of the box under the heading 'device status '?  What is the mention ' status of the device.
  • How can we change the layers while doing an animation?

    You know how in some animations, part of the body of the character, such as an arm, for example, we see layered over their face one minute and then turned be behind them or something? How do you do that in Adobe animate?

    I remember that this has been discussed on the forums, and IIRC the solution was to have two arms: one behind and one ahead and then exchange them via keyboard shortcuts during the recording of the scene.

  • How do you get the layers work correctly when you create a document merged into the InDesign data merge feature?

    Hey everybody,

    I working on a card game using data with a .csv file merge and spin in unusual behavior when you create a merged document when my master document had layers.  Imagine I had a layer of structure that looks like this:

    Layer has
    -< DataMergeFrameA >

    -Cooked in the static element
    Layer B

    -Cooked in the static element B
    -< DataMergeFrameB >

    -< DataMergeFrameC >

    Layer C
    -Cooked in the static element C

    -< DataMergeFrameD >

    Preview, this hierarchy is respected and the image is superb.

    When I create my merged document that each individual card includes this editable structure:

    Layer has
    -< DataMergeFrameA >

    Layer B

    -< DataMergeFrameB >

    -< DataMergeFrameC >

    Layer C

    -< DataMergeFrameD >

    And the order in which the elements are drawn resembles what happened past:

    -< DataMergeFrameA >

    -< DataMergeFrameB >

    -< DataMergeFrameC >

    -< DataMergeFrameD >

    -Cooked in the static element

    -Cooked in the static element B

    -Cooked in the static element C

    I would * really * like solving this problem without going through a column of data fusion with just the same picture in each area or something stupid like that, especially because some of my other static elements are generic text boxes. Is it possible to apply the stacking order in a merged document?

    I have attached a screenshot of the preview and the merged document.
    * WARNING: The main art is a temporary placeholder *.

    The one on the left is how it looks in preview. The second is the merged document. The major problems are that a) static grass image should appear on the art main and b) main image overlays areas of main text on the left. How can-

    InDesignPreviewBug.pngInDesignMergedDocumentBug.png

    Try moving it all off the master and on the page of document in the model.

  • How to loop through the layers of the children of a group with jsx?

    Need to change the name of a child layers in a group? How to get there?

    Kind regards

    Dorothy

    What is giving you problems?

    Perhaps this example can help:

    #target photoshop
    var theLayers = collectLayers(app.activeDocument.activeLayer, []);
    alert (theLayers.join("\n"));
    ////// function collect all layers //////
    function collectLayers (theParent, allLayers) {
      if (!allLayers) {var allLayers = new Array}
      else {};
      var theNumber = theParent.layers.length - 1;
      for (var m = theNumber; m >= 0;m--) {
      var theLayer = theParent.layers[m];
      theLayer.name = theParent.name + "_" + m;
    // apply the function to layersets;
      if (theLayer.typename == "ArtLayer") {
      allLayers.push(theLayer)
      }
      else {
      allLayers = (collectLayers(theLayer, allLayers))
    // this line includes the layer groups;
      allLayers.push(theLayer);
      }
      };
      return allLayers
      };
    
  • How to determine if the variable exists?

    I need to find a way to determine if a variable exists.  Because if I don't and evaluate a variable that does not exist, I get error.  This is why I need to do this.  I need to print only the failures in the sequence and the problem is that I can print only the failures that causes failure of the sequence.

    I have reduced that there is a Boolean status in the list of TS results. StepCausedSequenceFailure.  The question is this variable exists only when the step caused sequence failure checkbox is checked, otherwise this variable is not in the results.  Thanks for help.

    Use PropertyExists ("Locals.ResultList [x]. TS. "" "StepCausedSequenceFailure"), where "x" is the index of the step that interests you as a precondition to any approach that will access this value. "

    I hope this helps.

    -Jack

  • How to determine if the XP operating system is genuine

    They gave me this computer, Dell Precision 340, which had been built in 2003. He moved with Windows XP Pro version 2002 registered 3 pack.

    I was on the site of Microsoft trying to download Security Essentials and the site told me that this operating system may not be authentic. I said that it is by those who have donated pc for me. I need to know if the product key changer is a good thing or not? I now can not afford to buy the new operating system for this, nor update the pc now...

    How to request backup discs Dell

  • How can I combine the layers of transparent colors in one color?

    Hello

    I'm creating a design, and to create the colors that I wanted, I used a completely Opaque layer with another slightly transparent layer on top a different color. Is it possible that I can compress the transparent and opaque in one color parts so that I can easily move these colors to other colors without changing any individually each layer of transparency?

    When you select both layers and choose object > flatten transparency, you get objects that contain the combined color. (set the raster - vector balance to 100).

Maybe you are looking for