Highlighted

Problem adding LUTs (color lookup) using JSX

New Here ,
Sep 03, 2020

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:

LUT ScriptListener.png

 

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?

TOPICS
Actions and scripting

Views

76

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Problem adding LUTs (color lookup) using JSX

New Here ,
Sep 03, 2020

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:

LUT ScriptListener.png

 

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?

TOPICS
Actions and scripting

Views

77

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Sep 03, 2020 0
Most Valuable Participant ,
Sep 03, 2020

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.

image.png

JJMack

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 03, 2020 0
qmate LATEST
New Here ,
Sep 04, 2020

Copy link to clipboard

Copied

Thank you JJMack. My issue though is not understanding CUBE files and what they contain, but rather to read the CUBE file and formatting it the way Photoshop needs it for me to use it in a Color Lookup layer.
So far, from what I've found online and tested, this is the closest I get to something that works:

 

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);
    }
};​

 

 

However, that seems to only work with ICC files...

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 04, 2020 0