# \[FEATURE REQUEST\] Get all colors used in an INDEXEDCOLOR document

**URL:** <https://forums.creativeclouddeveloper.com/t/feature-request-get-all-colors-used-in-an-indexedcolor-document/5808>\
**Category:** UXP Developer Tool\
**Tags:** feature-request\
**Created:** [February 7, 2023, 5:22pm UTC](https://forums.creativeclouddeveloper.com/t/feature-request-get-all-colors-used-in-an-indexedcolor-document/5808 "2023-02-07T17:22:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![snizikish](https://avatars.discourse-cdn.com/v4/letter/s/eb8c5e/32.png) [@snizikish](https://forums.creativeclouddeveloper.com/u/snizikish)\
**Post date:** [February 7, 2023, 5:22pm UTC](https://forums.creativeclouddeveloper.com/t/feature-request-get-all-colors-used-in-an-indexedcolor-document/5808/1 "2023-02-07T17:22:42Z")

</div>

In an Indexed Color document, I can dump all of my swatches into an .act file with Image \> Mode \> Color Table… and then save the .act.

How can I get a list of colors in an INDEXEDCOLOR document using UXP?

Right now my workaround is horribly slow: nested loops to traverse every pixel in the document, top to bottom, left to right, and call `app.activeDocument.sampleColor()` on every one of them, collecting each unique color in an array. This is a deal breaker because of the time required to scan millions of pixels _even though I know there will only be 10 unique colors in the document_.

How can UXP help me do this? Anyone?

---

<div class="post-metadata">

**Author:** ![dotproduct](https://avatars.discourse-cdn.com/v4/letter/d/258eb7/32.png) [@dotproduct](https://forums.creativeclouddeveloper.com/u/dotproduct)\
**Post date:** [February 24, 2023, 9:44pm UTC](https://forums.creativeclouddeveloper.com/t/feature-request-get-all-colors-used-in-an-indexedcolor-document/5808/2 "2023-02-24T21:44:26Z")

</div>

There’s a “histogram” property on the document. Quoting the docs:

> histogram containing the number of pixels at each color intensity level for the composite channel. The array contains 256 members. Valid only when [mode](https://developer.adobe.com/photoshop/uxp/2022/ps_reference/classes/document/#mode) = `DocumentMode.{RGB,CMYK,INDEXEDCOLOR}

Could this be helpful?

---

<div class="post-metadata">

**Author:** ![DavideBarranca](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/davidebarranca/32/1523_2.png) [@DavideBarranca](https://forums.creativeclouddeveloper.com/u/DavideBarranca)\
**Post date:** [February 25, 2023, 2:56pm UTC](https://forums.creativeclouddeveloper.com/t/feature-request-get-all-colors-used-in-an-indexedcolor-document/5808/3 "2023-02-25T14:56:42Z")

</div>

I don’t think Histograms are helpful, because they return you how the population of pixels are represented in each channel (how many Red 0, Red 1, …, Red 255, Green 0, Green 1, … etc.) which cannot tell you anything useful about the way these values are actually combined in each pixel (how many R0G132B200, etc.)

A possibly faster (compared to color samplers) workaround would be to get pixel values using the Imaging API, now in beta. Get the whole pixel array, eliminate duplicates, count, and you should have the swatches.

---

<div class="post-metadata">

**Author:** ![Zee33](https://avatars.discourse-cdn.com/v4/letter/z/a698b9/32.png) [@Zee33](https://forums.creativeclouddeveloper.com/u/Zee33)\
**Post date:** [August 10, 2023, 7:31pm UTC](https://forums.creativeclouddeveloper.com/t/feature-request-get-all-colors-used-in-an-indexedcolor-document/5808/4 "2023-08-10T19:31:53Z")

</div>

Hi! Any more insight on how to use Imaging API to get the whole pixel array and then parse that data? I can’t figure it out.
