0.0.1 • Published 9 months ago

@adobe-csc/photoshop v0.0.1

Weekly downloads
-
License
MIT
Repository
-
Last release
9 months ago

Photoshop Manifest Client

A collection of PSD Document Manifest operations thatprovide the ability to get relevant information about the document useful for automation tasks. This library is powered by Jsonata

READ FIRST

This library is developped based on a naming convention of the Adobe Photoshop layer names. All dynamic / replaceable layer names are expected to be in the following format:

{{layerName}}

The libray will treat all layers (text, smart objects, artboards, etc) that follow this naming convention as dynamic layers.

Using this library

  • Install the package using npm install @adobe-csc/photoshop
  • Create an instance of the manifest client by passing a valid Photoshop document manifest object to the constructor.

Get the PSD Document Manifest

Follow the steps documented in the Firefly Services PS API: https://developer.adobe.com/firefly-services/docs/photoshop/api/photoshop_getManifest/

Initialize the library using the following code snippet:

import { ManifestClient } from '@adobe-csc/photoshop';
const  manifest: DocumentManifest = {/* manifest object */}
const manifestClient = new ManifestClient(manifest);

Get all artboards

const artboards:Array<Layer> = await manifestClient.getArtboards();

Get all replaceable text layers

const layers:Array<Layer> = await manifestClient.getVariableTextLayers();

Replace text in all replaceable text layers

The JSON data is expected to be an Array<TextLayerContentReplacement>.

Here is an example:

const jsonData:Array<TextLayerContentReplacement> = [
    {
        "LayerName":{
            "text":{
                "contents:"new text"
            }
        }
    }
]

Then pass the JSON data to the replaceTextLayerContent method.

const layers:Array<Layer> = await manifestClient.replaceTextLayerContent(jsonData);

Get all replaceable smart objects

const layers:Array<Layer> = await manifestClient.getVariableSmartObjects();

Replace smart object with a presignedUrl

The JSON data is expected to be an Array<SmartObjectReplacement>.

Here is an example:

const jsonData:Array<SmartObjectReplacement> = [
    {
        background: {
            href: "https://example.com/image.jpg",
            storage: "external",
        }
    }
]

Then pass the JSON data to the replaceTextLayerContent method.

const layers:Array<Layer> = await manifestClient.replaceSmartObjects(jsonData);

Unit Testing

  • Run npm run test from the root of this package folder.

JSONATA Expressions

The jsonata expressions used in this library are available as text files here: ./src/jsonata

Local Development Setup

  • Clone the mono repo
  • Install the dependencies using npm install
  • Run the tests using npm test
0.0.1

9 months ago