Community图像github.com

yb2460/cli-anything-photoshop

通过 COM 自动化操控 Adobe Photoshop 的 CLI harness。支持项目管理、图层操作、选区控制、文字编辑、图像调整和多格式导出。

cli-anything-photoshop 是什么?

cli-anything-photoshop is a Claude Code agent skill that 通过 COM 自动化操控 Adobe Photoshop 的 CLI harness。支持项目管理、图层操作、选区控制、文字编辑、图像调整和多格式导出。.

兼容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/yb2460/harness-anything/tree/master/photoshop-harness/skills/cli-anything-photoshop

Installed? Explore more 图像 skills: steipete/songsee, affaan-m/frontend-design, mattpocock/improve-codebase-architecture · View all 6 →

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

CLI-Anything Photoshop

A command-line tool for controlling Adobe Photoshop via the Windows COM automation interface.

Prerequisites

  • Windows 10/11
  • Adobe Photoshop 2023+ (COM interface must be registered)
  • Python 3.10+ and the pywin32 package

Installation

cd photoshop-harness/agent-harness
pip install -e .

After installation, you can use the cli-anything-photoshop command.

Command Structure

cli-anything-photoshop [--json] [--project <path>] [--dry-run] <command-group> <command> [options]

Global Options

OptionDescription
--jsonOutput in JSON format (for AI Agent parsing)
--project <path>Automatically open or create a PSD project file
--dry-runExecute the command without saving to disk

Command Groups

project — Project Management

CommandOptionsDescription
new <path>-w width, -h height, -r resolution, -m mode, -b bg-colorCreate a new PSD
open <path>Open a PSD file
save [path]Save the document
close--no-saveClose the document

document — Document Operations

CommandOptionsDescription
infoDocument info
resize-w width, -h height, -r resolutionResize dimensions
canvas-w width, -h height, -a anchorResize canvas
crop--left --top --right --bottomCrop
rotate-a angleRotate canvas
flip-d directionFlip canvas
mode-m modeChange color mode
trim-t typeTrim edges

layer — Layer Operations

CommandOptionsDescription
add-n name, -t type, -o opacity, -b blendAdd a layer
delete-n nameDelete a layer
duplicate-n name, --new-name nameDuplicate a layer
rename--old name, --new nameRename
show / hide-n nameShow/Hide
opacity-n name, -o opacitySet opacity
blend-n name, -m modeSet blend mode
listList all layers
reorder-n name, -p positionReorder
merge-n name, --with-layer nameMerge layers

selection — Selection Operations

CommandOptionsDescription
allSelect all
noneDeselect
invertInvert selection
feather-r radiusFeather
expand-p pixelsExpand
contract-p pixelsContract
border-w widthBorder selection
rect--left --top --right --bottomRectangular selection
fill-c color, -o opacityFill selection

text — Text Operations

CommandOptionsDescription
add-t text, -f font, -s size, -c colorAdd text
edit-n name, -t text, -f font, -s size, -c colorEdit text
info-n nameText info

export — Export

CommandOptionsDescription
save <path>-f format, -q quality, -w width, -h heightExport file

repl

CommandDescription
replStart interactive REPL mode

Usage Examples

AI Agent Usage (--json mode)

# Create a new project and get JSON output
cli-anything-photoshop --json project new -w 800 -h 600 poster.psd

# Add a text layer
cli-anything-photoshop --json --project poster.psd text add -t "Hello World" -f Arial -s 48 -c "#FF0000"

# List all layers (JSON format)
cli-anything-photoshop --json --project poster.psd layer list

# Export as PNG
cli-anything-photoshop --json --project poster.psd export save -f png output.png

# Preview (without saving)
cli-anything-photoshop --dry-run --project poster.psd layer add -n "draft" --type text

Human Usage

# Open a PSD, interactive editing
cli-anything-photoshop --project work.psd layer list

# Start REPL
cli-anything-photoshop repl

Agent Usage Guide

  1. Always use the --json flag for structured output
  2. Use --dry-run to preview before committing to a save
  3. Error handling: Check stderr for JSON error objects when exit code is non-zero
  4. Project state: Use --project to automatically manage file open/save
  5. REPL mode: Suitable for multi-step interactive operations, reducing Photoshop process startup overhead

Photoshop COM Architecture

CLI command → Click CLI → Core module → ComBridge (singleton) → Photoshop.Application COM → Photoshop engine

Photoshop exposes its full editing capabilities through the Windows COM interface. This harness wraps the most commonly used operations. To extend, refer to the Adobe Photoshop COM documentation and add new methods to utils/com_bridge.py.

Individual skills in this repo

This repo contains 1 individual skill — each has its own dedicated page.

相关技能