Skip to main content
Participant
October 20, 2023
Answered

Get Altitude value from Photoshop Javascript

  • October 20, 2023
  • 2 replies
  • 270 views

I am currently working on a script that returns / get the Altitude value from Layer Style -> Global Light.


I am able to get the Global Light Angle through this script:

var r = new ActionReference ();
r.putEnumerated (stringIDToTypeID ("layer"), stringIDToTypeID ("ordinal"), stringIDToTypeID ("targetEnum"));
alert(executeActionGet (r).getInteger(stringIDToTypeID("globalAngle"));


Here is a list of the properties I could find:

 

If someone knows how I can get the Altitude it would help me out so much!

Thank you for taking your time to read this.

This topic has been closed for replies.
Correct answer r-bin

I think this is a bug that apparently hasn't been fixed yet. You can easily get this data from the "application" object. But for "document" and "layer" it is not so simple. For these objects, try to get the “json” object property, and read the “globalLight” object in it. Your desired values will be there.

2 replies

r-binCorrect answer
Legend
October 25, 2023

I think this is a bug that apparently hasn't been fixed yet. You can easily get this data from the "application" object. But for "document" and "layer" it is not so simple. For these objects, try to get the “json” object property, and read the “globalLight” object in it. Your desired values will be there.

Participant
October 27, 2023

Thank you for writing this! I'll look closer into it! 🙂

Participant
October 25, 2023

Here is a snippet of the Action Listener that sets the Global Light Angle and Altitude. I still havn't figured out how to read the Altitude value. You can see that:

 

 

desc234.putUnitDouble( idgagl, idAng, 90.000000 ); // Sets the Angle
desc234.putUnitDouble( idglobalAltitude, idAng, 30.000000 ); / Sets the Altitude

 

 

The code below is the Action Listener that sets the Global Light:

 

 

// =======================================================
var idsetd = charIDToTypeID( "setd" );
    var desc233 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idPrpr = charIDToTypeID( "Prpr" );
        var idgblA = charIDToTypeID( "gblA" );
        ref2.putProperty( idPrpr, idgblA );
        var idDcmn = charIDToTypeID( "Dcmn" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref2.putEnumerated( idDcmn, idOrdn, idTrgt );
    desc233.putReference( idnull, ref2 );
    var idT = charIDToTypeID( "T   " );
        var desc234 = new ActionDescriptor();
        var idgagl = charIDToTypeID( "gagl" );
        var idAng = charIDToTypeID( "#Ang" );
        desc234.putUnitDouble( idgagl, idAng, 90.000000 );
        var idglobalAltitude = stringIDToTypeID( "globalAltitude" );
        var idAng = charIDToTypeID( "#Ang" );
        desc234.putUnitDouble( idglobalAltitude, idAng, 30.000000 );
    var idgblA = charIDToTypeID( "gblA" );
    desc233.putObject( idT, idgblA, desc234 );
executeAction( idsetd, desc233, DialogModes.NO );