Copy link to clipboard
Copied
Is there a way that you can convert a LUT file into a string?
Just how the ScriptListener does it?
My goal would be to "convert" the LUT file via the file path and then assign the string to the Color Lookup adjustment layer
Copy link to clipboard
Copied
var file = new File("C:/Program Files/Adobe/Adobe Photoshop 2020/Presets/3DLUTs/FoggyNight.3DL");
file.open("r");
file.encoding = "BINARY";
desc7.putData(stringIDToTypeID("profile"), file.read());
file.close();
Copy link to clipboard
Copied
Thank you r-bin,
unfortunately throws an error
cTID = function(s) { return app.charIDToTypeID(s); };
sTID = function(s) { return app.stringIDToTypeID(s); };
var fileName = "C:/Program Files/Adobe/Adobe Photoshop 2020/Presets/3DLUTs/FoggyNight.3DL";
setColorLookup(fileName, "FoggyNight.3DL");
function setColorLookup(file, name) {
try {
var desc1 = new ActionDescriptor();
var ref = new ActionReference();
ref.putEnumerated(cTID('AdjL'), cTID('Ordn'), cTID('Trgt'));
desc1.putReference(cTID('null'), ref);
var desc2 = new ActionDescriptor();
desc2.putEnumerated(sTID('lookupType'), sTID('colorLookupType'), sTID('3DLUT'));
desc2.putString(cTID('Nm '), name);
var file = new File(file);
file.open("r");
file.encoding = "BINARY";
desc2.putData(sTID('profile'), file.read());
file.close();
desc1.putObject(cTID('T '), sTID('colorLookup'), desc2);
executeAction(cTID('setd'), desc1, DialogModes.NO);
}
catch (e) {
alert(e);
}
};
Copy link to clipboard
Copied
Copy link to clipboard
Copied
EventListner gives:
d1.putData(stringIDToTypeID("profile"),String.fromCharCode(0x00,0x00,0x62...)
ActionFileToJavascript.jsx gives:
desc2.putData(sTID("profile"), _hexToBin( "0001711C41444245040000006C696E6B524742205247422007E4000100190008" +
"001F000261637370000000000000000000000000000000000000000000000000" +
...)
Also if put binary rawData in the file some symboles are readable, while others are not.
var r1 = new ActionReference();
var d1 = new ActionDescriptor();
r1.putProperty(s2t("property"), s2t("adjustment"));
r1.putEnumerated(s2t("layer"),
s2t("ordinal"),
s2t("targetEnum"));
d1 = executeActionGet(r1);
var l1= d1.getList(s2t("adjustment"));
var d2 = l1.getObjectValue(0);
var rawData = d2.getData(s2t("legacyContentData"));
var datFile = new File("~/Desktop/legacy.dat");
datFile.encoding = 'BINARY';
datFile.open('w');
datFile.write(rawData);
datFile.close();
Is there no other way?
Copy link to clipboard
Copied
Hi. It took me a week to study ICC specifications. I am very new to scripting, so some things take a while.
What Photoshop generates from files, is an ICC, which is a HEX file (not ASCII) where some of it's parts represent actual numbers (e.g. first 8 HEX characters of the ICC file is ICC's length/2. But broken into 4 bytes of ASCII code, makes it look like 2 control characters, which they are not) and some are texts that do appear readable in txt readers (cause those are HEX presentations of the ASCII characters).
In order to understand what's happening there, you need to learn ICC specification.
The easiest way to parse a LUT file is to generate an ICC ( device link, RGB to RGB, just one AToB0 tag in lut16Type and everything else is constant - can just copy from already generated ICC file) where it's grid will be converted from the LUT file grid, grid size variable would be read from the file and grid length and ICC length variables calculated on the fly. That is the smallest ICC size (and amount of work) i can think of.
That is theoretical though and i probably won't try to do that.
ICC can have extra tags and fields and Photoshop do generate those.
You can "hack" ..\ Adobe Photoshop\ Presets\ Scripts\ ExportColorLookupTables.jsx file to let you save LUTs of size starting from 2. Just change 7 to 2 in two places. Then save a 2 grid size ICC file, open it and study according to ICC specification.
And to see what photoshop is generating, you need to study it in HEX presentation.