• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

237

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
LEGEND ,
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.

Votes

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?

Votes

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
Guide ,
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. 

Votes

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
Community Expert ,
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

Votes

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
LEGEND ,
Sep 11, 2021 Sep 11, 2021

Copy link to clipboard

Copied

No, just histogram cells values of both layers.

Votes

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
Community Expert ,
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?

 

Votes

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.

Votes

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