Comparing layers for equality

Is it possible to compare two different layers to see if they are in fact the same image?
I'm actually working on a game at the moment. The game map was created by using game sprites created by other people. For example, I found 5 different pictures of trees, and copy pasted them into photoshop multiple times to create a forest. I have 100 trees in my photoshop document, but in reality, they are all made up of only 5 images. I want to save out each of these trees into a format usable by my game engine. I want to save each layer as an image, but avoid saving duplicates. Thus the need to compare layers for equality.
Is it possible to do this within a photoshop script? Thanks for any help you can provide.

but wouldn't this only work in the instance of them being on top of each other?
That bit of code presumes:
The layers are in the same document
The layers are the only two layers visible
The content of the layers is aligned.
The layers have simple content (no layer masks, vector masks, layer styles)
There may be other assumptions that I'm making, but this is all that I can think of.
For the trees/forest problem, I would iterate though the tree-layers.
Create a new document that is as large as the largest tree-layer in the forest.
Hide the background layer.
Copy the first layer to the new document.
Copy the second layer to the new doc
Do the layer comparison code from above my previous post
If the layers are the same, delete the new one.
Go to the next layer in the forest document.
Copy and compare the new layer against each layer in the new document.
Delete it if it's a dupe.
When you're done, the new document should have only the unique trees.

