Photoshop Cutout
Overview
This skill drives an already-open Photoshop session through COM automation. It is for live desktop workflows where Codex must work against the document the user already has open, not for offline image processing pipelines.
Trigger Conditions
Use this skill when:
- Photoshop is already installed and running on Windows.
- The user wants Codex to connect to the currently open Photoshop document.
- The task is subject cutout, background removal, transparent PNG export, white-background export, or placing a refined cutout back into the source document.
- The user wants a closed-loop result with concrete output paths.
Primary Workflow
- Confirm Photoshop is open and the target image document is visible.
- If multiple Photoshop documents are open, make the intended document active first. If needed, pass
-SourceDocumentNameto the script. - Run scripts/photoshop-cutout.ps1.
- Read back the script output:
transparent_fullkeeps the original canvas size.transparent_trimtrims transparent borders.white_jpgandwhite_pngare white-background exports.placed_backreports whether the refined result is now represented in the source document.used_existing_cutoutreports whether the script had to fall back to an existingCodex Cutout Refinedlayer because Photoshop would not perform a fresh automatic subject selection.
Direct Script Usage
Run the script directly when you want deterministic execution:
powershell -ExecutionPolicy Bypass -File .\skills\photoshop-cutout\scripts\photoshop-cutout.ps1
Useful flags:
-OutputDir <path>writes exports to a chosen folder. Default is.\photoshop_cutout.-BaseName <name>changes the output filename prefix.-SourceDocumentName <name>targets a specific open Photoshop document by name.-PlacedLayerName <name>changes the name of the layer placed back into the source document.-ExistingLayerName <name>changes the name used for fallback export from an already refined layer.-SkipPlaceBackexports files without placing the transparent result back into the source document.-SkipWhiteExportsexports only transparent outputs.-KeepPreviousCodexLayerleaves an existing refined layer in the source document instead of replacing it.-DisableExistingCutoutFallbackfails fast instead of reusing an existing refined layer.
Example:
powershell -ExecutionPolicy Bypass -File .\skills\photoshop-cutout\scripts\photoshop-cutout.ps1 `
-SourceDocumentName "Portrait.psd" `
-OutputDir "C:\Exports\Photoshop" `
-BaseName "portrait_a"
Decision Notes
- Prefer the active document when it is clearly the user document.
- If Photoshop has helper or temporary documents open, the script prefers a non-helper document and then breaks same-name ties by choosing the document with more layers.
- If fresh automatic cutout fails but the source document already contains an
ExistingLayerNamelayer, the script can still export usable transparent and white-background outputs from that layer. - If the user asks for exact ID-photo sizes, run this skill first and then resize the exported white-background output in a separate follow-up step.
Troubleshooting
Read references/troubleshooting.md when:
- Photoshop is open but no document is being found.
- Multiple documents are open and the wrong one is selected.
used_existing_cutout=trueappears in the output.- Fresh subject selection is unavailable in the current Photoshop session.
Resources
scripts/photoshop-cutout.ps1: Main automation entry point.references/troubleshooting.md: Failure modes and recovery guidance.