Copy link to clipboard
Copied
When document is set to 'Image > Mode > Indexed Color' we can choose 'Image > Mode > Table Color'. Then we can manually load / save current settings.
To load saved Color Table via scripting we can use this code (which works):
fle = File('~/desktop/ColorTable.act')
sTT = stringIDToTypeID; (dsc = new ActionDescriptor());
(ref = new ActionReference()).putProperty(sTT('color'), sTT('colorTable'));
dsc.putReference(sTT('null'), ref), dsc.putPath(sTT('to'), fle);
executeAction(sTT('set'), dsc, DialogModes.NO)
To export Color Table via scripting we are supposed to use this code (which doesn't work):
sTT = stringIDToTypeID; (dsc = new ActionDescriptor())
.putPath(sTT('null'), File('~/desktop/ColorTable.act'));
(ref = new ActionReference()).putProperty(sTT('color'), sTT('colorTable'));
dsc.putReference(sTT('to'), ref), executeAction(sTT('set'), dsc, DialogModes.NO)
It results as "Error: General Photoshop error occurred. This functionality may not be available in this version of Photoshop. - The parameters for command "Set" are not currently valid.", but probably Tom Ruark may confirm the code is correct so it's a bug...
I tried it in Photoshop 23.3.1 but the same is in previous releases:
Copy link to clipboard
Copied
I don't see any code inside of Photoshop to allow saving of the color table via a script. Sorry for the inconvenience.
Copy link to clipboard
Copied
Any chance we can have it like for Patterns? This code is constructed differently, but it exports:
sTT = stringIDToTypeID, fle = File('~/desktop/pat.pat')
ref = new ActionReference(), (dsc = new ActionDescriptor())
.putPath(sTT('null'), fle); ref.putIndex(sTT('pattern'), 1);
(lst = new ActionList()).putReference(ref), dsc.putList(sTT('to'), lst)
executeAction(sTT('set'), dsc)