Auto levels - White point only with action/script

New Here ,
Mar 24, 2021 Mar 24, 2021

Copy link to clipboard

Copied

Hi,

 

I've been trying to create an action that would adjust only the white point of a "levels" adjustment layer using the "auto" function. No success so far.

Actions let me record the results from the "auto" function but then they don't let me change the black/white points values individually.

 

Would anyone know how to do that with a script ?

 

Thanks.

TOPICS
Actions and scripting

Views

239

Likes

translate

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
Most Valuable Participant ,
Mar 24, 2021 Mar 24, 2021

Copy link to clipboard

Copied

Auto levels uses some computer algorithm I know not what. To Adjust the white point you use white eye dropper  or set the white point down some from the default 255.  That you can save as a preset. That would be a custom setting not an auto setting.  So with that in mind  I set a level adjustment manually where I set the black point to 20 from 0, Set the gamma to 1.2 from 1.0 and set the white point to 245 from 255. Then I look at the Action Manager code Adobe's plug-in scriptlistener recorder.  I then used the Clear SL Photoshop Script to make the code more readable.  Then create a javascript Function for Levels that may work  in your Photoshop Script.  I have no idea how you would know the white point the script should set. To make an auto white point script.

 

Action Managet Code:

 

 

// =======================================================
var idhistoryStateChanged = stringIDToTypeID( "historyStateChanged" );
    var desc1440 = new ActionDescriptor();
    var idDocI = charIDToTypeID( "DocI" );
    desc1440.putInteger( idDocI, 1889 );
    var idIdnt = charIDToTypeID( "Idnt" );
    desc1440.putInteger( idIdnt, 1894 );
    var idNm = charIDToTypeID( "Nm  " );
    desc1440.putString( idNm, """Levels""" );
    var idhasEnglish = stringIDToTypeID( "hasEnglish" );
    desc1440.putBoolean( idhasEnglish, true );
    var idItmI = charIDToTypeID( "ItmI" );
    desc1440.putInteger( idItmI, 3 );
executeAction( idhistoryStateChanged, desc1440, DialogModes.NO );

// =======================================================
var idLvls = charIDToTypeID( "Lvls" );
    var desc1441 = new ActionDescriptor();
    var idpresetKind = stringIDToTypeID( "presetKind" );
    var idpresetKindType = stringIDToTypeID( "presetKindType" );
    var idpresetKindCustom = stringIDToTypeID( "presetKindCustom" );
    desc1441.putEnumerated( idpresetKind, idpresetKindType, idpresetKindCustom );
    var idAdjs = charIDToTypeID( "Adjs" );
        var list19 = new ActionList();
            var desc1442 = new ActionDescriptor();
            var idChnl = charIDToTypeID( "Chnl" );
                var ref113 = new ActionReference();
                var idChnl = charIDToTypeID( "Chnl" );
                var idChnl = charIDToTypeID( "Chnl" );
                var idCmps = charIDToTypeID( "Cmps" );
                ref113.putEnumerated( idChnl, idChnl, idCmps );
            desc1442.putReference( idChnl, ref113 );
            var idInpt = charIDToTypeID( "Inpt" );
                var list20 = new ActionList();
                list20.putInteger( 20 );
                list20.putInteger( 245 );
            desc1442.putList( idInpt, list20 );
            var idGmm = charIDToTypeID( "Gmm " );
            desc1442.putDouble( idGmm, 1.200000 );
        var idLvlA = charIDToTypeID( "LvlA" );
        list19.putObject( idLvlA, desc1442 );
    desc1441.putList( idAdjs, list19 );
executeAction( idLvls, desc1441, DialogModes.NO );

 

 

Photoshop Clean SL script code:

 

 

// =======================================================
historyStateChanged(1894, "Levels", true, 3);
function historyStateChanged(ID, name2, hasEnglish, itemIndex) {
	var descriptor = new ActionDescriptor();

	descriptor.putInteger( stringIDToTypeID( "documentID" ), 1889 );
	descriptor.putInteger( stringIDToTypeID( "ID" ), ID );
	descriptor.putString( stringIDToTypeID( "name" ), name2 );
	descriptor.putBoolean( stringIDToTypeID( "hasEnglish" ), hasEnglish );
	descriptor.putInteger( stringIDToTypeID( "itemIndex" ), itemIndex );
	executeAction( stringIDToTypeID( "historyStateChanged" ), descriptor, DialogModes.NO );
}

