Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


How to tell if layers are the same??

Explorer ,
Sep 10, 2021 Sep 10, 2021

Copy link to clipboard

Copied

Hi~

Is there a way with jsx scripts to tell if two layers are the same?? So i can just choose one layer to convert to png for saving time。 

I have read the script guiding and did not find a clue.

 

Thanks,my best regard.

 

TOPICS
Actions and scripting

Views

109

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Sep 11, 2021 Sep 11, 2021

Copy link to clipboard

Copied

activeDocument.histogram

Try above code on only 1st visible layer, to do the same on another.

Make a loop over their histograms to compare values of their cells.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 11, 2021 Sep 11, 2021

Copy link to clipboard

Copied

Compare every pixels?

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Sep 11, 2021 Sep 11, 2021

Copy link to clipboard

Copied

A histogram is an array of 256 values, each of which describes the number of pixels in an image at a specific brightness level. 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Sep 11, 2021 Sep 11, 2021

Copy link to clipboard

Copied

If I duplicate normals pixels layer and change the duplicate layer blend mode to difference you will see Black. The layer are the same. Now if I shift one of the layers 1 pixels. The layers are not aligned and I do not see all black.  While the layer have identical pixel content and will have the same histogram they have a  different alignment they have different background boarded. Their layer bound are different  The miss alignment can be great the histogram will still be the same. The content location is not the same.

Capture.jpg

JJMack

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Sep 11, 2021 Sep 11, 2021

Copy link to clipboard

Copied

No, just histogram cells values of both layers.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Sep 11, 2021 Sep 11, 2021

Copy link to clipboard

Copied

This could be done with an action using difference blend mode + equalize, however, as JJMack wrote that depends on both layers having exactly the same alignment. From a scripting perspective, comparing the histogram of each layer in various forms would not have the same limitation.

 

Just curious, why do you have this problem in the first place?

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 12, 2021 Sep 12, 2021

Copy link to clipboard

Copied

LATEST

when the art staff finish a UI work with photoshop, I need to export the geometry data, and png of every layer of psd file, and then pack the pngs with texturepacker, and finally reform the UI in my applicaction. As now  i export every layer as png no matter if some of them are the same.

Before pack the pngs i will filter some pngs which are duplicate, i made a md5 value of each png data and compare the value to tell if pngs are the same. But some how i found there would be a little diffirence(mybe two or three pixels is not the same)between two pngs which should be the same ,because one are copied from the other. And some layers are duplicated but then rotated or scaled, In this case I do not know how to to figure out the sittuation. So I wonder if there is an efficient and accurate way to do this work in photoshop.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines