Copy link to clipboard
Copied
If you add a "Brightness/Contrast" adjustment layer in Photoshop? You can click the Auto button to have Photoshop make its best guess on what would be best for the current image.
If you try to record this as an Action however, it just records the specific Brightness/Contrast settings that were used -- not the variable "Auto" functionality itself.
Is there a way to automate this via Photoshop scripting? Some kind of .jsx code?
Thanks!
Copy link to clipboard
Copied
The best solution I can think of is, a .jsx file for Photoshop scripting that opens each image file from the desired folder, adds some default brightness/contrast layer, quite literally sends an arbitrary mouse click to the active window to click the Auto button, waits 5-30 seconds (depending on how safe I want to be to ensure it runs to completion), then finishes the job via more .jsx code to save the image and close the current document, then rinse and repeat until I'm done with the entire folder. Best idea I've got, given that this apparently can't be done EITHER via Photoshop scripting OR via Photoshop actions.
Copy link to clipboard
Copied
var d = new ActionDescriptor();
var r = new ActionReference();
r.putClass(stringIDToTypeID("adjustmentLayer"));
d.putReference(stringIDToTypeID("null"), r);
var d1 = new ActionDescriptor();
var d2 = new ActionDescriptor();
d2.putBoolean(stringIDToTypeID("auto"), true);
d2.putBoolean(stringIDToTypeID("useLegacy"), false);
d1.putObject(stringIDToTypeID("type"), stringIDToTypeID("brightnessEvent"), d2);
d.putObject(stringIDToTypeID("using"), stringIDToTypeID("adjustmentLayer"), d1);
executeAction(stringIDToTypeID("make"), d, DialogModes.NO);
Copy link to clipboard
Copied
@r-bin - thank you!
Copy link to clipboard
Copied
Works so far. The next challenge is, after it runs the "Auto" Brightness/Contrast functionality? I need to somehow get the Brightness level of that layer, and conditionally check if it's below 0. If so? Set it to zero. Then similarly, I need to get the Contrast level of that layer, and if it's not equal to zero? I need to set it to zero.
I can't seem to find out: A) How to get the Brightness or Contrast level OF the active document's Brightness/Contrast layer, and 2) How to change those values if the conditions aren't met. Any ideas?
Copy link to clipboard
Copied
My code so far:
Copy link to clipboard
Copied
How would this look if I instead wanted to do Auto Levels?
Copy link to clipboard
Copied
How would this look if I instead wanted to do Auto Levels?
By @the_king_of_goats
===========
"Auto" anything is a crap shoot. It will work some of the time but not every time. Your milage will vary.
Quick & easy shortcuts are no guarantee of accuracy. When quality matters (and it should), Levels or Curves adjustments give you precise control over settings & results. "Auto" features don't.
Copy link to clipboard
Copied
The Brightness/Contrast command is one of the legacy commands that was often inferior to other methods when used with photographic images, compared to levels or curves. Adobe then improved the code and added the legacy checkbox for the old behaviour.
In addition to auto options in the traditional commands, there is also the auto command in the Camera Raw filter, which can be scripted and automated:
Copy link to clipboard
Copied
Auto adjustments are hit & miss. Sometimes they work well and other times they make a mess. It really depends on individual image exposure and what needs correction. I see no way to successfully batch this.
For better control, I recommend using Levels or Curves Adjustments on each image separately.
Copy link to clipboard
Copied
I agree that Brightness/Contrast is a bit of a blunt instrument. You sbould be able to get more consistent results another way, and also much more easily than what you propose.
Instead of trying to gain programmatic access to the Auto button in Brightness and Contrast, consider creating an action that uses one or more of the Auto correction commands that are already conveniently available on the Image menu: Auto Tone, Auto Contrast, and Auto Color. Descriptions of what all three do are on the Adobe help page Make Quick Tonal Adjustments.
Furthermore, what those commands do is not set in stone. You can adjust the target colors and default clipping values you want, as described on that Adobe page. Some more background about how those work is in an article by Bruce Fraser, Don’t Underestimate Photoshop’s Auto Color. Although written in 2022, the description of Auto Color options still applies today. (What it calls Auto Levels is now Auto Tone.)
If you want the latest and most advanced automatic correction trained using machine learning, then I agree with the suggestion to run the images through the Auto Settings command available in Adobe Camera Raw or Lightroom Classic, if the image file types are compatible. The advantage here is that you can select any number of images, apply Auto Settings, and it will batch process the lot — without having to create an action or write a script.
If you do it with Camera Raw, I don’t mean not Camera Raw as a filter in Photoshop, but Camera Raw as the processor: That is what will let you batch apply immediately. To use Camera Raw that way, you would first use Adobe Bridge to select all the images, then choose File > Open in Camera Raw, then select all the images there. For Lightroom Classic, you would import all the images, then select them all. In both cases you would export corrected copies.
Copy link to clipboard
Copied
I ran an experiment to test this. I manually adjusted the Brightness level of 100 images to what I believe made them look best. I then compared that against Photoshop's "Auto" Brightness level. On average, there was a difference of only about 1.0 Brightness points between me and Photoshop for the full batch -- which, statistically, is almost meaningless. Additionally, 80% of Photoshop's Auto brightness adjustments were within 20 brightness points of what I would've done manually, and about 60% were within 10 brightness points. 0% of them were over 35 brightness points in difference -- ie so wildly different from my decision that the brightness would look very bad. 0% of the images that I looked at looked so horrendously bad that they made me say: "This looks awful because of the Auto brightness settings that were applied."
The trick to making it work for my workflow is, use it to just Auto adjust the Brightness, then revert the Contrast back to 0. Brightness + Contrast on Auto often looks terrible. Using it for Brightness only, however? It actually has a pretty good eye for, how much brighter an image needs to be to look optimal. At least, compared against how I would do it.
Copy link to clipboard
Copied
Whatever you say.
That's not my preferred workflow for commercial projects.
Best of luck.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now