Skip to main content
Participant
July 29, 2024
Answered

Programmatically Set Gray Point in Curves Adjustment Using a Random Pixel

  • July 29, 2024
  • 3 replies
  • 620 views

Hi everyone,

I'm trying to automate a color balancing process using Photoshop scripting. I'd like to achieve the following steps programmatically:

  1. Duplicate the background layer.

  2. Apply an Average Blur filter to the duplicated layer.

  3. Add a Curves Adjustment Layer.

  4. Select the middle pipette tool (sample in image to set gray point).

  5. Simulate a mouse click on a random pixel of the blurred layer.

  6. Hide the blurred layer after the gray point is set.

  7. Merge all layers.

I've managed to script the first three steps, but I'm struggling with how to programmatically control the gray point pipette tool.

  • Is it possible to select this tool and simulate a click on a specific pixel through the API?

  • Alternatively, is there a way to directly set the gray point value in the Curves adjustment without using the pipette?

Any help or code examples would be greatly appreciated!

Thanks in advance for your help!

This topic has been closed for replies.

3 replies

r-binCorrect answer
Legend
July 29, 2024
ja5E92Author
Participant
July 29, 2024

Thank you very, very much.

Legend
July 29, 2024

This isn't going to work the way you want. Imagine a hypothetical image that is 0 black or 255 white. You can't use middle grey with either one. This is why you have to use exposure compensation with an in-camera light meter for things like snowy conditions.

c.pfaffenbichler
Community Expert
Community Expert
July 29, 2024

Instead of using the Gray Point Sampler you could evaluate the Histogram and (as there should be only one value with non-zero numbers) use that in the Curves Adjustment. 

ja5E92Author
Participant
July 29, 2024

Thank you. Could you help me generate the script? Or specifically, that part that you are suggesting? I'm a beginner in all of this. Thank you so much in advance! 🙂