Can I access and save the Color Table in an INDEXEDCOLOR document?

I’m working with documents that are mode = DocumentMode.INDEXEDCOLOR. In Photoshop, I can go to Image > Mode > Color Table... and see swatches of every color; then I can save the color table as an .act file. I would like to do this using UXP’s app.activeDocument. Is this possible?

There is currently no DOM support for saving indexed color table. And it seems that even batch play won’t help.

A late response, but I’m running into the same problem. I have not figured out a way to update previous palette so it uses the palette I want. However, if you can save the image as png or some other file type, you can read the palette from that image. PCX is really easy because the palette is the last 768 bytes of the file in RGB format. Just save and use fs to get the data. You can also save an act using fs by creating a buffer that is 772 bytes in length (2563+4). The first 2563 are RGB colors. The next four bytes are used (1,0) and transparency (1,1). That transparency value seems to work and it sets it to use color at index 256 as transparency which doesn’t exist.

1 Like

Here may be a solution for colors export in uxp.

First, you can write colors to the csv file, like:

name,space_id,color
RGB Magenta 16-bit,0,#FF00FF

then use

usage: swatch generate [-h] -i INPUT -o OUTPUT [-v]

generate .aco output file based on .csv input file

to generate the aco file.

I would say swatches and colors for/of indexed color mode are two different things…

Sorry, and thank u for your explanation.
But why do uxp cant access .act/.aco directly?

Because Adobe didn’t implement API for us.

ACO file format is quite simple… you can find it here: https://www.adobe.com/devnet-apps/photoshop/fileformatashtml/#50577411_pgfId-1055819

With hexeditor you can write binary parser in pure JS as well.

But I am not sure how color tables are stored.