Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Problem adding LUTs (color lookup) using JSX

New Here ,
Sep 03, 2020 Sep 03, 2020

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.pngexpand image

 

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
346
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Community Expert ,
Sep 03, 2020 Sep 03, 2020

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.pngexpand image

JJMack
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 04, 2020 Sep 04, 2020
LATEST
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...
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines