Export Adobe Photoshop color table (.ACT) file as csv file

How do I export Adobe Photoshop color table (.ACT) files as csv files?

Answer

Well, in photoshop you do not. But the file itself is just a list of 8bit binary rgb colors (according to adobe). So converting that to a csv should be pretty trivial to do with say python for example, you could also do it with jsx but its a bit more involved.

Here is a quick python example (quickly tested on the run):

#!/usr/bin/python
# -*- coding: utf-8 -*-
# act2csv.py quick script no warranties whatsoever
import struct
import csv

DATA = []

with open("test.act", "rb") as actFile:
    for _ in range(256):
        raw = actFile.read(3)
        color = struct.unpack("3B", raw)
        DATA.append(color)

with open('test.csv', 'wb') as csvfile:
    csvWriter = csv.writer(csvfile)
    csvWriter.writerows(DATA)

Attribution
Source : Link , Question Author : Peter Raeth , Answer Author : joojaa

Leave a Comment