Highlighted

Applying a 3D LUT file with Color Lookup adjustment layer

New Here ,
Jun 09, 2016

Copy link to clipboard

Copied

Hi,

We are looking for a way to automatically apply a given 3D LUT file (.cube file) loaded into a Color Lookup adjustment layer to an open document. By using the Action Manager and the ScriptListener plug-in, we have managed to create a Color Lookup adjustment layer but we are getting some troubles for loading and applying the LUT to the document. We have analyzed the script code recorded by ScriptListener and did a few tests to try troubleshooting this step but we are a bit confused on how the color table data is being stored in the Color Lookup adjustment layer. Does it create a color profile? Or a curve? How can we convert those values in JScript to eventually get the LUT working properly?

Hoping to get some info to help on this!

Thanks

TOPICS
Actions and scripting

Views

4.5K

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

Applying a 3D LUT file with Color Lookup adjustment layer

New Here ,
Jun 09, 2016

Copy link to clipboard

Copied

Hi,

We are looking for a way to automatically apply a given 3D LUT file (.cube file) loaded into a Color Lookup adjustment layer to an open document. By using the Action Manager and the ScriptListener plug-in, we have managed to create a Color Lookup adjustment layer but we are getting some troubles for loading and applying the LUT to the document. We have analyzed the script code recorded by ScriptListener and did a few tests to try troubleshooting this step but we are a bit confused on how the color table data is being stored in the Color Lookup adjustment layer. Does it create a color profile? Or a curve? How can we convert those values in JScript to eventually get the LUT working properly?

Hoping to get some info to help on this!

Thanks

TOPICS
Actions and scripting

Views

4.5K

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
Jun 09, 2016 0
Guide ,
Jun 10, 2016

Copy link to clipboard

Copied

It is possible to get the code for the cube file, but it looks as if you need to get the code for each cube file you want.

For me the ONLY time I can get the cube code is after a fresh start of the machine.

Then create your lookup, you should then have the code in the log.

Example code can be downloaded. Wikisend: free file sharing service

This is from CS6 on Windows.

P.S. create your lookup layer before running the code.

function colorLookup() {

var desc79 = new ActionDescriptor();

var ref40 = new ActionReference();

ref40.putClass( charIDToTypeID('AdjL') );

desc79.putReference( charIDToTypeID('null'), ref40 );

var desc80 = new ActionDescriptor();

desc80.putClass( charIDToTypeID('Type'), stringIDToTypeID('colorLookup') );

desc79.putObject( charIDToTypeID('Usng'), charIDToTypeID('AdjL'), desc80 );

try{

executeAction( charIDToTypeID('Mk  '), desc79, DialogModes.NO );

}catch(e){}

};

Good luck.

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...
Jun 10, 2016 0
New Here ,
Jun 13, 2016

Copy link to clipboard

Copied

Hi SuperMerlin,

Thank you for your response, but I'm a bit confused here as the example code file seems to be damaged first and then because the colorLookup function creates a Color Lookup adjustment layer only, and like I said, we have already figured out how to do this.

What we are still missing is how we can convert the values from the 3D LUT file to create the color profile or curves in the Color Lookup adjustment layer, actually I'm not quite sure how this works in the background and that's the reason why I'm still looking for answers to get it.

Can you send me your example code again so I can take a look at it?

Thanks,

Jeremy

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...
Jun 13, 2016 0
Guide ,
Jun 14, 2016

Copy link to clipboard

Copied

I have amended the sample to create the lookup layer and apply the NightFromDay.cube

Wikisend: free file sharing service

Once you get code from scriptListener there are two line where the path to the cube file is located, these are not required.

You will see I have commented these out in the NightFromDay cube example.

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...
Jun 14, 2016 0
Guide ,
Jun 14, 2016

Copy link to clipboard

Copied

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...
Jun 14, 2016 0
Community Beginner ,
Jun 14, 2016

Copy link to clipboard

Copied

