@alisaitteke/photoshop-mcp 0.1.6 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +233 -179
- package/dist/api/extendscript.d.ts +12 -2
- package/dist/api/extendscript.d.ts.map +1 -1
- package/dist/api/extendscript.js +76 -9
- package/dist/api/extendscript.js.map +1 -1
- package/dist/api/photoshop-api.js +20 -3
- package/dist/api/photoshop-api.js.map +1 -1
- package/dist/platform/macos-executor.d.ts.map +1 -1
- package/dist/platform/macos-executor.js +3 -2
- package/dist/platform/macos-executor.js.map +1 -1
- package/dist/ui/agent.d.ts +44 -0
- package/dist/ui/agent.d.ts.map +1 -0
- package/dist/ui/agent.js +198 -0
- package/dist/ui/agent.js.map +1 -0
- package/dist/ui/cli.d.ts +3 -0
- package/dist/ui/cli.d.ts.map +1 -0
- package/dist/ui/cli.js +96 -0
- package/dist/ui/cli.js.map +1 -0
- package/dist/ui/config.d.ts +16 -0
- package/dist/ui/config.d.ts.map +1 -0
- package/dist/ui/config.js +45 -0
- package/dist/ui/config.js.map +1 -0
- package/dist/ui/providers/anthropic.d.ts +3 -0
- package/dist/ui/providers/anthropic.d.ts.map +1 -0
- package/dist/ui/providers/anthropic.js +72 -0
- package/dist/ui/providers/anthropic.js.map +1 -0
- package/dist/ui/providers/google.d.ts +3 -0
- package/dist/ui/providers/google.d.ts.map +1 -0
- package/dist/ui/providers/google.js +71 -0
- package/dist/ui/providers/google.js.map +1 -0
- package/dist/ui/providers/openai.d.ts +3 -0
- package/dist/ui/providers/openai.d.ts.map +1 -0
- package/dist/ui/providers/openai.js +71 -0
- package/dist/ui/providers/openai.js.map +1 -0
- package/dist/ui/providers/openrouter.d.ts +3 -0
- package/dist/ui/providers/openrouter.d.ts.map +1 -0
- package/dist/ui/providers/openrouter.js +82 -0
- package/dist/ui/providers/openrouter.js.map +1 -0
- package/dist/ui/providers/registry.d.ts +6 -0
- package/dist/ui/providers/registry.d.ts.map +1 -0
- package/dist/ui/providers/registry.js +17 -0
- package/dist/ui/providers/registry.js.map +1 -0
- package/dist/ui/providers/types.d.ts +40 -0
- package/dist/ui/providers/types.d.ts.map +1 -0
- package/dist/ui/providers/types.js +2 -0
- package/dist/ui/providers/types.js.map +1 -0
- package/dist/ui/server.d.ts +10 -0
- package/dist/ui/server.d.ts.map +1 -0
- package/dist/ui/server.js +337 -0
- package/dist/ui/server.js.map +1 -0
- package/dist/ui/store/chats.d.ts +53 -0
- package/dist/ui/store/chats.d.ts.map +1 -0
- package/dist/ui/store/chats.js +89 -0
- package/dist/ui/store/chats.js.map +1 -0
- package/dist/ui/store/db.d.ts +6 -0
- package/dist/ui/store/db.d.ts.map +1 -0
- package/dist/ui/store/db.js +59 -0
- package/dist/ui/store/db.js.map +1 -0
- package/dist/ui/store/kv.d.ts +4 -0
- package/dist/ui/store/kv.d.ts.map +1 -0
- package/dist/ui/store/kv.js +24 -0
- package/dist/ui/store/kv.js.map +1 -0
- package/package.json +42 -6
- package/web/dist/assets/index-Kxyfap9w.js +138 -0
- package/web/dist/assets/index-Th6OF4IB.css +1 -0
- package/web/dist/assets/source-sans-3-latin-wght-normal-BqRLTx4X.woff2 +0 -0
- package/web/dist/index.html +15 -0
- package/web/dist/ps-logo-icon.svg +6 -0
- package/.prettierrc +0 -9
- package/server.json +0 -21
package/README.md
CHANGED
|
@@ -8,6 +8,238 @@
|
|
|
8
8
|
|
|
9
9
|
A Model Context Protocol (MCP) server that enables AI assistants like Claude and Cursor to control Adobe Photoshop programmatically. This allows you to create designs, manipulate images, and automate Photoshop workflows through natural language commands while working in your IDE.
|
|
10
10
|
|
|
11
|
+
## 🖥️ Standalone UI (no IDE required)
|
|
12
|
+
|
|
13
|
+
Don't want to wire this into Claude Desktop or Cursor? The same package ships a
|
|
14
|
+
fully local web UI that lets you chat with an AI model and drive Photoshop
|
|
15
|
+
through this MCP server underneath.
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npx -p @alisaitteke/photoshop-mcp photoshop-mcp-ui
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
That's it. A local server starts on `127.0.0.1` (random free port) and your
|
|
22
|
+
default browser opens the chat UI automatically.
|
|
23
|
+
|
|
24
|
+
### Supported providers
|
|
25
|
+
|
|
26
|
+
Pick any of the following on first launch — bring your own API key:
|
|
27
|
+
|
|
28
|
+
| Provider | Models | Get a key |
|
|
29
|
+
|---|---|---|
|
|
30
|
+
| **Anthropic** | Claude Sonnet / Opus / Haiku | [console.anthropic.com](https://console.anthropic.com/settings/keys) |
|
|
31
|
+
| **OpenAI** | GPT-5, GPT-4.1, o-series | [platform.openai.com](https://platform.openai.com/api-keys) |
|
|
32
|
+
| **Google** | Gemini 2.5 Pro / Flash / Flash-Lite | [aistudio.google.com](https://aistudio.google.com/apikey) |
|
|
33
|
+
| **OpenRouter** | 100+ models from any provider | [openrouter.ai](https://openrouter.ai/keys) |
|
|
34
|
+
|
|
35
|
+
### What happens on first launch
|
|
36
|
+
|
|
37
|
+
1. Pick a provider and paste your API key.
|
|
38
|
+
2. The key is validated against the provider, then stored locally at
|
|
39
|
+
`~/.photoshop-mcp/data.db` (SQLite, `chmod 600`). It never leaves your
|
|
40
|
+
machine.
|
|
41
|
+
3. Type natural-language prompts. The UI streams the model's reply, runs
|
|
42
|
+
Photoshop tool calls in real time, and renders each tool call as an
|
|
43
|
+
inspectable card (input + result).
|
|
44
|
+
4. Switch provider or model anytime from the model selector — chats, costs and
|
|
45
|
+
tool history are persisted across sessions.
|
|
46
|
+
|
|
47
|
+
### CLI flags
|
|
48
|
+
|
|
49
|
+
```
|
|
50
|
+
photoshop-mcp-ui [--port 5174] [--host 127.0.0.1] [--no-open]
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Notes
|
|
54
|
+
|
|
55
|
+
- The agent is restricted to Photoshop MCP tools only — built-in shell, file
|
|
56
|
+
and web tools are disabled.
|
|
57
|
+
- Tech stack: Vue 3 + Tailwind v4 + [shadcn-vue](https://www.shadcn-vue.com/)
|
|
58
|
+
on the frontend; [Hono](https://hono.dev/) + the [Vercel AI SDK](https://sdk.vercel.ai/)
|
|
59
|
+
on the backend. The agent loop talks to this same Photoshop MCP server over
|
|
60
|
+
STDIO — same code path as the IDE integration.
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## Example Prompts
|
|
65
|
+
|
|
66
|
+
Below are example prompts you can use with AI assistants (Claude, Cursor, etc.) when this MCP server is configured:
|
|
67
|
+
|
|
68
|
+
<details>
|
|
69
|
+
<summary>🎨 Basic Design Creation</summary>
|
|
70
|
+
|
|
71
|
+
```
|
|
72
|
+
Create a 1920x1080 Photoshop document with RGB color mode.
|
|
73
|
+
Add a light blue background layer and fill it with RGB(240, 248, 255).
|
|
74
|
+
Add centered text "Welcome" in 64pt font.
|
|
75
|
+
Save as welcome.psd to my Desktop.
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
</details>
|
|
79
|
+
|
|
80
|
+
<details>
|
|
81
|
+
<summary>🖼️ Stock Image Design (with Pexels MCP)</summary>
|
|
82
|
+
|
|
83
|
+
```
|
|
84
|
+
Search Pexels for "mountain sunset" images.
|
|
85
|
+
Create a 1920x1080 Photoshop document.
|
|
86
|
+
Place the downloaded image and fit it to fill the entire canvas.
|
|
87
|
+
Apply a subtle Gaussian blur of 3px.
|
|
88
|
+
Increase brightness by 15 and contrast by 10.
|
|
89
|
+
Add white text "Adventure Awaits" centered at the top in 72pt.
|
|
90
|
+
Set the text opacity to 90% and blend mode to OVERLAY.
|
|
91
|
+
Save as adventure.jpg with quality 10.
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
</details>
|
|
95
|
+
|
|
96
|
+
<details>
|
|
97
|
+
<summary>✨ Photo Enhancement</summary>
|
|
98
|
+
|
|
99
|
+
```
|
|
100
|
+
Open photo.jpg from my Desktop in Photoshop.
|
|
101
|
+
Apply auto levels and auto contrast.
|
|
102
|
+
Apply unsharp mask with amount 120%, radius 1.5, threshold 0.
|
|
103
|
+
Increase saturation by 15.
|
|
104
|
+
Crop to remove 100px from each edge.
|
|
105
|
+
Save as enhanced-photo.jpg with quality 12.
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
</details>
|
|
109
|
+
|
|
110
|
+
<details>
|
|
111
|
+
<summary>🎭 Layer Effects & Blending</summary>
|
|
112
|
+
|
|
113
|
+
```
|
|
114
|
+
Create a 1200x800 document.
|
|
115
|
+
Add a new layer named "Background" and fill with RGB(50, 50, 50).
|
|
116
|
+
Place logo.png at position (100, 100).
|
|
117
|
+
Fit the logo layer to 50% of its current size.
|
|
118
|
+
Set blend mode to SCREEN and opacity to 85%.
|
|
119
|
+
Add another layer, fill with RGB(255, 100, 50).
|
|
120
|
+
Set this layer's blend mode to MULTIPLY and opacity to 60%.
|
|
121
|
+
Merge all visible layers.
|
|
122
|
+
Save as composite.psd.
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
</details>
|
|
126
|
+
|
|
127
|
+
<details>
|
|
128
|
+
<summary>📝 Text Poster Design</summary>
|
|
129
|
+
|
|
130
|
+
```
|
|
131
|
+
Create a 1080x1350 portrait document (Instagram story size).
|
|
132
|
+
Add a layer and fill with gradient-like color RGB(120, 40, 200).
|
|
133
|
+
Add text "SUMMER" at (540, 300) in 96pt.
|
|
134
|
+
Change text color to white RGB(255, 255, 255).
|
|
135
|
+
Set text alignment to CENTER.
|
|
136
|
+
Add another text "2026" at (540, 450) in 128pt, white color.
|
|
137
|
+
Apply Gaussian blur 2px to the background layer.
|
|
138
|
+
Save as summer-poster.png.
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
</details>
|
|
142
|
+
|
|
143
|
+
<details>
|
|
144
|
+
<summary>🎬 Batch Processing</summary>
|
|
145
|
+
|
|
146
|
+
```
|
|
147
|
+
Open image1.jpg.
|
|
148
|
+
Resize to 1920x1080.
|
|
149
|
+
Apply auto contrast.
|
|
150
|
+
Apply subtle sharpen (amount 80%, radius 1.0).
|
|
151
|
+
Save as processed-1.jpg with quality 10.
|
|
152
|
+
Close without saving changes to original.
|
|
153
|
+
|
|
154
|
+
Repeat for image2.jpg and image3.jpg.
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
</details>
|
|
158
|
+
|
|
159
|
+
<details>
|
|
160
|
+
<summary>🖌️ Creative Manipulation</summary>
|
|
161
|
+
|
|
162
|
+
```
|
|
163
|
+
Create a 2000x2000 square document.
|
|
164
|
+
Place abstract-pattern.jpg and fit to fill document.
|
|
165
|
+
Duplicate the layer.
|
|
166
|
+
On the duplicate, apply motion blur at 45 degrees, radius 50px.
|
|
167
|
+
Set blend mode to OVERLAY and opacity to 70%.
|
|
168
|
+
Add centered text "MOTION" in 120pt white.
|
|
169
|
+
Apply a rectangular selection from (200, 200) to (1800, 1800).
|
|
170
|
+
Invert the selection and delete (to create a border effect).
|
|
171
|
+
Flatten the image.
|
|
172
|
+
Save as motion-art.jpg.
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
</details>
|
|
176
|
+
|
|
177
|
+
<details>
|
|
178
|
+
<summary>🎯 Advanced Workflow</summary>
|
|
179
|
+
|
|
180
|
+
```
|
|
181
|
+
Create a 3000x2000 document at 300 DPI for print.
|
|
182
|
+
Place hero-image.jpg and fit to fill the canvas.
|
|
183
|
+
Duplicate the image layer.
|
|
184
|
+
On the duplicate, desaturate it completely.
|
|
185
|
+
Set blend mode to LUMINOSITY and opacity to 50%.
|
|
186
|
+
Create a new layer named "Overlay".
|
|
187
|
+
Fill with RGB(255, 150, 0) and set blend mode to SOFTLIGHT at 30% opacity.
|
|
188
|
+
Add text "PORTFOLIO" at top center (1500, 200) in 96pt.
|
|
189
|
+
Set text color to white.
|
|
190
|
+
Add subtext "2026 Collection" at (1500, 320) in 36pt.
|
|
191
|
+
Create a rectangular selection around the text area.
|
|
192
|
+
Create a layer mask on the overlay layer.
|
|
193
|
+
Merge visible layers.
|
|
194
|
+
Save as portfolio-cover.psd.
|
|
195
|
+
Export as portfolio-cover.jpg at quality 12.
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
</details>
|
|
199
|
+
|
|
200
|
+
<details>
|
|
201
|
+
<summary>🔄 Using Actions</summary>
|
|
202
|
+
|
|
203
|
+
```
|
|
204
|
+
Open my-photo.jpg.
|
|
205
|
+
Play the "Vintage Look" action from "My Actions" set.
|
|
206
|
+
Adjust brightness by -10 to darken slightly.
|
|
207
|
+
Save as vintage-photo.jpg.
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
</details>
|
|
211
|
+
|
|
212
|
+
<details>
|
|
213
|
+
<summary>⚡ Custom Script Execution</summary>
|
|
214
|
+
|
|
215
|
+
```
|
|
216
|
+
Execute this custom ExtendScript code:
|
|
217
|
+
app.beep();
|
|
218
|
+
alert('Processing started!');
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
</details>
|
|
222
|
+
|
|
223
|
+
<details>
|
|
224
|
+
<summary>⏮️ Undo/Redo Operations</summary>
|
|
225
|
+
|
|
226
|
+
```
|
|
227
|
+
Apply Gaussian blur 15px to the active layer.
|
|
228
|
+
[Wait for result]
|
|
229
|
+
Actually, that's too much blur. Undo that.
|
|
230
|
+
Apply Gaussian blur 5px instead.
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
Or:
|
|
234
|
+
|
|
235
|
+
```
|
|
236
|
+
Get the history states to see what operations were performed.
|
|
237
|
+
Undo the last 3 operations.
|
|
238
|
+
Redo 1 step to bring back one operation.
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
</details>
|
|
242
|
+
---
|
|
11
243
|
> **🎨 50+ Tools** | **🖥️ Cross-Platform** | **📦 NPX Ready** | **🔧 ExtendScript API** | **⏮️ Undo/Redo**
|
|
12
244
|
|
|
13
245
|
## Features
|
|
@@ -43,7 +275,7 @@ npx @alisaitteke/photoshop-mcp
|
|
|
43
275
|
### From Source
|
|
44
276
|
|
|
45
277
|
```bash
|
|
46
|
-
git clone https://github.com/
|
|
278
|
+
git clone https://github.com/alisaitteke/photoshop-mcp.git
|
|
47
279
|
cd photoshop-mcp
|
|
48
280
|
npm install
|
|
49
281
|
npm run build
|
|
@@ -816,184 +1048,6 @@ photoshop_open_image({
|
|
|
816
1048
|
})
|
|
817
1049
|
```
|
|
818
1050
|
|
|
819
|
-
## Example Prompts
|
|
820
|
-
|
|
821
|
-
Below are example prompts you can use with AI assistants (Claude, Cursor, etc.) when this MCP server is configured:
|
|
822
|
-
|
|
823
|
-
<details>
|
|
824
|
-
<summary>🎨 Basic Design Creation</summary>
|
|
825
|
-
|
|
826
|
-
```
|
|
827
|
-
Create a 1920x1080 Photoshop document with RGB color mode.
|
|
828
|
-
Add a light blue background layer and fill it with RGB(240, 248, 255).
|
|
829
|
-
Add centered text "Welcome" in 64pt font.
|
|
830
|
-
Save as welcome.psd to my Desktop.
|
|
831
|
-
```
|
|
832
|
-
|
|
833
|
-
</details>
|
|
834
|
-
|
|
835
|
-
<details>
|
|
836
|
-
<summary>🖼️ Stock Image Design (with Pexels MCP)</summary>
|
|
837
|
-
|
|
838
|
-
```
|
|
839
|
-
Search Pexels for "mountain sunset" images.
|
|
840
|
-
Create a 1920x1080 Photoshop document.
|
|
841
|
-
Place the downloaded image and fit it to fill the entire canvas.
|
|
842
|
-
Apply a subtle Gaussian blur of 3px.
|
|
843
|
-
Increase brightness by 15 and contrast by 10.
|
|
844
|
-
Add white text "Adventure Awaits" centered at the top in 72pt.
|
|
845
|
-
Set the text opacity to 90% and blend mode to OVERLAY.
|
|
846
|
-
Save as adventure.jpg with quality 10.
|
|
847
|
-
```
|
|
848
|
-
|
|
849
|
-
</details>
|
|
850
|
-
|
|
851
|
-
<details>
|
|
852
|
-
<summary>✨ Photo Enhancement</summary>
|
|
853
|
-
|
|
854
|
-
```
|
|
855
|
-
Open photo.jpg from my Desktop in Photoshop.
|
|
856
|
-
Apply auto levels and auto contrast.
|
|
857
|
-
Apply unsharp mask with amount 120%, radius 1.5, threshold 0.
|
|
858
|
-
Increase saturation by 15.
|
|
859
|
-
Crop to remove 100px from each edge.
|
|
860
|
-
Save as enhanced-photo.jpg with quality 12.
|
|
861
|
-
```
|
|
862
|
-
|
|
863
|
-
</details>
|
|
864
|
-
|
|
865
|
-
<details>
|
|
866
|
-
<summary>🎭 Layer Effects & Blending</summary>
|
|
867
|
-
|
|
868
|
-
```
|
|
869
|
-
Create a 1200x800 document.
|
|
870
|
-
Add a new layer named "Background" and fill with RGB(50, 50, 50).
|
|
871
|
-
Place logo.png at position (100, 100).
|
|
872
|
-
Fit the logo layer to 50% of its current size.
|
|
873
|
-
Set blend mode to SCREEN and opacity to 85%.
|
|
874
|
-
Add another layer, fill with RGB(255, 100, 50).
|
|
875
|
-
Set this layer's blend mode to MULTIPLY and opacity to 60%.
|
|
876
|
-
Merge all visible layers.
|
|
877
|
-
Save as composite.psd.
|
|
878
|
-
```
|
|
879
|
-
|
|
880
|
-
</details>
|
|
881
|
-
|
|
882
|
-
<details>
|
|
883
|
-
<summary>📝 Text Poster Design</summary>
|
|
884
|
-
|
|
885
|
-
```
|
|
886
|
-
Create a 1080x1350 portrait document (Instagram story size).
|
|
887
|
-
Add a layer and fill with gradient-like color RGB(120, 40, 200).
|
|
888
|
-
Add text "SUMMER" at (540, 300) in 96pt.
|
|
889
|
-
Change text color to white RGB(255, 255, 255).
|
|
890
|
-
Set text alignment to CENTER.
|
|
891
|
-
Add another text "2026" at (540, 450) in 128pt, white color.
|
|
892
|
-
Apply Gaussian blur 2px to the background layer.
|
|
893
|
-
Save as summer-poster.png.
|
|
894
|
-
```
|
|
895
|
-
|
|
896
|
-
</details>
|
|
897
|
-
|
|
898
|
-
<details>
|
|
899
|
-
<summary>🎬 Batch Processing</summary>
|
|
900
|
-
|
|
901
|
-
```
|
|
902
|
-
Open image1.jpg.
|
|
903
|
-
Resize to 1920x1080.
|
|
904
|
-
Apply auto contrast.
|
|
905
|
-
Apply subtle sharpen (amount 80%, radius 1.0).
|
|
906
|
-
Save as processed-1.jpg with quality 10.
|
|
907
|
-
Close without saving changes to original.
|
|
908
|
-
|
|
909
|
-
Repeat for image2.jpg and image3.jpg.
|
|
910
|
-
```
|
|
911
|
-
|
|
912
|
-
</details>
|
|
913
|
-
|
|
914
|
-
<details>
|
|
915
|
-
<summary>🖌️ Creative Manipulation</summary>
|
|
916
|
-
|
|
917
|
-
```
|
|
918
|
-
Create a 2000x2000 square document.
|
|
919
|
-
Place abstract-pattern.jpg and fit to fill document.
|
|
920
|
-
Duplicate the layer.
|
|
921
|
-
On the duplicate, apply motion blur at 45 degrees, radius 50px.
|
|
922
|
-
Set blend mode to OVERLAY and opacity to 70%.
|
|
923
|
-
Add centered text "MOTION" in 120pt white.
|
|
924
|
-
Apply a rectangular selection from (200, 200) to (1800, 1800).
|
|
925
|
-
Invert the selection and delete (to create a border effect).
|
|
926
|
-
Flatten the image.
|
|
927
|
-
Save as motion-art.jpg.
|
|
928
|
-
```
|
|
929
|
-
|
|
930
|
-
</details>
|
|
931
|
-
|
|
932
|
-
<details>
|
|
933
|
-
<summary>🎯 Advanced Workflow</summary>
|
|
934
|
-
|
|
935
|
-
```
|
|
936
|
-
Create a 3000x2000 document at 300 DPI for print.
|
|
937
|
-
Place hero-image.jpg and fit to fill the canvas.
|
|
938
|
-
Duplicate the image layer.
|
|
939
|
-
On the duplicate, desaturate it completely.
|
|
940
|
-
Set blend mode to LUMINOSITY and opacity to 50%.
|
|
941
|
-
Create a new layer named "Overlay".
|
|
942
|
-
Fill with RGB(255, 150, 0) and set blend mode to SOFTLIGHT at 30% opacity.
|
|
943
|
-
Add text "PORTFOLIO" at top center (1500, 200) in 96pt.
|
|
944
|
-
Set text color to white.
|
|
945
|
-
Add subtext "2026 Collection" at (1500, 320) in 36pt.
|
|
946
|
-
Create a rectangular selection around the text area.
|
|
947
|
-
Create a layer mask on the overlay layer.
|
|
948
|
-
Merge visible layers.
|
|
949
|
-
Save as portfolio-cover.psd.
|
|
950
|
-
Export as portfolio-cover.jpg at quality 12.
|
|
951
|
-
```
|
|
952
|
-
|
|
953
|
-
</details>
|
|
954
|
-
|
|
955
|
-
<details>
|
|
956
|
-
<summary>🔄 Using Actions</summary>
|
|
957
|
-
|
|
958
|
-
```
|
|
959
|
-
Open my-photo.jpg.
|
|
960
|
-
Play the "Vintage Look" action from "My Actions" set.
|
|
961
|
-
Adjust brightness by -10 to darken slightly.
|
|
962
|
-
Save as vintage-photo.jpg.
|
|
963
|
-
```
|
|
964
|
-
|
|
965
|
-
</details>
|
|
966
|
-
|
|
967
|
-
<details>
|
|
968
|
-
<summary>⚡ Custom Script Execution</summary>
|
|
969
|
-
|
|
970
|
-
```
|
|
971
|
-
Execute this custom ExtendScript code:
|
|
972
|
-
app.beep();
|
|
973
|
-
alert('Processing started!');
|
|
974
|
-
```
|
|
975
|
-
|
|
976
|
-
</details>
|
|
977
|
-
|
|
978
|
-
<details>
|
|
979
|
-
<summary>⏮️ Undo/Redo Operations</summary>
|
|
980
|
-
|
|
981
|
-
```
|
|
982
|
-
Apply Gaussian blur 15px to the active layer.
|
|
983
|
-
[Wait for result]
|
|
984
|
-
Actually, that's too much blur. Undo that.
|
|
985
|
-
Apply Gaussian blur 5px instead.
|
|
986
|
-
```
|
|
987
|
-
|
|
988
|
-
Or:
|
|
989
|
-
|
|
990
|
-
```
|
|
991
|
-
Get the history states to see what operations were performed.
|
|
992
|
-
Undo the last 3 operations.
|
|
993
|
-
Redo 1 step to bring back one operation.
|
|
994
|
-
```
|
|
995
|
-
|
|
996
|
-
</details>
|
|
997
1051
|
|
|
998
1052
|
---
|
|
999
1053
|
|
|
@@ -55,7 +55,12 @@ export declare const ExtendScriptSnippets: {
|
|
|
55
55
|
*/
|
|
56
56
|
deleteLayer: () => string;
|
|
57
57
|
/**
|
|
58
|
-
* Fill layer with color
|
|
58
|
+
* Fill the active layer with a solid RGB color.
|
|
59
|
+
*
|
|
60
|
+
* ArtLayer has no fillPath() method (that exists on PathItem only).
|
|
61
|
+
* The correct approach is Selection.fill(): preserve any existing
|
|
62
|
+
* selection, otherwise select the whole canvas, fill, then deselect.
|
|
63
|
+
* Background / fully-locked layers cannot be filled, so fail clearly.
|
|
59
64
|
*/
|
|
60
65
|
fillLayer: (red: number, green: number, blue: number) => string;
|
|
61
66
|
/**
|
|
@@ -139,7 +144,12 @@ export declare const ExtendScriptSnippets: {
|
|
|
139
144
|
*/
|
|
140
145
|
adjustBrightnessContrast: (brightness: number, contrast: number) => string;
|
|
141
146
|
/**
|
|
142
|
-
* Adjust hue and
|
|
147
|
+
* Adjust hue, saturation and lightness on the active layer.
|
|
148
|
+
*
|
|
149
|
+
* ArtLayer has no DOM method for Hue/Saturation - adjustColorBalance()
|
|
150
|
+
* is for Color Balance (cyan/red, magenta/green, yellow/blue) and would
|
|
151
|
+
* throw here. The correct path is the "HStr" Action Descriptor which
|
|
152
|
+
* matches the Image > Adjustments > Hue/Saturation menu command.
|
|
143
153
|
*/
|
|
144
154
|
adjustHueSaturation: (hue: number, saturation: number, lightness: number) => string;
|
|
145
155
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extendscript.d.ts","sourceRoot":"","sources":["../../src/api/extendscript.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"extendscript.d.ts","sourceRoot":"","sources":["../../src/api/extendscript.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAqEH;;GAEG;AACH,eAAO,MAAM,oBAAoB;IAC/B;;OAEG;;IASH;;OAEG;yBACkB,MAAM,UAAU,MAAM;IAW3C;;OAEG;;IAYH;;OAEG;4BACqB,MAAM;IAwB9B;;OAEG;2BACoB,MAAM;IAwC7B;;OAEG;0BACmB,MAAM;IAe5B;;OAEG;sBACe,MAAM;IAYxB;;OAEG;uBACgB,MAAM;IAazB;;OAEG;sBACe,MAAM;IAYxB;;OAEG;;IAUH;;OAEG;sBACe,MAAM;IAkBxB;;OAEG;;IAaH;;;;;;;OAOG;qBACc,MAAM,SAAS,MAAM,QAAQ,MAAM;IAyCpD;;OAEG;yBACkB,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;OAEG;2CACoC,MAAM,YAAY,MAAM;IAiD/D;;OAEG;;IAuBH;;OAEG;;IAuBH;;OAEG;;IAuCH;;OAEG;;CAsCJ,CAAC;AAEF;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAUzD"}
|
package/dist/api/extendscript.js
CHANGED
|
@@ -27,7 +27,14 @@ function getContextInfo() {
|
|
|
27
27
|
resolution: doc.resolution,
|
|
28
28
|
colorMode: String(doc.mode),
|
|
29
29
|
layerCount: doc.layers.length,
|
|
30
|
-
hasSelection:
|
|
30
|
+
hasSelection: (function () {
|
|
31
|
+
try {
|
|
32
|
+
return !!(doc.selection && doc.selection.bounds);
|
|
33
|
+
} catch (e) {
|
|
34
|
+
// ExtendScript throws "No such element" when there is no active selection
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
})()
|
|
31
38
|
};
|
|
32
39
|
|
|
33
40
|
if (doc.activeLayer) {
|
|
@@ -274,19 +281,52 @@ export const ExtendScriptSnippets = {
|
|
|
274
281
|
throw new Error('No active layer');
|
|
275
282
|
`,
|
|
276
283
|
/**
|
|
277
|
-
* Fill layer with color
|
|
284
|
+
* Fill the active layer with a solid RGB color.
|
|
285
|
+
*
|
|
286
|
+
* ArtLayer has no fillPath() method (that exists on PathItem only).
|
|
287
|
+
* The correct approach is Selection.fill(): preserve any existing
|
|
288
|
+
* selection, otherwise select the whole canvas, fill, then deselect.
|
|
289
|
+
* Background / fully-locked layers cannot be filled, so fail clearly.
|
|
278
290
|
*/
|
|
279
291
|
fillLayer: (red, green, blue) => `
|
|
280
292
|
if (app.documents.length === 0) {
|
|
281
293
|
throw new Error('No active document');
|
|
282
294
|
}
|
|
283
295
|
var doc = app.activeDocument;
|
|
296
|
+
var layer = doc.activeLayer;
|
|
297
|
+
|
|
298
|
+
if (layer.allLocked) {
|
|
299
|
+
throw new Error('Cannot fill a fully locked layer: ' + layer.name);
|
|
300
|
+
}
|
|
301
|
+
if (layer.kind === LayerKind.TEXT) {
|
|
302
|
+
throw new Error('Cannot fill a text layer. Rasterize it first.');
|
|
303
|
+
}
|
|
304
|
+
|
|
284
305
|
var color = new SolidColor();
|
|
285
306
|
color.rgb.red = ${red};
|
|
286
307
|
color.rgb.green = ${green};
|
|
287
308
|
color.rgb.blue = ${blue};
|
|
288
|
-
|
|
289
|
-
|
|
309
|
+
|
|
310
|
+
var hadSelection = false;
|
|
311
|
+
try {
|
|
312
|
+
hadSelection = doc.selection.bounds != null;
|
|
313
|
+
} catch (e) {
|
|
314
|
+
hadSelection = false;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
if (!hadSelection) {
|
|
318
|
+
doc.selection.selectAll();
|
|
319
|
+
}
|
|
320
|
+
doc.selection.fill(color);
|
|
321
|
+
if (!hadSelection) {
|
|
322
|
+
doc.selection.deselect();
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
return {
|
|
326
|
+
filled: true,
|
|
327
|
+
layerName: layer.name,
|
|
328
|
+
color: { red: ${red}, green: ${green}, blue: ${blue} }
|
|
329
|
+
};
|
|
290
330
|
`,
|
|
291
331
|
/**
|
|
292
332
|
* Resize image
|
|
@@ -761,17 +801,44 @@ export const ExtendScriptSnippets = {
|
|
|
761
801
|
};
|
|
762
802
|
`,
|
|
763
803
|
/**
|
|
764
|
-
* Adjust hue and
|
|
804
|
+
* Adjust hue, saturation and lightness on the active layer.
|
|
805
|
+
*
|
|
806
|
+
* ArtLayer has no DOM method for Hue/Saturation - adjustColorBalance()
|
|
807
|
+
* is for Color Balance (cyan/red, magenta/green, yellow/blue) and would
|
|
808
|
+
* throw here. The correct path is the "HStr" Action Descriptor which
|
|
809
|
+
* matches the Image > Adjustments > Hue/Saturation menu command.
|
|
765
810
|
*/
|
|
766
811
|
adjustHueSaturation: (hue, saturation, lightness) => `
|
|
812
|
+
${helperFunctions}
|
|
813
|
+
|
|
767
814
|
if (app.documents.length === 0) {
|
|
768
815
|
throw new Error('No active document');
|
|
769
816
|
}
|
|
770
817
|
var layer = app.activeDocument.activeLayer;
|
|
771
|
-
|
|
772
|
-
layer.
|
|
773
|
-
|
|
774
|
-
|
|
818
|
+
|
|
819
|
+
if (layer.kind === LayerKind.TEXT || layer.kind === LayerKind.SMARTOBJECT) {
|
|
820
|
+
layer.rasterize(RasterizeType.ENTIRELAYER);
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
var desc = new ActionDescriptor();
|
|
824
|
+
desc.putEnumerated(
|
|
825
|
+
sTID('presetKind'),
|
|
826
|
+
sTID('presetKindType'),
|
|
827
|
+
sTID('presetKindCustom')
|
|
828
|
+
);
|
|
829
|
+
desc.putBoolean(cTID('Clrz'), false);
|
|
830
|
+
|
|
831
|
+
var adjustments = new ActionList();
|
|
832
|
+
var adjustment = new ActionDescriptor();
|
|
833
|
+
adjustment.putInteger(cTID('H '), ${hue});
|
|
834
|
+
adjustment.putInteger(cTID('Strt'), ${saturation});
|
|
835
|
+
adjustment.putInteger(cTID('Lght'), ${lightness});
|
|
836
|
+
adjustments.putObject(cTID('Hsrt'), adjustment);
|
|
837
|
+
desc.putList(cTID('Adjs'), adjustments);
|
|
838
|
+
|
|
839
|
+
executeAction(cTID('HStr'), desc, DialogModes.NO);
|
|
840
|
+
|
|
841
|
+
return {
|
|
775
842
|
adjustment: 'Hue/Saturation',
|
|
776
843
|
hue: ${hue},
|
|
777
844
|
saturation: ${saturation},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extendscript.js","sourceRoot":"","sources":["../../src/api/extendscript.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,MAAM,eAAe,GAAG;;;CAGvB,CAAC;AAEF;;GAEG;AACH,MAAM,cAAc,GAAG
|
|
1
|
+
{"version":3,"file":"extendscript.js","sourceRoot":"","sources":["../../src/api/extendscript.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,MAAM,eAAe,GAAG;;;CAGvB,CAAC;AAEF;;GAEG;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;;;;;;;;;;;;;;;;;;;;;;GAmCjB;CACF,CAAC;AAEF;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAAC,IAAY;IAC/C,OAAO;;;MAGH,IAAI;;;;;GAKP,CAAC,IAAI,EAAE,CAAC;AACX,CAAC"}
|
|
@@ -62,21 +62,38 @@ class ExtendScriptPhotoshopAPI {
|
|
|
62
62
|
return await this.connection.executeScript(wrappedScript);
|
|
63
63
|
}
|
|
64
64
|
wrapInErrorHandling(script) {
|
|
65
|
-
// ExtendScript
|
|
66
|
-
//
|
|
65
|
+
// ExtendScript has no JSON object, so the result is serialized via
|
|
66
|
+
// toSource()/String(). Errors are surfaced with an "ERROR:" prefix
|
|
67
|
+
// that platform executors translate back into thrown Errors.
|
|
68
|
+
//
|
|
69
|
+
// Ruler and type units are temporarily forced to pixels/points so that
|
|
70
|
+
// every DOM API that accepts plain numbers (translate, textItem.size,
|
|
71
|
+
// textItem.position, doc.crop bounds, etc.) behaves consistently
|
|
72
|
+
// regardless of the user's Photoshop preferences. The user's original
|
|
73
|
+
// preferences are restored in the finally block.
|
|
67
74
|
return `
|
|
68
75
|
(function() {
|
|
76
|
+
var __originalRulerUnits = null;
|
|
77
|
+
var __originalTypeUnits = null;
|
|
78
|
+
try { __originalRulerUnits = app.preferences.rulerUnits; } catch (e) {}
|
|
79
|
+
try { __originalTypeUnits = app.preferences.typeUnits; } catch (e) {}
|
|
80
|
+
|
|
69
81
|
try {
|
|
82
|
+
try { app.preferences.rulerUnits = Units.PIXELS; } catch (e) {}
|
|
83
|
+
try { app.preferences.typeUnits = TypeUnits.POINTS; } catch (e) {}
|
|
84
|
+
|
|
70
85
|
var result = (function() {
|
|
71
86
|
${script}
|
|
72
87
|
})();
|
|
73
|
-
// Convert result to string for transport
|
|
74
88
|
if (typeof result === 'object' && result !== null) {
|
|
75
89
|
return result.toSource ? result.toSource() : String(result);
|
|
76
90
|
}
|
|
77
91
|
return String(result);
|
|
78
92
|
} catch (error) {
|
|
79
93
|
return 'ERROR: ' + (error.message || String(error));
|
|
94
|
+
} finally {
|
|
95
|
+
try { if (__originalRulerUnits !== null) app.preferences.rulerUnits = __originalRulerUnits; } catch (e) {}
|
|
96
|
+
try { if (__originalTypeUnits !== null) app.preferences.typeUnits = __originalTypeUnits; } catch (e) {}
|
|
80
97
|
}
|
|
81
98
|
})();
|
|
82
99
|
`.trim();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"photoshop-api.js","sourceRoot":"","sources":["../../src/api/photoshop-api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAiB5C,MAAM,OAAO,mBAAmB;IACtB,MAAM,CAAS;IACf,UAAU,CAAsB;IAExC,YAAY,UAA+B;QACzC,IAAI,CAAC,MAAM,GAAG,IAAI,MAAM,CAAC,qBAAqB,CAAC,CAAC;QAChD,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;IAED,KAAK,CAAC,SAAS;QACb,MAAM,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC,gBAAgB,EAAE,CAAC;QAEhD,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,MAAM,IAAI,KAAK,CAAC,8DAA8D,CAAC,CAAC;QAClF,CAAC;QAED,8CAA8C;QAC9C,MAAM,OAAO,GAAG,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAEpD,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,OAAO,8BAA8B,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;QAElF,IAAI,OAAO,KAAK,KAAK,EAAE,CAAC;YACtB,OAAO,IAAI,eAAe,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC9C,CAAC;aAAM,CAAC;YACN,OAAO,IAAI,wBAAwB,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QACvD,CAAC;IACH,CAAC;IAEO,gBAAgB,CAAC,OAAe;QACtC,oFAAoF;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,MAAM,aAAa,GAAG,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC;QACvD,OAAO,MAAM,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC;IAC5D,CAAC;IAEO,mBAAmB,CAAC,MAAc;QACxC,mEAAmE;QACnE,mEAAmE;QACnE,6DAA6D;QAC7D,EAAE;QACF,uEAAuE;QACvE,sEAAsE;QACtE,iEAAiE;QACjE,sEAAsE;QACtE,iDAAiD;QACjD,OAAO;;;;;;;;;;;;QAYH,MAAM;;;;;;;;;;;;;KAaT,CAAC,IAAI,EAAE,CAAC;IACX,CAAC;IAED,UAAU;QACR,OAAO,cAAc,CAAC;IACxB,CAAC;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"macos-executor.d.ts","sourceRoot":"","sources":["../../src/platform/macos-executor.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAItD,qBAAa,aAAc,YAAW,cAAc;IAClD,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,WAAW,CAAqC;IACxD,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,OAAO,CAAkC;;IAMjD,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAK3B,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE,MAAc,GAAG,OAAO,CAAC,OAAO,CAAC;YAuB1D,YAAY;YAqBZ,aAAa;IAmC3B,OAAO,CAAC,wBAAwB;IAWhC,OAAO,CAAC,WAAW;
|
|
1
|
+
{"version":3,"file":"macos-executor.d.ts","sourceRoot":"","sources":["../../src/platform/macos-executor.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAItD,qBAAa,aAAc,YAAW,cAAc;IAClD,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,WAAW,CAAqC;IACxD,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,OAAO,CAAkC;;IAMjD,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAK3B,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE,MAAc,GAAG,OAAO,CAAC,OAAO,CAAC;YAuB1D,YAAY;YAqBZ,aAAa;IAmC3B,OAAO,CAAC,wBAAwB;IAWhC,OAAO,CAAC,WAAW;IAcb,kBAAkB,IAAI,OAAO,CAAC,OAAO,CAAC;IAUtC,eAAe,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAuB3D;;;OAGG;IACG,uBAAuB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;CAoBhE"}
|