Similar Messages

  • Comparing dates for equality using API

    Hello,
    I was wondering if you could help me understand if it is possible for me to compare two dates for equality.
    I am looking to only compare the date and the month. So, if I am checking "today" with another objects Date for equality, it obviously fails because the compareTo and the equals method of both Date and Calendar, I think, are comparing even the timestamps.
    here is something I wrote for testing, which obviously is of no use
    Calendar today = Calendar.getInstance();
    Calendar later = Calendar.getInstance();
    later.set(Calendar.HOUR, 03);
    System.out.println(today.getTime());
    System.out.println(later.getTime());
    if(today.equals(later)){
       System.out.println("BIG BANG");
    if(today.compareTo(later)<0)
       System.out.println("Today Date is Lesser than my Date");
    else if(today.compareTo(later)>0)
       System.out.println("Today Date is Greater than my date");
    else
       System.out.println("Both Dates are equal");   
    Date today = new Date();
    Date myDate = new Date();
    myDate.setHours(23);
    System.out.println(today);
    System.out.println(myDate);
    if(today.compareTo(myDate)<0)
       System.out.println("Today Date is Lesser than my Date");
    else if(today.compareTo(myDate)>0)
       System.out.println("Today Date is Greater than my date");
    else
       System.out.println("Both Dates are equal");   
       So is then the only way left, is using the simple date formatter and going about things ?

    package forums;
    import java.util.Calendar;
    import java.text.DateFormat;
    import java.text.SimpleDateFormat;
    public class CalendarExample
      private static final DateFormat DF = new SimpleDateFormat("yyyy-MM-dd");
      public static void main(String[] args) {
        Calendar today = Calendar.getInstance();
        Calendar later = Calendar.getInstance();
        later.set(Calendar.HOUR, 3);
        System.out.println("today="+DF.format(today.getTime()));
        System.out.println("later="+DF.format(later.getTime()));
        System.out.println("isSameDayAndMonth(today, later) = "+isSameDayAndMonth(today, later));
        System.out.println("\n");
        Calendar tomorrow = Calendar.getInstance();
        tomorrow.set(Calendar.DATE, tomorrow.get(Calendar.DATE)+1);
        System.out.println("today="+DF.format(today.getTime()));
        System.out.println("tomorrow="+DF.format(tomorrow.getTime()));
        System.out.println("isSameDayAndMonth(today, tomorrow) = "+isSameDayAndMonth(today, tomorrow));
        System.out.println("\n");
      public static boolean isSameDayAndMonth(Calendar a, Calendar b) {
        return a.get(Calendar.DATE) == b.get(Calendar.DATE)
            && a.get(Calendar.MONTH) == b.get(Calendar.MONTH)
    }You're welcome... Javas standard date libraries leave a lot be desired. I recommend you try Joda, which is [a long standing JSR, which has never gotten up|http://www.theserverside.com/news/thread.tss?thread_id=44248].

  • Comparing objects for equality with UDT's

    Hi.
    I was wondering how Oracle does comparison for equality of objects that contains parameters of user defined types.
    Suppose I have an object with a parameters whose types are:
    1) number,
    2) varchar2,
    3) nested table type,
    4) associative array
    and I want to compare two such objects for equality. Would Oracle compare all parameters of this 2 compared objects field-by-field (and dig recursive to "leafs"), or would it compare only 1), 2) and doas nothing with 3) and 4)?
    Must I declare an order method for such comparison?

    You didn't specify a version - this is correct for 10.2, I'm not sure if it has changed in 11g.
    By default it will compare for exact equality - i.e that every attribute is the same. You can also only do it in SQL, not PL/SQL. Also can only do = and <> - you cannot do < or > etc.
    You need to create a MAP or ORDER method on the type to do any more sophisticated comparison (Same as in most object oriented languages). Documentation is here http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14260/adobjbas.htm#sthref211

  • Comparing array elements for equality

    Hi
    I have written a simple program that works as a lottery number predictor. It works fine except for the fact that sometimes 2 numbers will be the same. Does anyone know of a method that compares an array element to the others to test for equality?

    ok I've had a go at implementing a solution. I worked it out on paper so I haven't tested it yet in the program. Let me know if you can see any errors that I can't.
       boolean numNotSame = true;
       int[] lottery = new int[5];
       int currentNumber;
       start:  //label to return to if 2 numbers are the same
       while(numNotSame){
          for( int j = 0; j < lottery.length; j++){
              currentNumber = 1 + randomNumbers.nextInt(34);   //get random number
              for( int i = 0; i < lottery.length; i++){
                 if( currentNumber == lottery)
    continue start; //if numbers are the same begin again
    } //end inner for
    lottery[ j ] = currentNumber; //set array element if number not used yet
    } //end outer for loop
    numNotSame = false; //set false so while loop will end
    } //end while block

  • How do I make a drop down list of text in numbers as it is made in the example spreadsheet for comparing cars for buying where you can choose a value from a dropdown list for each car?

    how do I make a drop down list of text in numbers as it is made in the example spreadsheet for comparing cars for buying where you can choose a value from a dropdown list for each car?

    Where is this example spreadsheet? Without seeing it I can only guess at what you are asking.
    To make a drop-down list (a pop-up menu in Numbers-speak), format the cell as a pop-up then edit and add to the list of items.
    If the example spreadsheet is pulling in a dollar value based on what car you chose in the pop-up, it is probably using LOOKUP or one of the other lookup functions, getting the information from another table (a lookup table). If, instead, these dollar values are what you are choosing in the pop-up, then you need to create a pop-up with these values in it.
    The Help menu includes a link to a page where you can download the Numbers Users Manual. It also has a link to the Formulas and Functions guide. Both are useful to new users.

  • Multiple layers for possible different final images= how do I save each final pic & not lose layers

    I have layers for different possible end picture effects. eg text in different colors some of it on slopes etc.  I would like to send the client a few different choices without having to flatten or "merg visible" layers.  If I do that then I loose the possibility of changes that the client might want. Any ideas?

    @Kat
    I am moving your question to the Photoshop General Discussion forum. This particular forum is for questions around our Edit your first photo with Photoshop page.
    Regards,
    Randy Nielsen
    Product Integration Manager, Creative Cloud Learning & Training
    Adobe

  • Can't activate the COMPARE function for object DNL_CUST_TVAST for Adapter

    Hello
    I've applier OSS note 866824 to enable the exchange of the sales area flag deletion. I had to do the initial download for the customizing object DNL_CUST_TVAST but it failed because the no intial load was permitted as the data distribution was active. So I've applied note 887696 to enable the intial load for this object : I've deleted the COMPARE function for this object with transaction R3AC3. I've done the initial load for this object and now I can't add the COMPARE function : the error message is enter linked bdoc type for synchronisation load. and I don't know what to do...
    if somebody can help me...
    thanks a lot

    Thanks for your tip but it does not work, I need to fill this field.
    I just have an answer from SAP support, this value COMPARE is relevant for loading data in CDB.
    there no sense to add the compare value for this object : the compare load can never be used for this object. It was a delivery error
    Edited by: Jerome Munier on Dec 5, 2008 7:13 PM

  • Form that is a map of Ohio. I created layers for each county so I can click and it highlights, but I need to be able to click more than one. How do I do that?

    Form that is a map of Ohio. I created layers for each county so I can click and it highlights, but I need to be able to click more than one. How do I do that?

    Looks nice!
    I understand what you've done now. You used the "Set Layer Visibility" command which sets the on/off state of all the layers at once. What you need is a more subtle approach, one that will only change the state of the specific layer associated with the button, not the rest of them (so that you could have multiple layers enabled at the same time). The way to do that is by using a script.
    I wrote the script for you and applied it to the top-left counties (WILLIAMS and FULTON), in the attached file. You can now copy the actions I associated with those buttons to the rest of them, and it should work as you want it to.
    The file: MAP-HHA-Geographic(3)_edited.pdf - Google Drive

  • Why not support tree/shuttle layers for Structs/JSP in jheadstart 10.1.2.0.

    Why not support tree/shuttle layers for Structs/JSP in jheadstart 10.1.2.0.
    I want make tree style and shuttle style with Structs/JSP(jheadstart 10.1.2.0) in my project.
    Can you help me.
    Thanks for your help.

    UIX provides tree and shuttle components that generate all the complex javascript required for these UI component.
    We have no plans to create similar javascript ourselves so we can generate this with JSP. The future strategy for JHeadstart will be based on JSF / ADF Faces where we leverage UI components that have this functionality built-in, like UIX has today. With the JSF standard out there, we expect lots of sophisticated new UI components to come out, built by dhtml/javascript/ajax experts (which we are not).
    Our focus (and core competency) is on generating applications by wiring together these sophisticated UI components, and not so much on building new UI components.
    If you want to build this today using JSP I suggest you do some shopping on the internet, you wll probably find some sample code for trees and shuttles.
    Steven Davelaar,
    JHeadstart Team.

  • Is there a tutorial for layers for dummies

    I have been messing with ps for a long time but avoiding anything to do with layers...I guess it is time to learn...Is there an easy way to learn layers  ie making a layer, saving a layer, editing layers ...in my advancing years we have to go slow..So is there a tutorial for layers for dummies??
    Capt Marvy

    Bill, I came to Photoshop from the Amiga 1000 with Delux Paint, an application years ahead of its time, that would do animated 3D graphics, and with a cheap genloc, overlay them onto video.  Photoshop had reached version 4 by the time I switched, and I have always been a Windows user anyway.  You were spot on about when Layers were introduced though.
    Capt, if you find, and like, Matt Kloskowski's book, then you might like to follow the Photoshop Guys on Photoshop User TV   That is an amazing free resourse, and there are over 300 episodes now.  Scott Kelby has got together one heck of a team over there, with as well as Matt and Scott Kelby himself, of course, there is Cory Barker of Planet Photoshop which is a first class resource all by itself. 
    I find video tutorials more accessible than books nowadays, because my eyesight is none too flash, which reminds of another worthwhile resource (and I am not being rude when I say)  You Suck at Photoshop.  These are hilarious, but also full of great content.  In fact Donny would be right at home in this group as he often dreams up clever ways to use Photoshop tools.  The way he makes the train disapear into the distance in his Vanishing Point video is just one example.

  • I have several layers for this image: Background, Moon, Tree, Grass and Clouds.  When I try to use the Move tool to move the Moon, the tool jumps to the Tree layer.  The same thing happens with the other layers as well (except the background layer).  How

    I have several layers for my image: Background, Moon, Tree, Grass and Clouds.  When I try to use the Move tool to move the Moon, the tool jumps to the Tree layer.  The same thing happens with the other layers as well (except the background layer).  How can I keep the move tool from jumpimg to the Tree layer?

    1. Pre-select (highlight) the layer to move in the Layers panel.  or-
    2. [ALT+Right mouse click]  to select the wanted layer in the image window.
    and maybe
    3. Set the PS option to "Auto-select" a layer with cursor hover.  (can be very confusing!)

  • Dedicated Layers for each Page.

    I would like to see dedicated layers for each page. As it is right now the layers span across every page. If you make a layer on the home page as say "home header" it shows up as a layer on say the contact page, where it is completely useless and can cause confusion and clutter. This is a basic example but often I have multiple layers on one page and only need one or two on a different page and find I'm getting them confused from one page to the next and causing unnecessary clutter and confusion. If each page had dedicated layers for its content then it would be much easier to stay organized and provide a better user experience and more effectiant updating of info for each page.

    Daniel Flavin wrote:
    It's not, and each time (yesterday in fact) I've thought how nifty it would be to use layers in this fashion, I've killed time. Layers are document wide. You're choice is to create a pdf with layers enabled for client reviews, but than I realized they wouldn't understand how to mainipulate layers in Acrobat, and I couldn't formulate less than a one hundred word tutorial.
    It's possible to make buttons in InDesign that show/hide layers (and perform other actions like page navigation, etc.) in PDF documents. No user tutorials would be needed with informative text labels on the buttons.
    HTH
    Regards,
    Peter
    Peter Gold
    KnowHow ProServices

  • Warning in SLIN:'Does not test for equality'

    Hi i get the following error
    In "SELECT SINGLE ...", the WHERE condition for the key field "MATNR" does not
    test for equality. Therefore, the single record in question may not be unique.
    for the following code
    SELECT SINGLE * FROM zgd_phant_status
                                       INTO    t_phant_status
                                       WHERE   sellable  = p_l_matnr
                                       AND     opsys  = g_opsys
                                       AND     rellvl = g_rel
                                       AND     serlvl = g_ser
                                       AND     lang   = g_lang.

    Hi Kitty,
    Then there is no other solution (that's why it is only a WARNING message in the extended program check. Or you could bypass like this:
    SELECT *
             FROM zgd_phant_status
             UP TO 1 ROWS
    INTO t_phant_status
    WHERE sellable = p_l_matnr
    AND opsys = g_opsys
    AND rellvl = g_rel
    AND serlvl = g_ser
    AND lang = g_lang.
    ENDSELECT.
    Regards,
    John.

  • Show/hide layers for repeated recordset data

    Is there any product out there to assist with the creation of
    show/hide layers for repeated recordset data?

    You can't build that functionality in with InDesign — but you can with Acrobat Pro. You've got to use the form builder functions to create a button that will show or hide another element.
    d

  • Comparing input value to array value for equality

    Hi all,
    I'm fairly new to java and I am finding this forum to be a great resource. I am learning more by seeing the problems others are having and the solutions. thanks ahead of time for the help.
    Here is my problem.
    I am using InputStreamReader and Buffered Reader to take keyboard input and add to a string ( lets call it name)
    I then search an array for a match
    for ( int i=0; i<array.length; i++
    if ( name == array[i] )
    blah blah blah
    I can compile and run but my input never matches a value I know is in the array.
    Do I need to do something to the input string to make it usable?
    Any insight would be much appreciated

    When comparing objects (including Strings) you usually want to use obj1.equals(obj2), rather than obj1 == obj2. The equals method uses semantics defined by each object to determine whether the contents are "equal". For Strings it compares the characters, for a MyEmployee class it could compare employee IDs or names, birthdates, and whatever else you decide is important.
    The == operator, when used on references (anything that's not a primitive like int, float, etc.), tests whether both references refer to the same object. In your case, name and array[j] may have the same contents, but they're stored in two different String objects, so the == test fails.
    Oh, and when you post code, use [ code ] blocks to format it, and don't use i as an array index (gives you italics) See
    http://forum.java.sun.com/faq.jsp#messageformat

Maybe you are looking for