Hi SuperMerlin,

I'm trying to do the same as Jeremy... not an easy thing to do.

First, Thx for sharing this.... Google is empty and it's not easy to find help.

I got the same result too, but had problem to interpret this. If I understand it well, you have now the .cube file loaded correctly and if you're running the script... that will apply

Please, stop me if I'm going in the wrong direction:

What if I want to have different .cube file every time I run this script? I think that where Jeremy was speaking about converting the values.? It seems there is two operations here.. where the second one looks like an UNICODE translation. I don't get the first one.

Thx for this,

Hope this will go somewhere.

Romain

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...
Jun 14, 2016 0
Community Beginner ,
Jun 14, 2016

Copy link to clipboard

Copied

Just see your new message with the cubeLut-specification file.

That's great !!!!

thx a lot.

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...
Jun 14, 2016 0
New Here ,
Jun 14, 2016

Copy link to clipboard

Copied

Thank you for sending your NightFromDay.jsx file, SuperMerlin, but this is exactly the code we did get recorded from ScriptListener while doing our tests. We have also noticed that the 3D LUT file path is not required in the script indeed and the first one is used to define the selected 3D LUT menu item name actually.

I had already gone through the Cube LUT Specification PDF document but I don't think this will be very helpful even though it contains essential information regarding the Cube format which are very interesting to be more familiar with as we know we have to read and analyze a Cube file to get the table values.

Now, the main problem we're facing is to understand or get more information of what's being done in the putData() method that seems to create a color profile from the lookup table data which is the tricky step for us as we don't really know how to do this in JScript.

Not an easy one for sure and it's quite difficult to find relevant information but we'll keep investigating!

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...
Jun 14, 2016 0
New Here ,
Jan 06, 2017

Copy link to clipboard

Copied

Hi, SuperMerlin

The file you are shared is protected, can you please provide the password. Thanks

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...
Jan 06, 2017 0
Guide ,
Jan 06, 2017

Copy link to clipboard

Copied

That file expired, I have uploaded it again here.. Wikisend: free file sharing service

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...
Jan 06, 2017 1
Community Beginner ,
May 07, 2017

Copy link to clipboard

Copied

That link seems to point to an audio file.  Any chance you could repost?  Have you gotten this to work?  Thanks!

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...
May 07, 2017 0
New Here ,
May 21, 2017

Copy link to clipboard

Copied

    That link seems to point to an audio file.   Nidham Audio  MP3

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...
May 21, 2017 0
Guide ,
May 21, 2017

Copy link to clipboard

Copied

Yes it expired here is another link (90 days only!)

Wikisend: free file sharing service

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...
May 21, 2017 0
New Here ,
May 24, 2017

Copy link to clipboard

Copied

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...
May 24, 2017 0
Contributor ,
May 24, 2017

Copy link to clipboard

Copied

SuperMerlin

How do you get the code number of lut 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...
May 24, 2017 0
Guide ,
May 24, 2017

Copy link to clipboard

Copied

The code was from the scriptListener log.

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...
May 24, 2017 2
New Here ,
Sep 11, 2020

Copy link to clipboard

Copied

I got to the same point, the first block of code is an icc device link profile with a Clut generated by Lut. Unfortunately I can't figure out how to generate this data. Has anyone found a solution?

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 11, 2020 0
Community Beginner ,
Jun 17, 2016

Copy link to clipboard

Copied

Hi guys,

I want to resume a little bit as inside the scriptListener record, there are two big data, seems to be used. Don't really know exactly  what they are... We figured about the second one, which seems to be a UNICODE translation of the .cube file.

So I checked for the first data, precisely this line on the ScriptListener:

