Issue with creation colorLookup layer

Hello, for some reason this:
await app.activeDocument.createLayer(constants.LayerKind.COLORLOOKUP)
is not working.
It throws an error:
“Unknown kind colorLookup somehow passed validation.”

Seems that color lookup layers are not supported for now. Is it so?
P.S. Ye, of course I can make it via action.batchPlay, but I want to be sure if it’s not possible to create it in a “normal” way

all valid layerKinds according to the docs

I see COLORLOOKUP there
so it might be a bug?

This is valid layer kind. You will get this value when you ask what kind of layer is the existing one. But the creation on new one is not yet supported in DOM as far I know.

Just out of curiosity, have you actually tried making this layer via batchPlay? As far as I know, you can’t actually automate the creation of this particular type of layer. Yes, you can record the corresponding actions (via script listener or Alchemist) but in my experience that’s where you kind of hit a dead end. The input for this layer is a LUT which Photoshop internally converts to an ICC profile and it’s that ICC profile that gets passed around in the recorded action (not your original input LUT). Unless you know how to create this ICC yourself to the exact specifications/format that Photoshop needs I think you may have to wait until there’s an API function that can also do the LUT conversion.

1 Like

yes. Unfortunately( after several tries I undestand this complexity. Alchemist shows me something like this:

{
                _obj: "set",
                _target: [
                   {
                      _ref: "adjustmentLayer",
                      _enum: "ordinal",
                      _value: "targetEnum"
                   }
                ],
                to: {
                   _obj: "colorLookup",
                   name: <path>,
                   profile: {},
                   LUT3DFileData: {},
                   LUT3DFileName: <path>
                },
                _options: {
                   dialogOptions: "dontDisplay"
                }
            }

I even tried to read the LUT file contents and pass to LUT3DFileData in string but I haven’t succeded.

maybe i can choose a file from already existing ones? I don’t know how to do it(

By default Alchemist does not generate Raw Data into generated code due to performance concerns. But you can turn it on in settings and then you can make ColorLookup layer via batch play. Not as nice as DOM but possible. First you make a layer and then you set its content.

You should probably also change “name” properties accordingly.

In raw data it is binary encoded as base64. But I can’t really tell what is inside since I haven’t looked. As somebody suggested conversion might be necessary.

To make things simpler there is also an option to show RawData as array of numbers so it won’t be encoded as base64 and you can have quick look. This of course is not a valid descriptor and serves only for research as it cannot be replayed back in this shape.

Something like this code should work.

const {executeAsModal} = require("photoshop").core;
const {batchPlay} = require("photoshop").action;

async function actionCommands() {
   const result = await batchPlay(
      [
         {
            _obj: "make",
            _target: [
               {
                  _ref: "adjustmentLayer"
               }
            ],
            using: {
               _obj: "adjustmentLayer",
               type: {
                  _class: "colorLookup"
               }
            },
            _options: {
               dialogOptions: "dontDisplay"
            }
         },
         {
            _obj: "set",
            _target: [
               {
                  _ref: "adjustmentLayer",
                  _enum: "ordinal",
                  _value: "targetEnum"
               }
            ],
            to: {
               _obj: "colorLookup",
               name: "C:\Program Files\Adobe\Adobe Photoshop CC 2018\Presets\3DLUTs\Candlelight.CUBE",
               profile: {
                  _rawData: "base64",
                  _data: "AADoWEFEQkUEAAAAbGlua1JHQiBSR0IgB+cAAwAIAAwAFgAaYWNzcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAPbWAAEAAAAA0y1BREJFnMo9VKDq7BhYkF3GDHSnZQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEZGVzYwAAALQAAAA+Y3BydAAAAPQAAABucHNlcQAAAWQAAAB0RDJCMAAAAdgAAOaAbWx1YwAAAAAAAAABAAAADGVuVVMAAAAiAAAAHABDAGEAbgBkAGwAZQBsAGkAZwBoAHQALgBDAFUAQgBFAAAAAG1sdWMAAAAAAAAAAQAAAAxlblVTAAAAUgAAABwAQwBvAHAAeQByAGkAZwBoAHQAIAAyADAAMgAzACAAQQBkAG8AYgBlACAAUwB5AHMAdABlAG0AcwAgAEkAbgBjAG8AcgBwAG8AcgBhAHQAZQBkAABwc2VxAAAAAAAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAG1sdWMAAAAAAAAAAAAAAAxtbHVjAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAABtbHVjAAAAAAAAAAAAAAAMbWx1YwAAAAAAAAAAAAAADG1wZXQAAAAAAAMAAwAAAAEAAAAYAADmaGNsdXQAAAAAAAMAAxEREQAAAAAAAAAAAAAAAAA8wL/kPKCg9TyAf+084ODrPKCg9TygoPU9UNBoPSCg9T0goPU9kJBxPXDxbz2IiLU9uLiuPZCQcT24uK490NDuPaCgbz3g4Os9+PkrPcDA8D4MjJM9+PkrPcDA8D4cnJE+AIBzPcDA8D4wsK8+EJBxPcjIrD5... more data would follow since forum won't allow me send message that long :-D"
               },
               LUTFormat: {
                  _enum: "LUTFormatType",
                  _value: "LUTFormatCUBE"
               },
               LUT3DFileData: {
                  _rawData: "base64",
                  _data: "I0NyZWF0ZWQgYnk6IEFkb2JlIFBob3Rvc2hvcCBDUzYNCiNDb3B5cmlnaHQ6IENvcHlyaWdodCAyMDEyIEFkb2JlIFN5c3RlbXMgSW5jLg0KVElUTEUgIkNhbmRsZUxpZ2h0IGZyb20gVHVuZ3N0ZW4iDQoNCiNMVVQgc2l6ZQ0KTFVUXzNEX1NJWkUgMTcNCg0KI2RhdGEgZG9tYWluDQpET01BSU5fTUlOIDAuMCAwLjAgMC4wDQpET01BSU5fTUFYIDEuMCAxLjAgMS4wDQoNCiNMVVQgZGF0YSBwb2ludHMNCjAuMDIzNTI5IDAuMDE5NjA4IDAuMDE1Njg2DQowLjA3NDUxMCAwLjA0NzA1OSAwLjA0MzEzNw0KMC4xMjk0MTIgMC4wNzg0MzEgMC4wNzA1ODgNCjAuMTcyNTQ5IDAuMTAxOTYxIDAuMDkwMTk2DQowLjIwNzg0MyAwLjEwOTgwNCAwLjEwMTk2MQ0KMC4yNDcwNTkgMC4xMjE1NjkgMC4xMTM3MjUNCjAuMjg2Mjc1IDAuMTMzMzMzIDAuMTI1NDkwDQowLjMzMzMzMyAwLjE1Njg2MyAwLjE0OTAyMA0KMC4zODQzMTQgMC4xODAzOTIgMC4xNzI1NDkNCjAuNDM5MjE2IDAuMjA3ODQzIDAuMTk2MDc... more data would follow since forum won't allow me send message that long :-D"
               },
               LUT3DFileName: "C:\Program Files\Adobe\Adobe Photoshop CC 2018\Presets\3DLUTs\Candlelight.CUBE"
            },
            _options: {
               dialogOptions: "dontDisplay"
            }
         }
      ],
      {}
   );
}

async function runModalFunction() {
   await executeAsModal(actionCommands, {"commandName": "Action Commands"});
}

await runModalFunction();

:joy:

And also it doesn’t allow to post just a single emoji :laughing:

wow, thanks a lot. I will try.

seems that there’re two different datas:
-data in LUT3DFileData section. This is clear. It’s just encoded to base64 data from lut file.
-data in profile section. And this is the dark horse…
PS. I’ve investigated, that this profile data is generating every PS launch. Because it’s slightly differs from launch to launch. So I can’t generate or just substitute it