Reading and altering Levels Adjustment Layers with PS Script

Upload Photoshop Scripts, download Photoshop Scripts, Discussion and Support of Photoshop Scripts

Moderators: Tom, Kukurykus

pspal

Reading and altering Levels Adjustment Layers with PS Script

Post by pspal »

Hi there,

I recently got into photoshop scripting. I am building a desktop application that controls functions within Photoshop. For example, if an onscreen slider in the app is mapped to Red color in Photoshop, then when this onscreen slider is moved in the desktop app, it controls and moves the "Red" slider in the color Panel in Photoshop.

Similarly, now I am trying to control "Levels" layer values such as: inputRangeStart, inputRangeEnd, inputRangeGamma, outputRangeStart, outputRangeEnd

Here is what I want to do:
1) Get the current "inputRangeStart" value
2) Increment inputRangeStart by a certain integer
3) The Levels graph UI slider should change and move to the new position

Currently I am using ExtendScript ToolKit to test my scripts. Using some scripts I found in this form I was able to figure out step (2), but I am having issues with steps (1) and (3).

1) How can i read the current values of a particular Levels layer?
- Yes, when the layer is first created the values by default are: inputRangeStart = 0, inputRangeEnd = 255, inputRangeGamma = 1.0, outputRangeStart = 0, outputRangeEnd = 255. Thats easy
- But what if I change any of these values and I happen to come back to the same layer later, how do I read the active levels layer values and then proceed to alter it?

3) As I have mentioned above I have figured out how to change the values using adjustLevels model of a Levels layer. But when I increment say inputRangeStart from 0 to 10, the UI slider under the graph doesnt update automatically. It only updates when I select a different layer and go back to my Levels Layer...ugh. Anyways, I was able to script that step as well and it works...but it's such a horrible solution..I was wondering if there was another way to make sure the UI updated after the value is changed on the fly.

And ofcourse I have tried to use the scriptlistener, unfortunately it doesnt detect the changes made to the darks, gamma, whites etc.

I really appreciate your help. Any thoughts, feedback and suggestions would be great. Thanks!
pspal

Reading and altering Levels Adjustment Layers with PS Script

Post by pspal »

Just checking to see if anyone has had any luck with this? Thanks again!