Problem adding LUTs (color lookup) using JSX
Copy link to clipboard
Copied
Hi everyone!
I'm trying to apply LUTs (cube format) using JSX. I've used the ScriptListener to get an idea and looking at the code it seems straight forward to recreate:
except for the part following:
desc13.putData( idprofile, String.fromCharCode(………
I cannot figure out what Photoshop does to convert the cube file into this long list of numbers. Looking at this topic here: https://community.adobe.com/t5/photoshop/convert-lut-in-string-for-color-lookup-adjustment-layer/m-p... , some have managed to convert ICC profiles, but not other formats… Does anyone have an idea?
If not, is there any other way I could apply a LUT using JSX? Or would it possible by relying on a C++ plugin (for both Windows and macOS) then called by a JSX used in a panel?
Explore related tutorials & articles
Copy link to clipboard
Copied
I would think those numbers are the look up table like those generated by the color calculator that write then into ICC profiles. String.fromCharCode(looks like an array of unicode number) The scriptlistener set code is likely copying the profile to the document meta data perhaps. I would think the Photoshop would have read the Profile lut its setting into the document.
It looks like you us a Mac I use Windows. The Photoshop .cube file seem to be in Presets\3DLUTs none withe the name in your screen capture. They seem to be text file. the lut table seems to be rows with three columns. of numbers blank(space) separated.
Copy link to clipboard
Copied
function setColorLookup(filePath, name) {
try {
var ref = new ActionReference();
var desc = new ActionDescriptor();
var desc1 = new ActionDescriptor();
ref.putEnumerated(cTID('AdjL'), cTID('Ordn'), cTID('Trgt'));
desc1.putReference(cTID('null'), ref);
desc1.putEnumerated(sTID('lookupType'), sTID('colorLookupType'), sTID('3DLUT'));
desc1.putString(cTID('Nm '), name);
var file = new File(filePath);
file.open("r");
file.encoding = "BINARY";
desc1.putData(sTID('profile'), file.read());
file.close();
desc.putObject(cTID('T '), sTID('colorLookup'), desc1);
executeAction(cTID('setd'), desc, DialogModes.NO);
}
catch (e) {
alert(e);
}
};

