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>
3.5 KiB
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:
- Extracting the correct internal layer IDs
- Updating the JSON files with these IDs
- 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)
- Opens the PSD file in Photoshop
- Runs an ExtendScript that extracts the internal layer IDs
- Maps these IDs to layer names
- Updates the original JSON file with these internal IDs
- Saves a new JSON file with the
-api-ready.jsonsuffix
Update Text with API (update_text_with_api.py)
- Loads the API-ready JSON file
- Prepares text layer updates using the internal IDs
- Uploads the PSD file to Google Cloud Storage
- Sends the API request to Adobe
- Monitors the processing status
- 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
processedsubdirectory - 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.