HELP: PHOTOSHOP SCRIPT : how I retrive the 3DLUT Path from the colorlookup layer properties ?

Community Beginner ,
Mar 06, 2022 Mar 06, 2022

Copy link to clipboard

Copied

Hello,
I'd like to name the color lookup adjustment layer after the name of the 3dlut I have applied.
The script logic is quite simple: if the active layer is a color lookup adjustement layer, then retrive the full path from its properties, extract the base name, and rename the active layer using it.

#target Photoshop

if (app.activeDocument.activeLayer.kind == LayerKind.COLORLOOKUP) {

    var id = app.activeDocument.activeLayer.id;
    
    // how I retrive the 3DLUT Path from the colorlookup layer properties ?
    var lutPath = 'D:\\MyLUTs/Film Emulation\\kodak ektar 100.cube';

    lutPath = lutPath.replace(/\\/g, '/');

    var lutName = lutPath.substring(lutPath.lastIndexOf('/')+1, lutPath.lastIndexOf('.'));

    app.activeDocument.activeLayer.name = lutName;
} 
else {
    alert("Please select a Color Lookup layer!")
}

Can someone to explains me how to retrive the path properties of a color lookup adjustement layer ?

 

Thank you very much.

TOPICS
Actions and scripting

Views

66

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
community guidelines

correct answers 1 Correct answer

Community Beginner , Mar 07, 2022 Mar 07, 2022
I found a solution.. probably not the best one but does the job for me...#target Photoshop // COLORLOOKUP(legacyContentData) - DUMP of rawData.bin // ------------------------------------------------------------------------------ // 00000000 00 01 00 00 00 10 00 00 00 01 00 00 00 00 00 00 |................| // 00000010 6e 75 6c 6c 00 00 00 09 00 00 00 0a 6c 6f 6f 6b |null........look| // 00000020 75 70 54 79 70 65 65 6e 75 6d 00 00 00 0f 63 6f |upTypeenum....co| // 00000030 6c 6f 72 4c...

Likes

Translate

Translate
Community Beginner ,
Mar 07, 2022 Mar 07, 2022

Copy link to clipboard

Copied

LATEST

I found a solution.. probably not the best one but does the job for me...

#target Photoshop

// COLORLOOKUP(legacyContentData) - DUMP of rawData.bin
// ------------------------------------------------------------------------------
// 00000000  00 01 00 00 00 10 00 00  00 01 00 00 00 00 00 00  |................|
// 00000010  6e 75 6c 6c 00 00 00 09  00 00 00 0a 6c 6f 6f 6b  |null........look|
// 00000020  75 70 54 79 70 65 65 6e  75 6d 00 00 00 0f 63 6f  |upTypeenum....co|
// 00000030  6c 6f 72 4c 6f 6f 6b 75  70 54 79 70 65 00 00 00  |lorLookupType...|
// 00000040  05 33 44 4c 55 54 00 00  00 00 4e 6d 20 20 54 45  |.3DLUT....Nm  TE|
// 00000050  58 54 00 00 00 5a 00 43  00 3a 00 5c 00 55 00 73  |XT...Z.C.:.\.U.s|
// 00000060  00 65 00 72 00 73 00 5c  00 49 00 76 00 61 00 6e  |.e.r.s.\.I.v.a.n|
// 00000070  00 6f 00 5c 00 41 00 70  00 70 00 44 00 61 00 74  |.o.\.A.p.p.D.a.t|
// 00000080  00 61 00 5c 00 52 00 6f  00 61 00 6d 00 69 00 6e  |.a.\.R.o.a.m.i.n|
// 00000090  00 67 00 5c 00 41 00 64  00 6f 00 62 00 65 00 5c  |.g.\.A.d.o.b.e.\|
// 000000a0  00 41 00 64 00 6f 00 62  00 65 00 20 00 50 00 68  |.A.d.o.b.e. .P.h|
// 000000b0  00 6f 00 74 00 6f 00 73  00 68 00 6f 00 70 00 20  |.o.t.o.s.h.o.p. |
// 000000c0  00 32 00 30 00 32 00 32  00 5c 00 50 00 72 00 65  |.2.0.2.2.\.P.r.e|
// 000000d0  00 73 00 65 00 74 00 73  00 5c 00 33 00 44 00 4c  |.s.e.t.s.\.3.D.L|
// 000000e0  00 55 00 54 00 73 00 5c  00 69 00 63 00 2d 00 42  |.U.T.s.\.i.c.-.B|
// 000000f0  00 26 00 57 00 20 00 2d  00 20 00 30 00 31 00 2e  |.&.W. .-. .0.1..|
// 00000100  00 63 00 75 00 62 00 65  00 00 00 00 00 00 44 74  |.c.u.b.e......Dt|
// ------------------------------------------------------------------------------

function readUShort(rawData, ndx) 
{
    var byte1 = rawData.charCodeAt(ndx);
    var byte2 = rawData.charCodeAt(ndx + 1);

    var uShort = (byte1 <<8) + byte2;

    return uShort;
}

function readString(rawdata, from, len)
{
    var to = from + (len * 2) + 1;

    var str = "";

    for (var i = from + 1; i < to; i += 2) 
    {
        var val = rawData.charCodeAt(i);
        str += String.fromCharCode(val);
    }

    return str;
}

function readLutPath(rawData)
{
    var pathLen = readUShort(rawData, 0x54);
    var pathURI = readString(rawData, 0x56, pathLen);
    
    return pathURI;
}

if (app.activeDocument.activeLayer.kind == LayerKind.COLORLOOKUP) {

    var id = app.activeDocument.activeLayer.id;

    var ref = new ActionReference();

    ref.putIdentifier(stringIDToTypeID("layer"), id);

    var rawData = executeActionGet(ref).getList(stringIDToTypeID("adjustment")).getObjectValue(0).getData(stringIDToTypeID("legacyContentData"));

    // var dataFile = new File('C:/Users/Ivano/Downloads/rawdata.bin');
    // dataFile.encoding = 'BINARY';
    // dataFile.open('w');
    // dataFile.write(rawData);
    // dataFile.close();
 
    var lutPath = readLutPath(rawData);

    lutPath = lutPath.replace(/\\/g, '/');

    var lutName = lutPath.substring(lutPath.lastIndexOf('/')+1, lutPath.lastIndexOf('.'));

    app.activeDocument.activeLayer.name = lutName;
} 
else {
    alert("Please select a Color Lookup layer!")
}

 

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
community guidelines