Quitter
  • Communauté internationale
    • Langue:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티

PS Javascript get brig&contrast values - no data?

Engagé ,
Jun 22, 2023 Jun 22, 2023

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

SUJETS
Actions et scripting , Windows
475
Traduire
Signaler
Directives de la communauté
Restez bienveillant et courtois, ne vous attribuez pas la paternité des créations d’autrui et assurez-vous de l’absence de doublons avant de poster du contenu. En savoir plus
community guidelines

correct answers 1 bonne réponse

Défenseur du peuple , 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);

...
Traduire
Adobe
Défenseur du peuple ,
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);

        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); }
    }
Traduire
Signaler
Directives de la communauté
Restez bienveillant et courtois, ne vous attribuez pas la paternité des créations d’autrui et assurez-vous de l’absence de doublons avant de poster du contenu. En savoir plus
community guidelines
Engagé ,
Jun 22, 2023 Jun 22, 2023

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

 

Traduire
Signaler
Directives de la communauté
Restez bienveillant et courtois, ne vous attribuez pas la paternité des créations d’autrui et assurez-vous de l’absence de doublons avant de poster du contenu. En savoir plus
community guidelines
Nouveau ici ,
Jun 24, 2023 Jun 24, 2023
LA PLUS RÉCENTE

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

Traduire
Signaler
Directives de la communauté
Restez bienveillant et courtois, ne vous attribuez pas la paternité des créations d’autrui et assurez-vous de l’absence de doublons avant de poster du contenu. En savoir plus
community guidelines