Automating Image Workflows with Power Automate and the Adobe Photoshop API

Raymond Camden
Adobe Tech Blog
Published in
6 min readJul 19, 2023

--

A few months ago, we shared how to automate Photoshop API workflows using Pipedream platform. Pipedream is a great workflow platform for developers, but we thought we’d share an example using Microsoft’s Power Automate service. Power Automate is an incredibly powerful no-code/low-code solution that’s especially appealing for workflows dealing with other Microsoft services, like Sharepoint and the Azure platform. In this post, we’ll share a simple workflow that demonstrates how to use the Photoshop REST APIs with Power Automate.

Prereqs

Before we get started, there are a few things you’ll need in order to replicate what we’re demonstrating on your own account.

  • Obviously, you’ll need a Power Automate account. That’s free to start, but…
  • You will need a premium account in order to use the HTTP connector demonstrated in this article.
  • Finally, you’ll need a free trial of the Photoshop API to get your credentials. You’ll be using them in the workflow created with Power Automate.

With that out of the way, let’s discuss what we’re building.

The Process

One of the simpler, yet still powerful, parts of the Photoshop API is the Lightroom AutoTone feature. It’s what we used in the previous Pipedream integration so it makes sense to use it again. This API will attempt to correct multiple issues in a photo, including exposure, contrast, sharpness and more. Here’s a quick “before and after” example of the API in use:

Before and after showing improvements made by the Lightroom AutoTone API

Our process is going to make use of Azure Blob storage. We will use a trigger in PowerAutomate that fires when a new blob item is added to our storage, kick off an AutoTone call, and store the result in another location in Azure. This will allow for automatic processing of new images uploaded to Azure with no human interaction required.

The Flow

Now that we know what we need and what we’re building, let’s take a look at the completed flow. Everything starts with the trigger, and for ours, it’s tied to an Azure storage action that’s fired when a blob is added or modified:

PowerAutomate trigger tied to a new blob added to Azure Storage

Some things to note here are that when you first start working with Azure’s Storage system, you’ll be prompted to create a connection with your credentials. Once you’ve done that, you can then select that connection in any part of the flow that requires it. Lastly, “container” is how I specified what part of my Azure container I want to monitor.

For the next two steps, we use Power Automate’s “Initialize Variable” actions to define variables for our Photoshop credentials client id and client secret values. These will be used more than once in the following steps so having them as variables lets us re-use them easier.

Two PowerAutomate steps initializing variables related to my Photoshop credentials.

Alright, so in order for the Photoshop API to work, we need to provide it with a cloud storage URL for both input and output. Let’s talk about the input. Our flow was triggered by a new item added to the Azure blob storage. One of PowerAutomate’s built-in actions is the ability to create a “SAS URI” (Shared Access Signature) for a resource. In our case, we can create one based on the asset that was just added, and in the advanced options, ensure it’s set to Read for permissions. The end result of this action is a URL that lets the Photoshop API read the bits of the image that was just added.

The “Create SAS URI by Path” step

Next, we’ll deal with authorization. We need to take our credentials (the client ID and secret defined earlier) and exchange them for an access token. In Power Automate, this is two steps — one to make the HTTP call and another to parse the JSON.

For the HTTP post call, we’re going to pass in the credentials via the URL and send an empty body in the POST.

Defining the POST for credentials.

For parsing the JSON, we cheated a bit at this. We ran the flow in a test, took the results, and used that to generate a schema from the response.

The step that parses the JSON result from getting our auth.

Here’s the actual schema JSON. Note that this isn’t exactly perfect as it doesn’t handle a failed credential result.

Alright, we’re almost ready to fire off the job. Earlier, we got a URL for our input. Now we need a URL for our output. Unfortunately, Power Automate doesn’t have an action that supports this. Instead, we need to use Azure’s own tooling to generate a SAS URL that lets us write back to our storage. There are different ways you can do this, but for this demo, we used the desktop client, Microsoft Azure Storage Explorer. This free tool can be downloaded for multiple operating systems and once you’ve entered your credentials, can be used to both view and edit your Azure storage.

To create a SAS URL, you can right-click on a container, as shown here for our output:

Screen shot from Azure Storage Explorer, showing generating a SAS url.

Select “Write” for permissions, select an appropriate Expiry time, and click Create. This will give a URL like so:

https://exiotransientstorage.blob.core.windows.net/psapiout?sv=2021-10-04&st=2023-07-18T17%3A10%3A17Z&se=2023-07-19T17%3A10%3A17Z&sr=c&sp=w&sig=sigvalue

For the Photoshop API’s output value, we can simply add a path after our container name, in this case, psapiout. We could hard code this, but instead, it would be better to use the filename of the input that triggered the workflow.

To put this all together, a new step based on “Initialize variable” will be used. The name, outputURL, will be of type "String", and we'll generate a URL by using PowerAutomate's concact function like so:

Finally, we’ve got everything gathered to make our call. The AutoTone API reference details everything needed for the call. We begin with an HTTP Post action. For authorization, we’ll use two headers. First is a bearer token containing the access token created earlier, and next x-api-key which uses the client id value.

The body of the POST can be seen in the screenshot below. Make special note of how we use the earlier variables for input and output:

Showing the call to Lightroom API in PowerAutomate

And finally, we’re done! All that’s left to do is test the flow. After activating it, we used Azure Storage Explorer to upload a few images. Here’s an excellent image. First, the initial image.

Landscape picture, a bit dark and washed out

And the automatically improved version:

The much improved version with much more clarity.

Next Steps

This was one of the simpler examples of what you could do with the Photoshop API on Microsoft’s PowerAutomate platform. For more ideas, dig deep into our docs and share your integrations on our forums!

--

--

Raymond Camden is a Senior Developer Evangelist for Adobe. He works on the Document Services tools, JavaScript, and the Jamstack.