// =======================================================
levels(1.2);
function levels(gamma) {
	var descriptor = new ActionDescriptor();
	var descriptor2 = new ActionDescriptor();
	var list = new ActionList();
	var list2 = new ActionList();
	var reference = new ActionReference();

	descriptor.putEnumerated( stringIDToTypeID( "presetKind" ), stringIDToTypeID( "presetKindType" ), stringIDToTypeID( "presetKindCustom" ));
	reference.putEnumerated( stringIDToTypeID( "channel" ), stringIDToTypeID( "channel" ), stringIDToTypeID( "composite" ));
	descriptor2.putReference( stringIDToTypeID( "channel" ), reference );
	list2.putInteger( 20 );
	list2.putInteger( 245 );
	descriptor2.putList( stringIDToTypeID( "input" ), list2 );
	descriptor2.putDouble( stringIDToTypeID( "gamma" ), gamma );
	list.putObject( stringIDToTypeID( "levelsAdjustment" ), descriptor2 );
	descriptor.putList( stringIDToTypeID( "adjustment" ), list );
	executeAction( stringIDToTypeID( "levels" ), descriptor, DialogModes.NO );
}

 

 

 

A Function that may work in youe Photoshop script:

 

 

levels(0,1.0,255);   // default no adjustment Black 0, Gamma 1, White 255

function levels(black,gamma,white) {
	var descriptor = new ActionDescriptor();
	var descriptor2 = new ActionDescriptor();
	var list = new ActionList();
	var list2 = new ActionList();
	var reference = new ActionReference();

	descriptor.putEnumerated( stringIDToTypeID( "presetKind" ), stringIDToTypeID( "presetKindType" ), stringIDToTypeID( "presetKindCustom" ));
	reference.putEnumerated( stringIDToTypeID( "channel" ), stringIDToTypeID( "channel" ), stringIDToTypeID( "composite" ));
	descriptor2.putReference( stringIDToTypeID( "channel" ), reference );
	list2.putInteger( black );
	list2.putInteger( white );
	descriptor2.putList( stringIDToTypeID( "input" ), list2 );
	descriptor2.putDouble( stringIDToTypeID( "gamma" ), gamma );
	list.putObject( stringIDToTypeID( "levelsAdjustment" ), descriptor2 );
	descriptor.putList( stringIDToTypeID( "adjustment" ), list );
	executeAction( stringIDToTypeID( "levels" ), descriptor, DialogModes.NO );
}

 

 

JJMack

Likes

translate

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
Adobe Community Professional ,
Mar 24, 2021 Mar 24, 2021

Copy link to clipboard

Copied

It is not clear what you want to say and what your screenshot means.

Likes

translate

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
New Here ,
Mar 25, 2021 Mar 25, 2021

Copy link to clipboard

Copied

Simply put, I'd like a scrit that:

  1. create a "levels" adjustment layer;
  2. activate the "auto" function;
  3. reset the black point to "0" and the gamma to "1.00" no matter what.

 

I really hope somene can help me on this one as this exceeds my competencies.

Likes

translate

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
Most Valuable Participant ,
Mar 25, 2021 Mar 25, 2021

Copy link to clipboard

Copied

You may be able to do that with a smart object layer where levels would be like an adjustment layer.  you may be able the adjust an adjustment layer you added the you set with auto.  Then set  the adjustment black setting to 0 and gamma to 1.    if you apply and auto Levels adjustment  to a layer its a destructive change, You can not then set the Black point to 0 and gamma to 1.  The the layer was changes and the new layer will show its level are  0,  1.0 and 255.    Adjustment layer does not change an image layer's pixels and smart object layer pixels can not be changed.

 

Did you try adding the auto level adjustment layer in and action.  then  later  in the action adjust adjustment layer in the action set black to 0 and gamma to 1 and not change the white point.

JJMack

Likes

translate

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