adobe-ps-scripts-loreal/API-WORKFLOW.md
DJP 4a192a8c97 Initial commit: Adobe Photoshop API text management scripts
Local and cloud-based workflows for extracting and updating
text layers in PSD files via ExtendScript and Adobe PS API.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 13:46:52 -05:00

3.5 KiB

Adobe Photoshop API Text Layer Update Workflow

This document explains how to update text layers in PSD files using the Adobe Photoshop API with the correct internal layer IDs.

Understanding the Layer ID Problem

The Adobe Photoshop API requires internal layer IDs to correctly identify text layers for updates. These internal IDs are different from the IDs we extract using basic ExtendScript.

The workflow involves:

  1. Extracting the correct internal layer IDs
  2. Updating the JSON files with these IDs
  3. Sending API requests with the correctly identified layers

Step-by-Step Workflow

1. Extract Internal Layer IDs and Create API-Ready JSON

# Process a specific PSD and JSON file pair:
python extract_and_update_json.py --psd-path /path/to/file.psd --json-path /path/to/file-textonly.json

# Process all JSON files in a directory:
python extract_and_update_json.py --directory /path/to/files

# Process files in the current directory:
python extract_and_update_json.py

This creates new JSON files with -api-ready.json suffix containing the internal layer IDs.

2. Update Text Layers with the Adobe API

# Process a specific API-ready JSON file:
python update_text_with_api.py --json-path /path/to/file-api-ready.json

# Process all API-ready JSON files in a directory:
python update_text_with_api.py --directory /path/to/files

# Process files in the current directory:
python update_text_with_api.py

This sends API requests to Adobe using the correct internal layer IDs.

How It Works

Extract and Update JSON (extract_and_update_json.py)

  1. Opens the PSD file in Photoshop
  2. Runs an ExtendScript that extracts the internal layer IDs
  3. Maps these IDs to layer names
  4. Updates the original JSON file with these internal IDs
  5. Saves a new JSON file with the -api-ready.json suffix

Update Text with API (update_text_with_api.py)

  1. Loads the API-ready JSON file
  2. Prepares text layer updates using the internal IDs
  3. Uploads the PSD file to Google Cloud Storage
  4. Sends the API request to Adobe
  5. Monitors the processing status
  6. Downloads the processed file

Common Issues and Troubleshooting

Photoshop Not Responding

If Photoshop doesn't respond when running the extraction script:

  • Close any open documents in Photoshop
  • Restart Photoshop
  • Ensure you have enough memory available

Layer Matching Issues

If you see "Layer not found" messages:

  • Make sure the layer names exactly match between the PSD and JSON files
  • Check for invisible layers or locked layers

API Issues

If you see API errors:

  • Verify your client ID and client secret in config.py
  • Check that the GCS credentials are valid
  • Make sure the JSON structure matches what Adobe expects

Example Workflow

# Step 1: Extract text from PSD files
python mac_ps_extract.py /path/to/psd_files -o /path/to/output_dir

# Step 2: Edit the JSON files with your text changes
# (manual step - update the "updatedText" fields)

# Step 3: Extract internal layer IDs and update JSON
python extract_and_update_json.py --directory /path/to/json_files

# Step 4: Update text using the API
python update_text_with_api.py --directory /path/to/json_files

Additional Notes

  • The processed PSD files are saved in a processed subdirectory
  • API-ready JSON files use the suffix -api-ready.json
  • The original JSON files are never modified
  • All API operations are logged with detailed information

For more details on the layer ID issue and solution, see API-LAYER-ID-SOLUTION.md and SOLUTION-SUMMARY.md.