Making adjustment layers..

Anyone, especially newbies, asking for help with Photoshop Scripting and Photoshop Automation - as opposed to those contributing to discussion about an aspect of Photoshop Scripting

Moderators: Kukurykus, Tom, xbytor

IAMasd98_
Posts: 2
Joined: Mon May 03, 2021 10:24 pm

Making adjustment layers..

Post by IAMasd98_ »

I have managed to make normal layers, but whenever i try to edit it says i can only change the kind to 'normal' or 'text'.
Is it possible to make adjustment layers (like B&W)?

User avatar
Kukurykus
Posts: 377
Joined: Mon Jul 25, 2016 12:36 pm

Re: Making adjustment layers..

Post by Kukurykus »

Can you describe how exactly you try to edit adjustement layers?

IAMasd98_
Posts: 2
Joined: Mon May 03, 2021 10:24 pm

Re: Making adjustment layers..

Post by IAMasd98_ »

I try to make them like this, but it says i can only change the kind to "NORMAL" or "TEXT".

Code: Select all

const newLayer = app.activeDocument.artLayers.add()
newLayer.kind = LayerKind.BLACKANDWHITE
Am i missing something here?

User avatar
Kukurykus
Posts: 377
Joined: Mon Jul 25, 2016 12:36 pm

Re: Making adjustment layers..

Post by Kukurykus »

'kind' is read only property. You can't add adjustement layer by Document Object Model. Do it with with Action Manager.

IAMasd98_
Posts: 2
Joined: Mon May 03, 2021 10:24 pm

Re: Making adjustment layers..

Post by IAMasd98_ »

I really don't get the Action Manager. I checked the documentation, but it didn't really help.. Do you know any guides or something to the Action Manager?

Edit: nvm i kind of get it now, that i found ps sdk and with the scriptlistener, BUT i don't find anything related to what are the inputs that the events need (like "eventMake" or stuff like that)
Last edited by IAMasd98_ on Tue May 04, 2021 5:53 pm, edited 1 time in total.

User avatar
Kukurykus
Posts: 377
Joined: Mon Jul 25, 2016 12:36 pm

Re: Making adjustment layers..

Post by Kukurykus »

Good you found ScriptListener. Add B&W adjustement layer, change some value and check the log.

User avatar
txuku
Posts: 134
Joined: Thu Jan 01, 1970 12:00 am

Re: Making adjustment layers..

Post by txuku »

Bonjour
Tu dors??? :)

I just tried with CS5 by curiosite
This gives this :!

Code: Select all

