Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Prompt for Levels not working in Photoshop CC

Explorer ,
Sep 03, 2013 Sep 03, 2013

Hi,

I was helped on here a few months ago about a script that would promopt the user to create a levels adjustment layer, set the levels and then the script would be able to call the information again and apply the levels without user intervention.

Since upgrading to Photoshop CC it has stopped working correctly and I can't figure out why as it doesn't come up with any errors. It works on the prompt, alows the user to enter levels ect but when it comes to apply it to the next image it will just create an unaltered levels adjustment and move on. The script is below, any help would be much appreciated!

/// user prompt

var newLevelsDesc = newLevels();

//// apply levels without user

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

function newLevels() {

    try{

var desc2 = new ActionDescriptor();

var ref1 = new ActionReference();

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

desc2.putReference( charIDToTypeID('null'), ref1 );

var desc3 = new ActionDescriptor();

var desc4 = new ActionDescriptor();

desc4.putEnumerated( stringIDToTypeID('presetKind'), stringIDToTypeID('presetKindType'), stringIDToTypeID('presetKindDefault') );

desc3.putObject( charIDToTypeID('Type'), charIDToTypeID('Lvls'), desc4 );

desc2.putObject( charIDToTypeID('Usng'), charIDToTypeID('AdjL'), desc3 );

return executeAction( charIDToTypeID('Mk  '), desc2, DialogModes.ALL );

}

catch (e){

    }

};

TOPICS
Actions and scripting
1.4K
Translate
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
Guru ,
Sep 05, 2013 Sep 05, 2013

It seems that Adobe has changed the way this works with Photoshop CC. In prior versions the newLevels() function returns a new Action Descriptor that contains the level settings the user entered into the levels dialog. In Photoshop CC it returns the Action Descriptor created by the function. It does not cause an error because the descriptor has the required info to make a new levels adjustment layer using the default settings.

I don't see an easy way around this change. The best I have been able to come up with is to let the user create the new levels adjustment layer. Then get the settings from that layer and store them in an .alv file. The script can then create a new levels adjustment layer and apply the .alv file. I have not found an easy way to use the current settings directly to make a new layer and the temp .alv file in required for this approach. I think it would be possible to create a function that converts the raw data in the stringIDToTypeID('legacyContentData') key to an Action Descriptor that can be used to make a new layer. That function would be much easier to create if it only had to support the RGB color mode. Creating such a function would eliminate the need for the temp .alv file.

If the script is designed to work in a single session you could dupe the adjustment layer with the user's settings to a new document( or leave the document that contains the layer open ) and dupe that layer to other documents as needed. That method should work with most versions including CC.

Translate
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
Guru ,
Sep 05, 2013 Sep 05, 2013
LATEST

This seems to work in Photoshop CC.

function levelsAdjustmentDialog(){

       var desc = new ActionDescriptor();

        var ref = new ActionReference();

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

    desc.putReference( charIDToTypeID('null'), ref );

        var desc3 = new ActionDescriptor();

            var desc4 = new ActionDescriptor();

            desc4.putEnumerated( stringIDToTypeID('presetKind'), stringIDToTypeID('presetKindType'), stringIDToTypeID('presetKindDefault') );

        desc3.putObject( charIDToTypeID('Type'), charIDToTypeID('Lvls'), desc4 );

    desc.putObject( charIDToTypeID('Usng'), charIDToTypeID('AdjL'), desc3 );

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

        var desc = new ActionDescriptor();

            var ref = new ActionReference();

            ref.putEnumerated( charIDToTypeID( "AdjL" ), charIDToTypeID( "Ordn" ), charIDToTypeID( "Trgt" ) );

        desc.putReference( charIDToTypeID( "null" ), ref );

        desc.putObject( charIDToTypeID( "T   " ), charIDToTypeID( "Lvls" ), new ActionDescriptor() );

    return user_levels = executeAction( charIDToTypeID( "setd" ), desc, DialogModes.ALL );

};

function makeLevelsAdjustmentLayer( userDesc ) {

    var desc = new ActionDescriptor();

        var ref = new ActionReference();

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

    desc.putReference( charIDToTypeID('null'), ref );

        var desc3 = new ActionDescriptor();

            var desc4 = new ActionDescriptor();

            desc4.putEnumerated( stringIDToTypeID('presetKind'), stringIDToTypeID('presetKindType'), stringIDToTypeID('presetKindDefault') );

        desc3.putObject( charIDToTypeID('Type'), charIDToTypeID('Lvls'), desc4 );

    desc.putObject( charIDToTypeID('Usng'), charIDToTypeID('AdjL'), desc3 );

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

    if(userDesc!=undefined){

        executeAction( charIDToTypeID( "setd" ), userDesc, DialogModes.NO );

    }

};

var desc = levelsAdjustmentDialog();

makeLevelsAdjustmentLayer( desc );

Translate
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