I was looking for a way to read the Photoshop's color palette files.
As of yet there is no answer here, so I'd like to share my solution.
I was looking for a way to read the Photoshop's color palette files.
As of yet there is no answer here, so I'd like to share my solution.
Photoshop stores color values as hexadecimals, with info at the end of the file and here's how you can read it with Python.
Important sidenote: Adobe sometimes does weird stuff, like filling the last bits with
00ff ffff ffff, which totally ruins color amount recognition. I haven't found the documentation for the fileformat, so I don't really know what's going on there.It seems the total_colors_count is the most reliable bit of information we have, as it is least likely to get filled with
fffeven if we make color tables 2 or 4 colors long, where as color_count has the tendency to be broken on less than 128 colors palette tables.