desc5.putData(stringIDToTypeID( "profile" ), String.fromCharCode( 00000000......values)

and more specifically about this part: stringIDToTypeID( "profile" ). This seems to be the color profile of the document, embedded inside of the psd.

You can call yours with theses lines of javascript: (Source)

try{

var profile = app.activeDocument.colorProfileName;

}catch(e){

var profile = "not embedded";

}

$.write(profile);

So far, I'm at work... and the one used here is: sRGB IEC61966-2.1

I will try at home. but will be interested about yours... When theses values may change ?

--------------------------------

For what I understand, to apply a lut, you need first a profile, regarding your colorSpace env (think about an IPAD - screen projector or CRT monitor), do some math with your LUT data... and this make the lut as globally possible.

This is new to me.. If someone have more knowledge about this and would love to confirm it or simply say it's totally wrong...!!

PLEASE flag it.

Just a wiki page to remember what is what : Wiki

Thx,

Romain

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...
Jun 17, 2016 1
New Here ,
Jun 23, 2016

Copy link to clipboard

Copied

I did some tests and to me, the desc.putData( idprofile, String.fromCharCode( values ) ) seems to create a color profile from the color table data while the desc.putData( idLUTthreeDFileData, String.fromCharCode( values ) ) will store the color table data.

Even though I'm still not quite sure about this but that would be my guess.

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...
Jun 23, 2016 0
Community Beginner ,
Nov 09, 2016

Copy link to clipboard

Copied

I have the same issue, and have concluded the the (binary) profile data is a processed version of the LUT, which means that unless we can create this binary data ourselves (i.e., Adobe publishes the format of the data), it won't be possible to create a script that loads an arbitrary LUT from disk.

If you've figured out a solution to this problem, I'd love to know about it! Thanks!

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...
Nov 09, 2016 0
Community Beginner ,
Mar 11, 2017

Copy link to clipboard

Copied

Anybody got better chance with this ? I'm wondering if there are any progress on this question as on my side, it feels like a blocker.

Cheers

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...
Mar 11, 2017 0
New Here ,
Jul 23, 2019

Copy link to clipboard

Copied

Hey guys Did anyone end up finding a solution to load up any lut using JSX?

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...
Jul 23, 2019 0
New Here ,
Sep 11, 2020

Copy link to clipboard

Copied


I got to the same point, the first block of code is an icc device link profile with a Clut generated by Lut.
Unfortunately I can't figure out how to generate this data. Has anyone found a solution?

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 11, 2020 0
Oleqsa LATEST
New Here ,
Oct 17, 2020

Copy link to clipboard

Copied

Hi. To see what photoshop is generating, you need to study it in HEX presentation. I have converted it to HEX, broken the data into fields according to ICC specifications and was able to read what it says and understand what's happening that way.
For a device link RGB to RGB ICC with ATB0 tag set to lut16Type the CLUT grid of that tag is a HEX presentation of values from 0.0 to 1.0 presented as a range from 0 to 65535, so it's 0000-ffff. For the same AToB0 tag set to lut8Type it's 00-ff. 
The presentation is always HEX format, but depending on the tag and it's type, CLUT grid will look differently.
You need to study ICC specifications in order to understand how it looks like in every case.
The easiest way i can think of to parse a LUT file is to generate an ICC ( device link, RGB to RGB, just one AToB0 tag in lut16Type and everything else is constant - can just copy from already generated ICC file) where it's grid will be converted from the LUT file grid, grid size variable would be read from the file and grid length and ICC length variables calculated on the fly. That is the smallest ICC size (and amount of work) i can think of.

Photoshop generates extra tags, i am very new to this and don't know why yet.

You can "hack" ..\ Adobe Photoshop\ Presets\ Scripts\ ExportColorLookupTables.jsx file to let you save LUTs of size starting from 2. Just change 7 to 2 in two places (row 69 and row 200). Then save a 2 grid size ICC file, open it and study according to ICC specification to understand how it is formed. It saves the smallest file with least amount of tags, so it's easy to study.

The second block of variables and data Photoshop generates is a presentation of the actual file the ICC abowe was generated from. And it is not needed when setting a Color Lookup layer, works fine without it.

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...
Oct 17, 2020 0