/adobe-ps-api-sdk-sample

Adobe DI SDK Beta

Primary LanguageJavaScriptMIT LicenseMIT

Adobe DI SDK (Public Beta)

Preparation

Create Photoshop API credential

  1. Sign up to create a credential in order to use Photoshop API. When creating a credential, a zip file (config.zip) will be automatically downloaded. It contains your private key (private.key). Please store the private key securely, since Adobe does not retain a copy of it.

Prepare Storage

AWS

  1. Create AWS accont
  2. Set up AWS CLI
    1. Install AWS CLI
    2. Configure AWS CLI options: aws configure
    3. Test AWS CLI: aws s3 ls to list S3 objects

Download this project

  1. Clone this project: git clone https://github.com/kmikawa/adobe-ps-api-sdk-sample.git
  2. Install node modules: npm install
  3. Unzip your downloaded config.zip and save private.key as config/private.key in this project
  4. Save config/config-template.js as config/config.js
  5. Fill the following configuration in config/config.js, save, and close.
// Adobe Photoshop API Configuration
// https://developer.adobe.com/console/projects -> project -> Service Account (JWT)
const adobeConfig = {
  clientId: "",
  clientSecret: "",
  technicalAccountId: "",
  orgId: "",
  metaScopes: ["ent_ccas_sdk"],
};
// AWS Configuration
// https://aws.amazon.com/console/
const awsConfig = {
  region: "", // us-east-1
  bucketName: "" // aws s3 bucket name
}

Sample Script

Run a sample script (src/sample/psapi/...)

  1. Run a sample
node src/sample/psapi/01_createCutout.js
  1. Find your output file in your S3 storage, output directory (ex: s3://<awsConfig.bucketName>/output/...)

Run a sample scrip for a batch job (src/sample/batch_script/...)

  1. Store multiple JPEG files in your S3 storage (ex: s3://<awsConfig.bucketName>/input/...) or modify input/output directories in the sample script.
// -------------------------------------------------
// Enter your parameters
// -------------------------------------------------
const inputDir = 'input/' //your input directory in S3 bucket (ex: s3://<awsConfig.bucketName>/input)
const outputDir = 'output' //your output directory in S3 bucket (ex: s3://<awsConfig.bucketName>/input/output)

const listObjectsInputRequest = { //URI Request Parameters
  // Add more request as you like.  see https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListObjectsV2.html for more details
  Bucket: awsConfig.bucketName, //Bucket name to list.
  Prefix: inputDir, // Keys that begin with the indicated prefix.
  MaxKeys: 5 // Sets the maximum number of keys returned in the response. By default the action returns up to 1,000 key names.
};
// -------------------------------------------------
  1. Run a sample
node src/sample/batch_job/01_createCutout_batch.js
  1. Find your output files in your S3 storage, output directory (ex: s3://<awsConfig.bucketName>/input/output/...)
  • You can also use AWS CLI to sync files from your S3 storage into your local machine (ex: aws s3 sync s3://<awsConfig.bucketName>/input/output/ /Users/<username>/Desktop/output/)

Links