Copy link to clipboard
Copied
Does Adobe Lightroom have an SDK or a set of APIs that will let me do something like this:
// fetch a photo image file from local hard drive or network
Image img_original = Image.FromFile("C:\Event123\original\DSC_1337.jpg");
// Use Lightroom's ToneControl.Auto on the ORIGINAL image to create a NEW image
Image img_new = LightroomUtilities.ToneControl.Auto(img_original);
// take that NEW image and perform Lightroom's WhiteBalance.Auto on it
img_new = LightroomUtilities.WhiteBalance.Auto(img_new);
// save the NEW image to a local folder
img_new.Save("C:\Event123\corrected\DSC_1337.jpg");
I've researched Lightroom's APIs and Firefly APIs several times for the past several months. And I do not thing this is possible.
Here's the context...
I photograph events where I may shoot 1000s (or tens of 1000s) of photos. Then after the event, I load the photos into Lightroom and run Tone Control > Auto on all of them. And often White Balance > Auto as well. I usually do this in batches of about 1000 to 2000 images at a time.
What I'd like to do is have Lightroom do these tasks for me automatically during the event while I am shooting.
I'm a software developer, so I already have my own software to move image files from the camera to a computer, from drive to drive, up to the web, etc. I don't need Lightroom to do any of these things for me.
All I need is to tell Lightroom...
Then when I'm ready, my code needs to tell Lightroom to do the same thing for my next image.
What I'm really looking for is an SDK or a set of local API endpoints (not in the cloud) so that I can access Lightroom features without having to open up Lightroom.
Is what I'm asking for possible?
Thanks!
Lightroom Classic has an SDK with an extensive API that lets you control most aspects of the catalog and photo processing. You can download the SDK, including both an API reference and an introductory Lightroom Classic SDK Programmers Guide, from here:
https://developer.adobe.com/console/67648/servicesandapis
I can't give you a direct link to the SDK because that web site is horribly designed and confusing.
Beware there's a pretty steep learning curve to do more than write a trivial script, espec
...Copy link to clipboard
Copied
Lightroom Classic has an SDK with an extensive API that lets you control most aspects of the catalog and photo processing. You can download the SDK, including both an API reference and an introductory Lightroom Classic SDK Programmers Guide, from here:
https://developer.adobe.com/console/67648/servicesandapis
I can't give you a direct link to the SDK because that web site is horribly designed and confusing.
Beware there's a pretty steep learning curve to do more than write a trivial script, especially if you don't know the Lua programming language, a very minimal but powerful language in which most of the LR app is written. I highly recommend investing a couple hours reading a Lua tutorial.
Debugging LR plugins with print statements is a huge waste of time. Invest in learning the Zerobrane IDE or my Debugging Toolkit for Lightroom Plugins. The toolkit is not as powerful as the IDE but is better integrated with Lightroom's task architecture.
If you try to just dive in and hack without learning Lua or getting a debugger, you'll regret it.
* * *
Some hints about where to start:
To set White Balance to Auto, you can do:
photo:applyDevelopSettings {WhiteBalance = "Auto"}
But you can't do that for Auto Settings. The only way for a plugin to set Auto Settings is by applying a preset with photo:applyDevelopPreset(). So you might define a preset that sets both Auto Settings and White Balance and have the plugin apply that preset.
Copy link to clipboard
Copied
Thank you, @johnrellis. I'll check out the Zerobrane IDE and your Debugging Toolkit. As well as the SDK link you posted.
And help me make sure that I understand you correctly. When you say "But you can't do that for Auto Settings," are you saying that it's not possible to perform the Tone Control > Auto feature using the SDK (per my screen snip in the OP)?
That's my main purpose for wanting to access LR features via SDK. I want LR to auto-adust the exposure, contast, highlights, shadows, whites, blacks, vibrance and saturation for each individual image. On the fly. The composition, colors, lighting, etc can vary from image to image. So a single preset would not work.
Or perhaps is there a way to do an auto-set for each of those individual properties? auto-exposure, auto-contast, auto-highlights, etc.
Thanks!
Copy link to clipboard
Copied
A plugin can't use photo:applyDevelopSettings() to set Auto Settings. But it can apply a preset that sets Auto Settings and White Balance using photo:applyDevelopPreset().
Copy link to clipboard
Copied
Thanks so much, @johnrellis. I'm sure what you're saying will become obvious to me after I've dug into it for a while.
Copy link to clipboard
Copied
@RD Hi
It is possible to run Auto Tone via SDK but only in Develop using
LrDevelopController.setAutoTone()
If you are looking for a way to do Auto Tone automatically in Library then is better to apply a preset as @johnrellis said.
.
Copy link to clipboard
Copied
Thanks for that info, @C.Cella!
I gather that when you and @johnrellis mention the notions of "in Library" and "in Develop" that you are refering to what we see here in the LR UI. Correct?
In Library ...
In Develop ...
If so, that begins to make sense.
I'm still thinking very simplisticly, like the way I wrote my pseudo-code in my OP. As I get into the SDK and the docs, I'll post my progress and solution here.
My 3rd grade brain tells me that the first thing I need to figure out how to do is to tell the LR SDK which image file on my hard drive that I want to work with. Then do the setAutoTone() and a SaveImage() method of some kind.
LrDevelopController.GetImage("C:\Event123\original\DSC_1337.jpg");
LrDevelopController.setAutoTone();
LrDevelopController.SaveImage("C:\Event123\corrected\DSC_1337.jpg");
Thanks again. I feel like you're pointing me in the right direction.
Copy link to clipboard
Copied
Figure out what you want to do manually, using LR's terminology and concepts: import one or more photos to the LR catalog, apply a preset to those photos, then export them in the desired format. Then look at the APIs corresponding to that terminology.
Copy link to clipboard
Copied
Very helpful. Thank you, @johnrellis.
Copy link to clipboard
Copied
@RD Hi wrote
"I'd like to do is have Lightroom do these tasks for me automatically during the event while I am shooting ...
... I'm a software developer, so I already have my own software to move image files from the camera to a computer, from drive to drive, up to the web, etc. I don't need Lightroom to do any of these things for me.
All I need is to tell Lightroom...
I don't understand this workflow, but I can tell you that the SDK will do very little to help you.
In order for LrC to do anything to an image, it must be Imported into a catalog first.
You say "I already have my own software to move image files from the camera to a computer". Is this while you are shooting the event? If so, how is the camera connected to the computer? Is it tethered?
LrC's Tethered Capture allows you to apply a Develop Preset on capture; it is easy to create a Develop Preset to apply Auto Settings and Auto WB.
If you can't use Tethered Capture or don't want to, then LrC can be configured to Auto Import from a 'Watched Folder'; the same applies as in the Tethered Capture, a Preset can be applied on Auto Import.
Trying to do what you want with the SDK is not easy, but it is possible. I question why would you bother when LrC is already capable of doing it for you.
I also ask why do you need Step 4 while shooting at an event?
Copy link to clipboard
Copied
Thank you @drtonyb for your thoughts and feedback. You're essentially asking the most important question of all. Which is "What are you actually trying to accomplish? What's the overall business problem you're trying to solve?"
However, I need the scope of this conversation to be confined to how to access LrC's Tone Control > Auto and White Balance > Auto features on an image programatically, automatically, locally and outside of the LrC UI.
Like I mentioned in my OP, I've already built all the processes in my workflow. From the camera, to the backend, to a retail frontend. These processes have been in place for years. They are modular, fast, robust, don't spend time rendering to a screen, and run completely unattended by a human.
Plus, I already have a process in place that does exactly what I'm exploring with LrC. I'm merely exploring an alternative. And I like what I see from those 2 Adobe LrC features.
And you may be correct, that the LrC SDK won't do what I'm asking. I mentioned that possibility in my OP. But I'll find out for sure and post my results here.
Thanks!
Copy link to clipboard
Copied
It seems that you want to use the LrC SDK outside of LrC. Not possible.
For your information, here is a script that prompts for image files, imports them and then applies an existing Develop Preset named "Auto Preset" which is saved in the group named "Auto".
local LrApplication = import 'LrApplication'
local LrDialogs = import 'LrDialogs'
local LrTasks = import 'LrTasks'
local function getDevelopPreset( presetName, folderName )
local group
local developPreset
for _, folder in ipairs( LrApplication.developPresetFolders() ) do
if folder:getName() == folderName then
group = folder
break
end
end
if nil ~= group then
for _, preset in ipairs( group:getDevelopPresets() ) do
if preset:getName() == presetName then
developPreset = preset
break
end
end
end
return developPreset
end
LrTasks.startAsyncTask( function()
local presetGroup = 'Auto'
local presetName = 'Auto Preset'
local catalog = LrApplication.activeCatalog()
local preset = getDevelopPreset( presetName, presetGroup )
if nil == preset then
LrDialogs.message( string.format( 'Failed to find the %s', presetName ) )
else
local sources = catalog:getActiveSources()
local folderPath = nil ~= sources[1] and 'LrFolder' == sources[1]:type() and sources[1]:getPath()
local images = LrDialogs.runOpenPanel( {
title = 'Import Photo',
canChooseFiles = true,
canChooseDirectories = false,
canCreateDirectories = false,
allowsMultipleSelection = true,
initialDirectory = folderPath,
} )
if nil ~= images then
local photo
for _, imagePath in ipairs( images ) do
catalog:withWriteAccessDo( string.format( 'Import Photo with %s', presetName ), function( context )
photo = catalog:addPhoto( imagePath, nil, nil, nil, preset:getUuid() )
if nil ~= photo then
photo:applyDevelopPreset( preset )
end
end )
end
-- select the last imported photo
catalog:setSelectedPhotos( photo, {} )
end
end
end )
Place the script with a .lua extension in a folder called Scripts under "%appdata%\Adobe\Lightroom", then start LrC. Scripts can be launched from the Scripts menu in LrC.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now