There may be a Scripting solution, but unless you provide a more clear description I doubt people will be able to help you well.
i need a script in which i need to compare 2 photo , the purpose for that is to identify portrait and landscape photo it layer compare in psd which contain near about 7 layer it may portrait or landscape it will compare with 1st 7 photo with layer if all are same then it will run my action. or paste that opened image
for eg a psd contains 1st 2 layer landscape after that 1 portrait and rest landscape , script should open 7 image if it will find 1st 2 photo landscape after that 1 portrait and rest landscape . then it will run action named PASTE else close that psd and open another. and compare.