Converting CUBE to ICC

Greetings every curious soul!

I am in a bit of a bind.

I would like to set the 3DLUT file of a ColorLookUp adjustment layer automatically.

Using the action recorder I have managed to extract that the batchplay action should look like this

const actionObj = [
            {
              _obj: "set",
              _target: [
                {
                  _enum: "ordinal",
                  _ref: "adjustmentLayer",
                  _value: "targetEnum",
                },
              ],
              to: {
                _obj: "colorLookup",
                lookupType: {
                  _enum: "colorLookupType",
                  _value: "3DLUT",
                },
                name: lutAbsolutePath,
                LUTFormat: {
                  _enum: "LUTFormatType",
                  _value: "LUTFormatCUBE",
                },
                profile: {
                  _data: profile, // this is a variable
                  _rawData: "base64",
                }
,
                LUT3DFileData: {
                  _data: base64, // this is also a variable
                  _rawData: "base64",
                },
                LUT3DFileName: lutAbsolutePath,
              },
              _isCommand: true,
            },
          ];

The three variables are:

  • lutAbsolutePath is the name you will see in the 3DLUT file input
  • The base64, which is the .cube file encoded in base64.
  • The profile, which is a the .icc file encoded in base64

The rest is static

The .cube was easy, read the file with uxp.storage, load the string, encode to base64 and stuff it in the action object.
But I cannot figure out how to get the .icc file.

Loading in the LUT manually is selecting the ColorLookUp adjustment layer and loading in the .cube.
I never even touch anything .icc related.
So I assume it is generated from the .cube

The profile cannot be any other .icc base64 encoded profile, it has to be one linked to the .cube.

But I have no idea how to generate that .icc file.

Any thoughts?

Thank you :heart:

As far as I know, from tinkering around with this myself a few years ago, Photoshop converts all input LUTs to ICC profiles when you load the LUT through the menu. It’s true that you can record the underlying action but the data that is necessary (i.e. the profile) comes from Photoshop itself. I’ve never been able to automate this. So if you come up with a solution I’d be super interested as well :blush: Unfortunately Photoshop makes a number of assumptions (some of them wrong) when converting LUTs to ICCs, in particular when dealing with HDR LUTs…