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

PS Javascript get brig&contrast values - no data?

Engaged ,
Jun 22, 2023 Jun 22, 2023

Copy link to clipboard

Copied

Hey

 

Running this :

var ref = new ActionReference();
ref.putEnumerated(charIDToTypeID("AdjL"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt"));
var desc = executeActionGet(ref);
var data = desc.getList(stringIDToTypeID("adjustment")).getObjectValue(0).getData(stringIDToTypeID("legacyContentData"));

var Brightness= getShortIntFromData(data, 0),
var Contrast= getShortIntFromData(data, 2),
var UseLegacy= (getShortIntFromData(data, 4)) ? 1 : 0


If the bri&contrast is set to Use Legacy = I get all data

But if its "new" then I can't get any data no matter what I do.

Any idea, any1 ?

 

Regards
Dariusz

TOPICS
Actions and scripting , Windows

Views

374

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

People's Champ , Jun 22, 2023 Jun 22, 2023

Try thia

 

function get_contrast_desc(id)
    {
    try {
        var r = new ActionReference();
        var d = new ActionDescriptor();

        r.putProperty(stringIDToTypeID("property"), stringIDToTypeID("json"));
        r.putEnumerated(stringIDToTypeID("document"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
        d.putReference(stringIDToTypeID("null"), r);

        d.putInteger(stringIDToTypeID("layerID"), id);
        d.putBoolean(stringIDToTypeID("layerInfo"), true);

...

Votes

Translate

Translate
Adobe
People's Champ ,
Jun 22, 2023 Jun 22, 2023

Copy link to clipboard

Copied

Try thia

 

function get_contrast_desc(id)
    {
    try {
        var r = new ActionReference();
        var d = new ActionDescriptor();

        r.putProperty(stringIDToTypeID("property"), stringIDToTypeID("json"));
        r.putEnumerated(stringIDToTypeID("document"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
        d.putReference(stringIDToTypeID("null"), r);

        d.putInteger(stringIDToTypeID("layerID"), id);
        d.putBoolean(stringIDToTypeID("layerInfo"), true);

        d.putBoolean(stringIDToTypeID( "includeAncestors" ), false);

        eval("var json="+executeAction(stringIDToTypeID("get"), d, DialogModes.NO).getString(stringIDToTypeID("json")));

        var d = new ActionDescriptor();

        if (!json.layers) return d;
        if (json.layers.length != 1) return d;
        if (json.layers[0].id != id) return d;

        var adj = json.layers[0].adjustment;

        if (!adj) return d;

        if (adj.brightness != undefined) d.putInteger(stringIDToTypeID("brightness"), adj.brightness);
        if (adj.center     != undefined) d.putInteger(stringIDToTypeID("center"),     adj.center);
        if (adj.useLegacy  != undefined) d.putBoolean(stringIDToTypeID("useLegacy"),  adj.useLegacy);

        return d;
        }
    catch (e) { throw(e); }
    }

Votes

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
Engaged ,
Jun 22, 2023 Jun 22, 2023

Copy link to clipboard

Copied

This is incredible!

Also how? Why when what?!

Also if we can get data as json, can we also set data from json? O.O

Tell me more, I must know!!! O.O

 

Also, 

        eval("var json=" + executeAction(stringIDToTypeID("get"), d, DialogModes.NO).getString(stringIDToTypeID("json")));
This seems to make json object? o.O Dict? O.O eval = XX does dicts from strings/returns? O.O

Regards

Dariusz

 

Votes

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 ,
Jun 24, 2023 Jun 24, 2023

Copy link to clipboard

Copied

LATEST

This is very interesting! I am using a script that I wrote myself few years ago which is reading the values from a levels layer using getData(stringIDToTypeID("legacyContentData")) which is not working anymore in PS 24.6 . I played with your function and json.layers[0].adjustment.brightness it really reads the value! But what are the new names for channel values for Levels adjustments layer? In my old scripts I was parsing something like Dariusz using getShortIntFromData

 

Best regards,

Alain

Votes

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