AWS Partner Network (APN) Blog
Scaling Image Manipulation Workflows with Adobe Photoshop API on AWS
By Chirag Oswal, Partner Solutions Architect – AWS
By Yoginder Sethi, Sr. Solutions Architect – AWS
By Archy Posada, Sr. Product Manager – Adobe
Adobe |
The power and flexibility of Adobe Photoshop (and Lightroom) has moved to the cloud via a new set of developer APIs. These APIs allow for powerful integrations including ecommerce generators and other content automation streams.
Organizations can now get Photoshop technology in the cloud, giving you the ability to scale content workflows and save time and money in the process.
In this post, we’ll look at what Amazon Web Services (AWS) developers can add to their toolbox and how they can use different AWS services to build scalable image manipulation workflow.
Adobe is an AWS Competency Partner and AWS Marketplace Seller that helps customers create, deliver, and optimize compelling content and applications.
Architecture and Workflow
The solution’s architecture consists of following AWS services:
- Amazon Simple Storage Service (Amazon S3) buckets:
- Source bucket where user uploads image.
- Destination bucket where image returned by Photoshop API is available.
- AWS Lambda function which is triggered by S3 and contains logic to talk to Photoshop API.
- AWS Secret Manager which contains data required to authenticate with Photoshop API.
- Amazon CloudFront which allows user to access final image through edge location closest to user.
Figure 1 – Adobe Photoshop API architecture on AWS.
The workflow contains the following high-level steps:
- User uploads image to the source S3 bucket; in our example, this an image a user wants the background removed through Photoshop API.
- Image uploaded to S3 triggers the Lambda function which does the following:
- Calls AWS Secret Manager to fetch credentials required to talk to Photoshop API.
- Calls the Photoshop API with JWT token and passes image; it then gets the image back with background removed.
- Lambda stores the image (with background removed) to the destination S3 bucket which is mapped to Amazon CloudFront.
- Final image is available to user through CloudFront, allowing access through CloudFront edge location which is closest to user.
Prerequisites
To start, you will need to have an AWS account and an Adobe Developer account. Then, follow this documentation to set up your AWS account.
Make sure you have an AWS account that has permissions to access the following services:
- AWS Identity and Access Management (IAM)
- Amazon CloudFront
- AWS Lambda
- Amazon S3
- AWS Secrets Manager
- AWS CloudFormation
Subscribing Photoshop API
Sign in to your AWS account with your credentials, and navigate to the Adobe Photoshop API listing on AWS Marketplace.
Click on View Purchase Options, and then click Subscribe.
Next, you’ll see a green banner at the top of your screen. Click on the Set up your account button.
Figure 2 – AWS Marketplace subscription page.
This will take you to the Adobe Developer site to create your credentials. Log in using your Adobe ID. Once signed in, you’ll be asked to enter a project name. After choosing a project name, click on the blue Create credentials button.
This generates your credentials for the Adobe Photoshop API and a config.zip file will be downloaded automatically. This zip file contains a public key and private key which you’ll need in the next step.
Click on Generate access token in I/O console. At this stage, you should be able in the Adobe Developer console.
On the left navigation page, click on Service Account (JWT).
Next, copy Client ID and Client Secret and paste it in your notepad. We’ll use these credentials in the further steps.
Figure 3 – Adobe Developer console showcasing credential details.
Click on Generate JWT on the top. Then, copy JWT Payload and paste it in your notepad.
Figure 4 – Adobe Developer console, showcasing JWT credential details.
Verify Your Subscription
To verify if you have successfully subscribed to the Photoshop API, navigate to your AWS account.
Search for “marketplace” and click on AWS Marketplace Subscriptions. You’ll see Adobe Photoshop API listed under your subscriptions.
Deploying AWS CloudFormation Template
Sign into the AWS Management Console and click the launch stack button below to deploy the AWS CloudFormation template.
If you need to change the AWS region, choose a different one by using the region selector in the upper right corner of the navigation bar.
Default stack name is photoshop-demo, and you can also edit the name of your choice.
Copy and paste the values of ClientId and ClientSecret you saved in the earlier step.
Copy and paste the values of iss, sub, and aud from the JWT Payload you saved in the earlier step.
Copy and paste the value of PrivateKey from the config.zip file.
Check the acknowledge box and click Submit.
Figure 5 – Entering parameters in AWS CloudFormation.
The CloudFormation template will take approximately 12 minutes to spin up the following AWS services in your account:
- Amazon CloudFront
- AWS Lambda
- Amazon S3
- AWS Secrets Manager
Exploring Lambda Function
The code snippet below shows the core logic of invoking remove background feature of the Photoshop API.
Figure 6 – Lambda function displaying the Photoshop API code.
You can navigate to the Lambda console and click on photoshop-demo-CoreLogicStack—PsApiLambdaFunction-***** to learn more about the entire Lambda function.
Test the Setup
Navigate to the source S3 bucket. For example, the bucket name will look like photoshop-demo-corelogicstack-********-sourcebucket-*******
Figure 7 – Amazon S3 source bucket.
Upload a photo for which you would like to remove the background. Navigate to the destination bucket, and you’ll see a photo has been uploaded with the background removed from it:
Photoshop-demo-cdnstack-*******-destinationbucket-******
Figure 8 – Amazon S3 destination bucket.
Cleanup
To avoid incurring future charges, delete the resources that have been created by this post. Navigate to the CloudFormation console, select your stack, and click Delete. This will delete all of the resources which were deployed earlier by the CloudFormation template.
Conclusion
In this post, we demonstrated how to create an automated workflow for removing backgrounds using the Photoshop API on AWS. We used the “Remove Background” feature of the Photoshop API to remove the background from an image.
To build the automated workflow, we used several AWS services like AWS CloudFormation, Amazon S3, AWS Lambda, and AWS Secrets Manager.
The Adobe Photoshop API provides full-fidelity Adobe image editing in the cloud. This service includes Adobe Photoshop and Lightroom APIs.
The Adobe Photoshop API and Lambda functions automate time-consuming design tasks, saving hours of manual effort to reduce production costs, increase fidelity on output, and empower the creative team do what they do best—create.
By subscribing to the Photoshop API on AWS Marketplace, users can leverage Adobe’s Photoshop, Lightroom, and artificial intelligence (AI) platform to build scalable photo editing workflows on AWS.
Adobe – AWS Partner Spotlight
Adobe is an AWS Competency Partner that helps customers create, deliver, and optimize compelling content and applications.