Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[tech summit] Use new aio app structure for example photoshop worker #68

Merged
merged 9 commits into from
Mar 9, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions ga-aio-projects/worker-cc-photoshop/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@

# package directories
node_modules
jspm_packages

# build
build
dist
.manifest-dist.yml

# Config
config.json
.env*
.aio

# Adobe I/O console config
console.json

# Test output
junit.xml

# IDE & Temp
.cache
.idea
.nyc_output
.vscode
coverage
.aws.tmp.creds.json
.wskdebug.props.tmp

# Parcel
.parcel-cache

# OSX
.DS_Store

# yeoman
.yo-repository

# logs folder for aio-run-detached
logs

139 changes: 139 additions & 0 deletions ga-aio-projects/worker-cc-photoshop/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
# CC Photoshop Api Worker

## Overview

The CC Photoshop Api Worker wraps the Photoshop APIs to be used by AEM. It is built on top of [aio-lib-photoshop](https://github.com/adobe/aio-lib-photoshop-api).

It provides the following functionality:

- [Run a Photoshop Action](#photoshop-action) on an image

## Enabling the APIs in I/O Console

In order to utilize these APIs, the APIs are added to the existing Asset Compute I/O Console integration that is automatically created by Cloud Manager on behalf of the user. Authentication is done service to service through a JWT created based on the technical account associated with the I/O Console integration. This all done behind the scenes by AEM already. The following APIs exposed in I/O Console are used:

- Photoshop API - Creative Cloud Automation Services

These can be enabled in a AEM Cloud environment by following these steps:

- Log in to <https://console.adobe.io/>
- Switch to the correct organization in the top right corner. This must be the org where your AEM Cloud environment exists.
jdelbick marked this conversation as resolved.
Show resolved Hide resolved
- Switch to the Projects page
- [Create a new project using the App Builder Template](https://experienceleague.adobe.com/docs/asset-compute/using/extend/setup-environment.html?lang=en). Move into the workspace you would like to work in.
- Add the necessary services for Asset Compute Development: I/O Management API, Asset Compute, I/O Events
jdelbick marked this conversation as resolved.
Show resolved Hide resolved
- Also add the following service necessary for creating this worker:
- Add _Photoshop API - Creative Cloud Automation Services_:
- Click on _Add to Project_
- Select _API_
- Click on _Photoshop API - Creative Cloud Automation Services_
- Click on _Next_
- Select _Service Account (JWT)_
- Click on _Next_, which takes you to the Create a new Service Account (JWT) credential
- The public key is already provided
- Click on _Next_
- Select _Default Creative Cloud Automation Services configuration_
- Click on _Save configured API_

## API
### Photoshop Action

Uses the [Photoshop Actions API](https://github.com/adobe/aio-lib-photoshop-api#PhotoshopAPI+applyPhotoshopActions)

REST API: https://adobedocs.github.io/photoshop-api-docs-pre-release/#api-Photoshop-photoshopActions

Supported formats:

- Input: `png`, `jpeg`, `psd`
- Output: `png`, `jpeg`, `psd`

```json
{
"worker": "<custom-worker-url>",
"name": "rendition.jpg",
"fmt": "jpg",
"photoshopActions": "<presigned-url>"
}
```

You can test using our sample [fisheye photoshop action](./files/fisheye.atn).

#### Example Photoshop Action with multiple actions in the set
If you have an action file with multiple photoshop actions in the set, use the `photoshopActionsName` parameter to call only one of the actions.
```
{
"worker": "https:/mynamespace.adobeioruntime.net/api/v1/web/myactionname/worker-cc-photoshop",
"name": "rendition.jpg",
"photoshopActions":"<presigned-url>",
"photoshopActionsName": "Oil Paint Action 1"
}
```
_Note: All actions in the set will be played if none are specified_

## Limitations

- Creative Automation APIs do not support multi-part upload and only support a single URL. This means outputs larger than 100MB on Azure are not currently supported.
jdelbick marked this conversation as resolved.
Show resolved Hide resolved
- The Creative Processing Profile UI in AEM only supports a single operation
jdelbick marked this conversation as resolved.
Show resolved Hide resolved
- Only use `.atn` files with one photoshop action in the set
jdelbick marked this conversation as resolved.
Show resolved Hide resolved


## Setup

Requirements:

- Access to _Photoshop API - Creative Cloud Automation Services_ in the [Adobe Developer Console](https://console.adobe.io).
- [Node.js](https://nodejs.org/en/), version 10 or 12
jdelbick marked this conversation as resolved.
Show resolved Hide resolved
- [aio cli](https://github.com/adobe/aio-cli)
- [Docker Desktop](https://www.docker.com/products/docker-desktop)

### Create App Builder Project

Review the [Asset Compute Extensibility Documentation](https://experienceleague.adobe.com/docs/asset-compute/using/extend/understand-extensibility.html?lang=en#extend) for more detailed information.

- [Setup a developer environment](https://experienceleague.adobe.com/docs/asset-compute/using/extend/setup-environment.html?lang=en#extend) including the App Builder project
- Make sure to add _Photoshop API - Creative Cloud Automation Services_ Service Account (JWT) API to the workspaces
- Select your App Builder project
- Select the Workspace where you added the Photoshop API service
- Click on _Download All_ in the top right corner. This will download the _Adobe I/O Developer Console configuration file_

### Deploy

- Download the sources of this repository
- Go to the `worker-cc-photoshop` directory
- Run `npm install`
- Run `aio app use <Path to Adobe I/O Developer Console configuration file>`
- This will setup your `.env` to point at the App Builder project and workspace
- Run `aio app deploy` to deploy the application

### Review logs

- Use `aio app logs` to review the logs of the most recent invocation

## Integrating with AEM Cloud Service

### Create a Processing Profile

- From the AEM homepage, navigate to Tools -> Assets -> Processing profiles -> Create
- Select the Custom tab
- Add a rendition name and extension
- For _Endpoint URL_, input the URL of the worker as seen after running `aio app deploy`:
- It should look like this: `https://<namespace>.adobeioruntime.net/api/v1/web/<appname>-0.0.1/<worker-name>`
- _Note: If you see a different hostname: `adobeio-static.net`, your action got deployed with Web Assets. If this was not on purpose, please remove the Web Assets using `aio app delete web-assets`. Actions deployed with Web Assets use different authentification that is not supported out of the box by the Asset Compute Service. See details [here](https://www.adobe.io/app-builder/docs/getting_started/common_troubleshooting/#action-authentication-errors)._
- Add `photoshopActions` service parameter and set the value to presigned url for a photoshop action
- Click on Save

![Processing Profile](./files/processingProfile.png)

### Associate Processing Profile with Folder

- Select the created Processing Profile
- Click on _Apply Profile to Folder(s)_
- Select a folder
- Click on _Apply_


### End to end test

- Upload a PNG or JPG to the folder that has the _Processing Profile_ associated with it
- Wait for the asset to stop processing
- Click on the asset
- Click on renditions
10 changes: 10 additions & 0 deletions ga-aio-projects/worker-cc-photoshop/_dot.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

# Specify your secrets here
# This file must not be committed to source control

## Adobe I/O Runtime credentials
AIO_runtime_auth=''
AIO_runtime_namespace=''
AIO_runtime_apihost='https://adobeioruntime.net'
## Adobe I/O Console service account credentials (JWT) Api Key
SERVICE_API_KEY=''
4 changes: 4 additions & 0 deletions ga-aio-projects/worker-cc-photoshop/app.config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

extensions:
dx/asset-compute/worker/1:
$include: src/dx-asset-compute-worker-1/ext.config.yaml
Loading