// =======================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        ref3.putClass( idAdjL );
    desc4.putReference( idnull, ref3 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc5 = new ActionDescriptor();
        var idGrup = charIDToTypeID( "Grup" );
        desc5.putBoolean( idGrup, true );
        var idType = charIDToTypeID( "Type" );
            var desc6 = new ActionDescriptor();
            var idpresetKind = stringIDToTypeID( "presetKind" );
            var idpresetKindType = stringIDToTypeID( "presetKindType" );
            var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
            desc6.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
            var idRd = charIDToTypeID( "Rd  " );
                var desc7 = new ActionDescriptor();
                var idRd = charIDToTypeID( "Rd  " );
                var idPrc = charIDToTypeID( "#Prc" );
                desc7.putUnitDouble( idRd, idPrc, 100.000000 );
            var idChMx = charIDToTypeID( "ChMx" );
            desc6.putObject( idRd, idChMx, desc7 );
            var idGrn = charIDToTypeID( "Grn " );
                var desc8 = new ActionDescriptor();
                var idGrn = charIDToTypeID( "Grn " );
                var idPrc = charIDToTypeID( "#Prc" );
                desc8.putUnitDouble( idGrn, idPrc, 100.000000 );
            var idChMx = charIDToTypeID( "ChMx" );
            desc6.putObject( idGrn, idChMx, desc8 );
            var idBl = charIDToTypeID( "Bl  " );
                var desc9 = new ActionDescriptor();
                var idBl = charIDToTypeID( "Bl  " );
                var idPrc = charIDToTypeID( "#Prc" );
                desc9.putUnitDouble( idBl, idPrc, 100.000000 );
            var idChMx = charIDToTypeID( "ChMx" );
            desc6.putObject( idBl, idChMx, desc9 );
        var idChnM = charIDToTypeID( "ChnM" );
        desc5.putObject( idType, idChnM, desc6 );
    var idAdjL = charIDToTypeID( "AdjL" );
    desc4.putObject( idUsng, idAdjL, desc5 );
executeAction( idMk, desc4, DialogModes.NO );

// =======================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref4 = new ActionReference();
        var idSnpS = charIDToTypeID( "SnpS" );
        ref4.putClass( idSnpS );
    desc10.putReference( idnull, ref4 );
    var idFrom = charIDToTypeID( "From" );
        var ref5 = new ActionReference();
        var idHstS = charIDToTypeID( "HstS" );
        var idCrnH = charIDToTypeID( "CrnH" );
        ref5.putProperty( idHstS, idCrnH );
    desc10.putReference( idFrom, ref5 );
executeAction( idMk, desc10, DialogModes.NO );

// =======================================================
var idslct = charIDToTypeID( "slct" );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref6.putEnumerated( idChnl, idChnl, idRGB );
    desc11.putReference( idnull, ref6 );
    var idMkVs = charIDToTypeID( "MkVs" );
    desc11.putBoolean( idMkVs, false );
executeAction( idslct, desc11, DialogModes.NO );

// =======================================================
var idsetd = charIDToTypeID( "setd" );
    var desc12 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idLyr, idOrdn, idTrgt );
    desc12.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var desc13 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc13.putString( idNm, "B&W" );
    var idLyr = charIDToTypeID( "Lyr " );
    desc12.putObject( idT, idLyr, desc13 );
executeAction( idsetd, desc12, DialogModes.NO );

// =======================================================
var idsetd = charIDToTypeID( "setd" );
    var desc34 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref17 = new ActionReference();
        var idAdjL = charIDToTypeID( "AdjL" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref17.putEnumerated( idAdjL, idOrdn, idTrgt );
    desc34.putReference( idnull, ref17 );
    var idT = charIDToTypeID( "T   " );
        var desc35 = new ActionDescriptor();
        var idpresetKind = stringIDToTypeID( "presetKind" );
        var idpresetKindType = stringIDToTypeID( "presetKindType" );
        var idpresetKindCustom = stringIDToTypeID( "presetKindCustom" );
        desc35.putEnumerated( idpresetKind, idpresetKindType, idpresetKindCustom );
        var idMnch = charIDToTypeID( "Mnch" );
        desc35.putBoolean( idMnch, true );
        var idGry = charIDToTypeID( "Gry " );
            var desc36 = new ActionDescriptor();
            var idRd = charIDToTypeID( "Rd  " );
            var idPrc = charIDToTypeID( "#Prc" );
            desc36.putUnitDouble( idRd, idPrc, 40.000000 );//luminosite ( rouge)
            var idGrn = charIDToTypeID( "Grn " );
            var idPrc = charIDToTypeID( "#Prc" );
            desc36.putUnitDouble( idGrn, idPrc, 34.000000 );//vert
            var idBl = charIDToTypeID( "Bl  " );
            var idPrc = charIDToTypeID( "#Prc" );
            desc36.putUnitDouble( idBl, idPrc, 34.000000 );//bleu
            var idCnst = charIDToTypeID( "Cnst" );
            var idPrc = charIDToTypeID( "#Prc" );
            desc36.putUnitDouble( idCnst, idPrc, -3.000000 );//constant
        var idChMx = charIDToTypeID( "ChMx" );
        desc35.putObject( idGry, idChMx, desc36 );
    var idChnM = charIDToTypeID( "ChnM" );
    desc34.putObject( idT, idChnM, desc35 );
executeAction( idsetd, desc34, DialogModes.NO );

// =======================================================
var idsetd = charIDToTypeID( "setd" );
try it ?