Photopea Embedded Editor Skill
Using photopea.js (yikuansun/PhotopeaAPI) in Websites & Apps
When to Use This Skill
Use this skill for every task that involves:
- Embedding Photopea as an image editor inside a webpage or web app
- Controlling an embedded Photopea instance from your JavaScript code
- Automating image editing workflows from a host page (open files, run scripts, export results)
- Building an image editing feature into your product using Photopea as the engine
- Writing scripts to manipulate documents, layers, text, selections, filters, colors, and paths
Do NOT use raw postMessage wiring — always use photopea.js as the wrapper.
Library: photopea.js
photopea.js is a Promises-based JavaScript wrapper around the Photopea Live Messaging API.
Repository: https://github.com/yikuansun/PhotopeaAPI
npm package: https://www.npmjs.com/package/photopea
Installation
CDN (no build step)
<script src="https://cdn.jsdelivr.net/npm/photopea@1.1.1/dist/photopea.min.js"></script>
Self-hosted
<script src="./photopea.min.js"></script>
npm (Webpack / Vite / Rollup)
npm install photopea
import Photopea from "photopea";
Core API: The Photopea Class
| Method |
Description |
Photopea.createEmbed(container) |
Creates + injects the iframe, resolves when ready |
new Photopea(window.parent) |
Plugin mode: wrap the parent window |
pea.runScript(script) |
Run JS string inside Photopea; returns output array |
pea.loadAsset(arrayBuffer) |
Load binary file (image, font, brush, etc.) |
pea.openFromURL(url, asSmart) |
Open remote URL as new doc or smart object layer |
pea.exportImage(type) |
Export current doc; returns Blob ("png" or "jpg") |
All methods return Promises — always await or .then().
Step 1 — Embed
The container <div> must have a fixed width and height before calling createEmbed.
<div id="editor" style="width:1000px; height:650px;"></div>
<script src="https://cdn.jsdelivr.net/npm/photopea@1.1.1/dist/photopea.min.js"></script>
<script>
Photopea.createEmbed(document.getElementById("editor")).then(async (pea) => {
// pea is ready
});
</script>
React:
import { useEffect, useRef } from "react";
import Photopea from "photopea";
export default function Editor() {
const containerRef = useRef(null);
const peaRef = useRef(null);
useEffect(() => {
if (!containerRef.current || peaRef.current) return;
Photopea.createEmbed(containerRef.current).then((pea) => {
peaRef.current = pea;
});
}, []);
return <div ref={containerRef} style={{ width: "100%", height: "650px" }} />;
}
Step 2 — Opening Files
// Remote URL → new document
await pea.openFromURL("https://example.com/design.psd", false);
// Remote URL → smart object layer inside current document
await pea.openFromURL("https://example.com/overlay.png", true);
// Local file (user input → ArrayBuffer → loadAsset)
document.getElementById("fileInput").addEventListener("change", async (e) => {
const buf = await e.target.files[0].arrayBuffer();
await pea.loadAsset(buf);
});
// Base64 data URI via runScript
await pea.runScript(`app.open("data:image/png;base64,iVBORw0...");`);
Step 3 — Running Scripts
runScript sends a JS string, returns an array of app.echoToOE(...) values + "done" last.
const result = await pea.runScript(`app.echoToOE("hello");`);
// result → ["hello", "done"]
// Return structured data
const out = await pea.runScript(`
app.echoToOE(JSON.stringify({
width: app.activeDocument.width,
height: app.activeDocument.height,
layers: app.activeDocument.layers.length
}));
`);
const info = JSON.parse(out[0]);
Step 4 — Exporting
// PNG Blob (via exportImage)
const blob = await pea.exportImage("png");
document.getElementById("preview").src = URL.createObjectURL(blob);
// JPEG Blob
const blob = await pea.exportImage("jpg");
// WebP / PSD / quality-controlled JPEG via saveToOE
const result = await pea.runScript(`app.activeDocument.saveToOE("webp:0.85");`);
const webpBlob = new Blob([result[0]], { type: "image/webp" });
const result = await pea.runScript(`app.activeDocument.saveToOE("psd:true");`);
const psdBlob = new Blob([result[0]], { type: "application/octet-stream" });
// Trigger download
async function download(pea, filename = "export.png") {
const blob = await pea.exportImage("png");
const a = Object.assign(document.createElement("a"), {
href: URL.createObjectURL(blob),
download: filename
});
a.click();
}
Export format strings for saveToOE:
| String |
Format |
"png" |
PNG lossless |
"jpg" |
JPEG default |
"jpg:0.8" |
JPEG quality 0.0–1.0 |
"webp:0.7" |
WebP quality 0.0–1.0 |
"psd" |
Full PSD |
"psd:true" |
Minified PSD |
"svg:true" |
SVG |
Step 5 — Loading Assets
// Font
const buf = await (await fetch("https://example.com/MyFont.otf")).arrayBuffer();
await pea.loadAsset(buf);
// Now usable in textItem.font
// Brush
await pea.loadAsset(await (await fetch("Nature.ABR")).arrayBuffer());
// Gradient
await pea.loadAsset(await (await fetch("Gradients.GRD")).arrayBuffer());
Step 6 — Plugin Mode
// Your page is inside Photopea's sidebar iframe
const pea = new Photopea(window.parent);
const out = await pea.runScript(`app.echoToOE(app.activeDocument.width);`);
console.log("Width:", out[0]);
// Load an asset from your plugin
const buf = await (await fetch("https://my-assets.com/sticker.png")).arrayBuffer();
await pea.loadAsset(buf);
Plugin config:
{
"environment": {
"plugins": [{
"name": "My Plugin",
"url": "https://my-plugin.example.com",
"icon": "===https://my-plugin.example.com/icon.png"
}]
}
}
Utility Patterns
addImageAndWait — robust async layer insertion
async function addImageAndWait(pea, imgURI) {
let count = "done";
while (count === "done")
count = (await pea.runScript(`app.echoToOE(app.activeDocument.layers.length)`))[0];
count = parseInt(count);
const imageUrlLiteral = JSON.stringify(imgURI);
await pea.runScript(`app.open(${imageUrlLiteral}, null, true);`);
return new Promise((resolve) => {
const check = async () => {
const n = parseInt((await pea.runScript(
`app.echoToOE(app.activeDocument.layers.length)`
))[0]);
n === count + 1 ? resolve() : setTimeout(check, 50);
};
check();
});
}
getDocumentAsImage — returns <img> element
async function getDocumentAsImage(pea) {
const result = await pea.runScript(`app.activeDocument.saveToOE('png')`);
return new Promise((resolve) => {
const fr = new FileReader();
fr.addEventListener("load", (e) => {
const img = new Image(); img.src = e.target.result; resolve(img);
});
fr.readAsDataURL(new Blob([result[0]], { type: "image/png" }));
});
}
Real-World Patterns
Pattern A — Open + Export UI
<input type="file" id="fileInput" accept="image/*,.psd">
<button id="exportBtn">Export PNG</button>
<div id="editor" style="width:100%;height:600px;"></div>
<script src="https://cdn.jsdelivr.net/npm/photopea@1.1.1/dist/photopea.min.js"></script>
<script>
let pea;
Photopea.createEmbed(document.getElementById("editor")).then(p => pea = p);
document.getElementById("fileInput").addEventListener("change", async e => {
await pea.loadAsset(await e.target.files[0].arrayBuffer());
});
document.getElementById("exportBtn").addEventListener("click", async () => {
const blob = await pea.exportImage("png");
const a = Object.assign(document.createElement("a"), {
href: URL.createObjectURL(blob), download: "export.png"
});
a.click();
});
</script>
Pattern B — Template + Text Edit + Export
async function generateCard(pea, name, tagline) {
await pea.openFromURL("https://example.com/card.psd", false);
const nameLiteral = JSON.stringify(name);
const taglineLiteral = JSON.stringify(tagline);
await pea.runScript(`
app.activeDocument.layers.getByName("Name").textItem.contents = ${nameLiteral};
app.activeDocument.layers.getByName("Tagline").textItem.contents = ${taglineLiteral};
`);
return await pea.exportImage("png");
}
Pattern C — Batch Watermark
async function batchWatermark(pea, imageURLs, watermarkURL) {
const results = [];
for (const url of imageURLs) {
await pea.openFromURL(url, false);
await pea.openFromURL(watermarkURL, true);
await pea.runScript(`
var doc = app.activeDocument, wm = doc.activeLayer;
wm.translate(doc.width - wm.bounds[2] - 20, doc.height - wm.bounds[3] - 20);
wm.opacity = 70;
`);
results.push(await pea.exportImage("png"));
await pea.runScript(`app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);`);
}
return results;
}
FULL SCRIPTING API REFERENCE
All code in this section runs inside pea.runScript("...") strings.
Photopea implements the Adobe Photoshop CC 2015 JavaScript scripting interface.
Any Photoshop script targeting that version should work in Photopea.
app — Application Object
Properties
| Property |
Type |
R/W |
Description |
app.activeDocument |
Document |
R/W |
The currently active document |
app.documents |
Documents |
R |
Collection of all open documents |
app.documents.length |
number |
R |
Count of open documents |
app.documents[i] |
Document |
R |
Access by zero-based index |
app.foregroundColor |
SolidColor |
R/W |
Current foreground color |
app.backgroundColor |
SolidColor |
R/W |
Current background color |
app.preferences.rulerUnits |
Units |
R/W |
Units.PIXELS, Units.CM, Units.INCHES, Units.MM, Units.PICAS, Units.POINTS, Units.PERCENT |
app.preferences.typeUnits |
TypeUnits |
R/W |
TypeUnits.PIXELS, TypeUnits.MM, TypeUnits.POINTS |
app.displayDialogs |
DialogModes |
R/W |
DialogModes.NO, DialogModes.ALL, DialogModes.ERROR |
Methods
| Method |
Description |
app.open(url) |
Open URL as new document |
app.open(url, null, true) |
Open URL as smart object layer in active document |
app.echoToOE(string) |
Photopea extension — send string to host page (captured by runScript) |
app.showWindow("magiccut") |
Photopea extension — open Magic Cut panel |
app.showWindow("vbitmap") |
Photopea extension — open Vectorize Bitmap panel |
app.UI.zoomIn() |
Zoom in |
app.UI.zoomOut() |
Zoom out |
app.UI.fitTheArea() |
Fit canvas to viewport |
app.UI.pixelToPixel() |
100% zoom |
app.UI.switchFullscreen() |
Toggle fullscreen |
app.UI.scroll(dx, dy) |
Scroll by delta |
app.UI.scrollTo(x, y) |
Scroll to absolute position |
Important: Always set ruler units to pixels at the start of any script that uses pixel measurements:
var savedUnits = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.PIXELS;
// ... your code ...
app.preferences.rulerUnits = savedUnits;
Document — Document Object
Access via app.activeDocument or app.documents[i].
Properties
| Property |
Type |
R/W |
Description |
width |
number |
R |
Document width in current ruler units |
height |
number |
R |
Document height in current ruler units |
resolution |
number |
R |
DPI (pixels per inch) |
name |
string |
R/W |
Photopea extension — display label (no history step) |
source |
string |
R/W |
Photopea extension — file origin URL or "local,X,NAME" |
mode |
DocumentMode |
R |
DocumentMode.RGB, GRAYSCALE, CMYK, LAB, BITMAP, INDEXEDCOLOR, MULTICHANNEL |
bitsPerChannel |
BitsPerChannelType |
R |
BitsPerChannelType.EIGHT, SIXTEEN, THIRTYTWO |
colorProfileName |
string |
R |
Name of embedded color profile |
activeLayer |
Layer/ArtLayer/LayerSet |
R/W |
Set to activate a layer |
currentLayer |
ArtLayer |
R/W |
Alias for activeLayer |
layers |
Layers |
R |
All top-level layers (both art + group) |
artLayers |
ArtLayers |
R |
All top-level art layers only |
layerSets |
LayerSets |
R |
All top-level group layers only |
selection |
Selection |
R |
The current selection |
channels |
Channels |
R |
All channels |
historyStates |
HistoryStates |
R |
Undo history |
activeHistoryState |
HistoryState |
R/W |
Current history position |
layerComps |
LayerComps |
R |
Layer comps collection |
guides |
Guides |
R |
Guides collection |
pathItems |
PathItems |
R |
Vector paths |
id |
number |
R |
Unique document ID |
saved |
boolean |
R |
Whether document has unsaved changes |
quickMaskMode |
boolean |
R |
Whether in Quick Mask mode |
backgroundLayer |
ArtLayer |
R |
The background layer |
pixelAspectRatio |
number |
R |
Custom pixel aspect ratio (0.1–10.0) |
histogram |
array |
R |
256-element histogram array |
Methods
| Method |
Signature |
Description |
resizeImage |
(w, h, res, resampleMethod) |
Resize image pixels. ResampleMethod: BICUBIC, BILINEAR, NEARESTNEIGHBOR, NONE, BICUBICSHARPER, BICUBICSMOOTHER |
resizeCanvas |
(w, h, anchor) |
Resize canvas without scaling. AnchorPosition: TOPLEFT, TOPCENTER, TOPRIGHT, MIDDLELEFT, MIDDLECENTER, MIDDLERIGHT, BOTTOMLEFT, BOTTOMCENTER, BOTTOMRIGHT |
rotateCanvas |
(degrees) |
Rotate entire canvas. Positive = clockwise |
flipCanvas |
(direction) |
Direction.HORIZONTAL or Direction.VERTICAL |
crop |
([x1,y1,x2,y2], angle, w, h) |
Crop canvas. Angle and dimensions are optional |
trim |
(trimType, top, left, bottom, right) |
Trim transparent/background-color borders. TrimType: TRANSPARENT, TOPLEFT, BOTTOMRIGHT |
revealAll |
() |
Expand canvas to show clipped content |
flatten |
() |
Merge all layers into one |
mergeVisibleLayers |
() |
Merge all visible layers |
rasterizeAllLayers |
() |
Rasterize all vector/text layers |
changeMode |
(mode, options) |
Convert color mode (e.g., ChangeMode.GRAYSCALE) |
convertProfile |
(profileName, renderingIntent, blackPointCompensation, dither) |
Convert color profile |
duplicate |
(name, mergedLayers) |
Duplicate the document |
close |
(saveOptions) |
Close document. SaveOptions: DONOTSAVECHANGES, SAVECHANGES, PROMPTTOSAVECHANGES |
save |
() |
Save (requires server config in embed) |
saveToOE |
(format) |
Photopea extension — send binary to host. Formats: "png", "jpg:0.8", "webp:0.7", "psd:true", "svg:true" |
clearHistory |
() |
Photopea extension — clear undo history to free RAM |
exportDocument |
(file, exportType, options) |
Export to filesystem (triggers ZIP). ExportType: SAVEFORWEB |
paste |
(intoSelection) |
Paste clipboard into document |
suspendHistory |
(historyName, callback) |
Wrap multiple ops in one history state |
Practical examples:
var doc = app.activeDocument;
// Resize image to 1920×1080 at 72dpi bicubic
doc.resizeImage(1920, 1080, 72, ResampleMethod.BICUBIC);
// Expand canvas to 2000px wide, keeping content centered
doc.resizeCanvas(2000, doc.height, AnchorPosition.MIDDLECENTER);
// Crop to a region
doc.crop([100, 100, 900, 600]);
// Trim transparent edges
doc.trim(TrimType.TRANSPARENT, true, true, true, true);
// Flip horizontal
doc.flipCanvas(Direction.HORIZONTAL);
// Change to grayscale
doc.changeMode(ChangeMode.GRAYSCALE);
// One undo step for many operations
doc.suspendHistory("Batch Edit", "action");
// (Inside Photopea, all ops become one history state)
// Export PNG to filesystem (triggers ZIP download)
var opts = new ExportOptionsSaveForWeb();
opts.format = SaveDocumentType.PNG;
opts.PNG8 = false;
opts.quality = 100;
doc.exportDocument(new File("/output.png"), ExportType.SAVEFORWEB, opts);
// Close without saving
doc.close(SaveOptions.DONOTSAVECHANGES);
Layers / ArtLayers / LayerSets Collections
These collections exist on Document, LayerSet (groups within groups), and can be iterated.
var doc = app.activeDocument;
// Access
doc.layers // all top-level (art + groups)
doc.artLayers // top-level art layers only
doc.layerSets // top-level group layers only
// By index (0 = topmost)
doc.layers[0]
doc.layers[doc.layers.length - 1] // bottommost
// By name (throws if not found)
doc.layers.getByName("Background")
doc.artLayers.getByName("Logo")
doc.layerSets.getByName("Header Group")
// Add
var newLayer = doc.artLayers.add(); // new blank art layer
var newGroup = doc.layerSets.add(); // new group
var innerLayer = newGroup.artLayers.add(); // layer inside a group
// Remove
doc.artLayers.getByName("Temp").remove();
// Iterate all layers recursively
function walkLayers(parent) {
for (var i = 0; i < parent.layers.length; i++) {
var l = parent.layers[i];
if (l.typename === "LayerSet") walkLayers(l);
else /* ArtLayer */ processLayer(l);
}
}
walkLayers(doc);
ArtLayer — Individual Layer
Properties
| Property |
Type |
R/W |
Description |
name |
string |
R/W |
Layer name |
visible |
boolean |
R/W |
Layer visibility |
opacity |
number |
R/W |
Layer opacity 0–100 |
fillOpacity |
number |
R |
Fill opacity 0–100 |
blendMode |
BlendMode |
R/W |
Blend mode (see enum below) |
kind |
LayerKind |
R/W |
Layer type (can set to LayerKind.TEXT on empty layer) |
textItem |
TextItem |
R |
Text object (only when kind === LayerKind.TEXT) |
bounds |
array |
R |
[left, top, right, bottom] in current ruler units |
parent |
Document/LayerSet |
R |
Containing object |
typename |
string |
R |
Always "ArtLayer" |
selected |
boolean |
R |
Photopea extension — is layer highlighted in panel |
isBackgroundLayer |
boolean |
R |
Is this the locked background layer |
grouped |
boolean |
R |
Is clipping mask applied |
pixelsLocked |
boolean |
R |
Pixels locked |
positionLocked |
boolean |
R |
Position locked |
transparentPixelsLocked |
boolean |
R |
Transparent pixels locked |
layerMaskDensity |
number |
R |
Layer mask density 0–100 |
layerMaskFeather |
number |
R |
Layer mask feather 0–250 |
vectorMaskDensity |
number |
R |
Vector mask density 0–100 |
vectorMaskFeather |
number |
R |
Vector mask feather 0–250 |
Transform Methods
| Method |
Signature |
Description |
translate |
(deltaX, deltaY) |
Move layer by offset |
rotate |
(angle, anchor) |
Rotate by degrees. AnchorPosition optional (default center) |
resize |
(widthPct, heightPct, anchor) |
Scale as percentage of current size |
rasterize |
(target) |
Rasterize. RasterizeType: ENTIRE, FILLCONTENT, LAYERCLIPPINGMASK, LINKEDLAYERS, SHAPE, TEXTCONTENTS, VECTORMASK |
Layer Management Methods
| Method |
Signature |
Description |
duplicate |
() |
Duplicate to same document, returns new layer |
duplicate |
(doc, placement) |
Duplicate to another document |
remove |
() |
Delete the layer |
merge |
() |
Merge down; returns the merged ArtLayer |
move |
(relativeLayer, placement) |
Reorder. ElementPlacement: PLACEBEFORE, PLACEAFTER, PLACEATBEGINNING, PLACEATEND, INSIDE |
copy |
(merged) |
Copy to clipboard |
cut |
() |
Cut to clipboard |
clear |
() |
Cut without clipboard |
Adjustment Methods on ArtLayer
| Method |
Signature |
Description |
adjustBrightnessContrast |
(brightness, contrast) |
Brightness -100–100, Contrast -100–100 |
adjustColorBalance |
(shadows, midtones, highlights, preserveLuminosity) |
Each is [cyan-red, magenta-green, yellow-blue] array |
adjustCurves |
(curveShape) |
Array of [input,output] pairs per channel |
adjustLevels |
(inputRangeStart, inputRangeEnd, gamma, outputRangeStart, outputRangeEnd) |
Levels adjustment |
autoLevels |
() |
Auto levels |
autoContrast |
() |
Auto contrast |
desaturate |
() |
Convert to grayscale values in current mode |
equalize |
() |
Equalize brightness distribution |
invert |
() |
Invert pixel colors |
posterize |
(levels) |
Posterize (2–255 levels) |
threshold |
(level) |
B&W threshold (1–255) |
shadowHighlight |
(shadowAmount, shadowWidth, shadowRadius, highlightAmount, highlightWidth, highlightRadius, colorCorrection, midtoneContrast, blackClip, whiteClip) |
Shadows/Highlights |
photoFilter |
(fillColor, density, luminosity) |
Photo filter |
mixChannels |
(outputChannels, monochrome) |
Channel mixer |
selectiveColor |
(colors, cyan, magenta, yellow, black, method) |
Selective color |
Filter Methods on ArtLayer
| Method |
Signature |
Description |
applyGaussianBlur |
(radius) |
Gaussian blur (0.1–250 px radius) |
applyMotionBlur |
(angle, distance) |
Motion blur |
applyRadialBlur |
(amount, blurMethod, blurQuality) |
Radial blur |
applySmartBlur |
(radius, threshold, blurQuality, blurMode) |
Smart blur |
applyBlur |
() |
Simple blur |
applyBlurMore |
() |
Blur more |
applyUnSharpMask |
(amount, radius, threshold) |
Unsharp mask |
applySharpen |
() |
Sharpen |
applySharpenEdges |
() |
Sharpen edges |
applySharpenMore |
() |
Sharpen more |
applyAddNoise |
(amount, distribution, monochromatic) |
Add noise. NoiseDistribution: GAUSSIAN, UNIFORM |
applyDespeckle |
() |
Despeckle |
applyDustAndScratches |
(radius, threshold) |
Dust and scratches |
applyMedianNoise |
(radius) |
Median noise reduction |
applyMaximum |
(radius) |
Maximum filter (dilate) |
applyMinimum |
(radius) |
Minimum filter (erode) |
applyHighPass |
(radius) |
High pass |
applyOffset |
(horizontal, vertical, undefinedAreas) |
Offset. UndefinedAreas: SETTOBACKGROUND, WRAPAROUND, REPEATEDGEPIXELS |
applyRipple |
(amount, size) |
Ripple. RippleSize: SMALL, MEDIUM, LARGE |
applyWave |
(generators, minWavelength, maxWavelength, minAmplitude, maxAmplitude, horizScale, vertScale, waveType, undefinedAreas, randomSeed) |
Wave filter |
applyZigZag |
(amount, ridges, style) |
Zig-Zag |
applyTwirl |
(angle) |
Twirl |
applyPolarCoordinates |
(conversion) |
Polar coordinates |
applySpherize |
(amount, mode) |
Spherize |
applyPinch |
(amount) |
Pinch (-100–100) |
applyShear |
(curve, undefinedAreas) |
Shear |
applyDisplace |
(horizontalScale, verticalScale, displacementType, undefinedAreas, displacementMapFile) |
Displace |
applyClouds |
() |
Render Clouds |
applyDifferenceClouds |
() |
Difference Clouds |
applyLensFlare |
(brightness, flareCenter, lensType) |
Lens Flare. LensType: ZOOMWIDE, ZOOMNORMAL, MOVIE |
applyDiffuseGlow |
(graininess, glowAmount, clearAmount) |
Diffuse Glow |
applyGlassEffect |
(distortion, smoothness, scaling, invert, texture, textureFile) |
Glass |
applyOceanRipple |
(size, magnitude) |
Ocean Ripple |
applyLensBlur |
(source, focalDistance, invertDepthMap, shape, radius, bladeCurvature, rotation, brightness, threshold, amount, distribution, monochromatic) |
Lens Blur |
applyAverage |
() |
Average blur |
applyDeInterlace |
(eliminateFields, createFields) |
De-interlace |
applyNTSC |
() |
NTSC colors |
applyCustomFilter |
(characteristics, scale, offset) |
Custom filter (5×5 matrix) |
applyTextureFill |
(textureFile) |
Texture fill |
applyStyle |
(styleName) |
Apply a layer style preset by name |
photoFilter |
(fillColor, density, luminosity) |
Photo Filter |
Practical examples:
var layer = app.activeDocument.activeLayer;
// Move to absolute position (layer.bounds[0] = current left edge)
layer.translate(200 - layer.bounds[0], 100 - layer.bounds[1]);
// Rotate 45° around center
layer.rotate(45);
// Scale to 50% keeping center
layer.resize(50, 50, AnchorPosition.MIDDLECENTER);
// Gaussian blur radius 10
layer.applyGaussianBlur(10);
// Unsharp mask
layer.applyUnSharpMask(50, 2, 0);
// Levels: input 0–200, gamma 1.2, output 0–255
layer.adjustLevels(0, 200, 1.2, 0, 255);
// Brightness +20, Contrast +10
layer.adjustBrightnessContrast(20, 10);
// Invert
layer.invert();
// Rasterize text
layer.rasterize(RasterizeType.TEXTCONTENTS);
// Duplicate layer
var copy = layer.duplicate();
copy.name = "Layer Copy";
// Move layer below another
var target = doc.layers.getByName("Background");
layer.move(target, ElementPlacement.PLACEAFTER);
LayerSet — Group Layer
A LayerSet is a folder/group in the Layers panel. It has the same layer management methods as Document.
Properties
| Property |
Type |
R/W |
Description |
name |
string |
R/W |
Group name |
visible |
boolean |
R/W |
Group visibility |
opacity |
number |
R/W |
Group opacity 0–100 |
blendMode |
BlendMode |
R/W |
Group blend mode |
bounds |
array |
R |
Bounding box [left,top,right,bottom] |
layers |
Layers |
R |
All layers inside this group |
artLayers |
ArtLayers |
R |
Art layers inside this group |
layerSets |
LayerSets |
R |
Sub-groups inside this group |
parent |
Document/LayerSet |
R |
Parent container |
typename |
string |
R |
Always "LayerSet" |
Methods
Same as Document for layer management: layers.add(), artLayers.add(), layerSets.add(), .getByName(), plus duplicate(), remove(), move().
// Create group with layers inside
var group = doc.layerSets.add();
group.name = "Product Card";
var bgLayer = group.artLayers.add(); bgLayer.name = "Background";
var textLayer = group.artLayers.add(); textLayer.kind = LayerKind.TEXT;
textLayer.textItem.contents = "Buy Now";
textLayer.textItem.size = 36;
// Collapse/expand group (Photopea specific, not in standard DOM)
// Use visibility as workaround
// Get specific layer inside a group
var innerLayer = doc.layerSets.getByName("Header Group").artLayers.getByName("Title");
TextItem — Text Layer Content
Access via layer.textItem on any layer with layer.kind === LayerKind.TEXT.
Core Properties (most commonly used)
| Property |
Type |
R/W |
Description |
contents |
string |
R/W |
The actual text content |
font |
string |
R/W |
Font PostScript name (e.g. "ArialMT", "Verdana-Bold") |
size |
number |
R/W |
Font size in points |
color |
SolidColor |
R/W |
Text color |
position |
array |
R/W |
[x, y] origin of text (point text) or bounding box top-left |
justification |
Justification |
R/W |
Justification.LEFT, CENTER, RIGHT, FULLJUSTIFY |
kind |
TextType |
R/W |
TextType.POINTTEXT or TextType.PARAGRAPHTEXT |
width |
number |
R/W |
Width of bounding box (paragraph text only) |
height |
number |
R/W |
Height of bounding box (paragraph text only) |
direction |
Direction |
R/W |
Direction.HORIZONTAL or Direction.VERTICAL |
Typography Properties
| Property |
Type |
R/W |
Description |
leading |
number |
R/W |
Line spacing in points |
tracking |
number |
R/W |
Letter spacing -1000–10000 (1000 = 1 em) |
horizontalScale |
number |
R/W |
Horizontal scaling 0–1000% |
verticalScale |
number |
R/W |
Vertical scaling 0–1000% |
baselineShift |
number |
R/W |
Baseline offset in points |
capitalization |
Case |
R/W |
Case.NORMAL, ALLCAPS, SMALLCAPS |
fauxBold |
boolean |
R/W |
Simulated bold |
fauxItalic |
boolean |
R/W |
Simulated italic |
underline |
UnderlineType |
R/W |
UnderlineType.NONE, UNDERLINELEFT, UNDERLINERIGHT |
strikeThru |
StrikeThruType |
R/W |
StrikeThruType.NONE, STRIKEBOX, STRIKEHEIGHT |
antiAliasMethod |
AntiAlias |
R/W |
AntiAlias.NONE, SHARP, CRISP, STRONG, SMOOTH |
autoKerning |
AutoKernType |
R/W |
AutoKernType.MANUAL, METRICS, OPTICAL |
language |
Language |
R/W |
Language.ENGLISH, etc. |
ligatures |
boolean |
R/W |
Enable ligatures |
alternateLigatures |
boolean |
R/W |
Enable alternate ligatures |
oldStyle |
boolean |
R/W |
Old-style numerals |
noBreak |
boolean |
R/W |
Prevent line breaks in this text |
useAutoLeading |
boolean |
R/W |
Use font's built-in leading |
autoLeadingAmount |
number |
R/W |
Auto leading percentage 0.01–5000 |
hyphenation |
boolean |
R/W |
Enable hyphenation |
Paragraph Properties
| Property |
Type |
R/W |
Description |
leftIndent |
number |
R/W |
Left indent -1296–1296 |
rightIndent |
number |
R/W |
Right indent -1296–1296 |
firstLineIndent |
number |
R/W |
First line indent -1296–1296 |
spaceBefore |
number |
R/W |
Space before paragraph -1296–1296 |
spaceAfter |
number |
R/W |
Space after paragraph -1296–1296 |
hangingPuntuation |
boolean |
R/W |
Roman hanging punctuation |
textComposer |
TextComposer |
R/W |
TextComposer.ADOBEEVERYLINE, ADOBESINGLELINE |
Warp Properties
| Property |
Type |
R/W |
Description |
warpStyle |
WarpStyle |
R/W |
WarpStyle.NONE, ARC, ARCH, BULGE, SHELLLOWER, SHELLUPPER, FLAG, WAVE, FISH, RISE, FISHEYE, INFLATE, SQUEEZE, TWIST |
warpDirection |
Direction |
R/W |
Direction.HORIZONTAL or Direction.VERTICAL |
warpBend |
number |
R/W |
Warp bend -100–100 |
warpHorizontalDistortion |
number |
R/W |
Horizontal distortion -100–100 |
warpVerticalDistortion |
number |
R/W |
Vertical distortion -100–100 |
Photopea Extensions
| Property |
Type |
Description |
totalTextStyle |
string |
JSON string with ALL style parameters of the text |
transform |
string |
JSON array — the affine transform matrix of the text |
Methods
| Method |
Description |
convertToShape() |
Convert text to a filled shape layer with text as clipping path |
createPath() |
Create work path from text outlines |
Practical examples:
var layer = doc.layers.getByName("Headline");
var text = layer.textItem;
// Set content
text.contents = "Hello World";
// Style
text.font = "Verdana-Bold";
text.size = 72;
text.color.rgb.hexValue = "FF0000"; // red
// Position point text at (50, 100)
text.position = [50, 100];
// Center align
text.justification = Justification.CENTER;
// Paragraph text with bounding box
text.kind = TextType.PARAGRAPHTEXT;
text.width = new UnitValue("400 pixels");
text.height = new UnitValue("200 pixels");
// Letter spacing
text.tracking = 100; // 10% spacing
// Scale text horizontally to 80%
text.horizontalScale = 80;
// Warp arc
text.warpStyle = WarpStyle.ARC;
text.warpBend = 30;
// Read all text styles as JSON (Photopea extension)
var styles = JSON.parse(text.totalTextStyle);
app.echoToOE(JSON.stringify(styles));
Creating a Text Layer from Scratch
app.preferences.rulerUnits = Units.PIXELS;
var layer = doc.artLayers.add();
layer.kind = LayerKind.TEXT; // Convert blank layer to text
layer.name = "My Title";
var text = layer.textItem;
text.contents = "Welcome";
text.font = "ArialMT";
text.size = 48;
text.justification = Justification.CENTER;
text.position = [doc.width / 2, 100];
var color = new SolidColor();
color.rgb.red = 255;
color.rgb.green = 255;
color.rgb.blue = 255;
text.color = color;
SolidColor — Color Object
// RGB (most common in Photopea)
var c = new SolidColor();
c.rgb.red = 255; // 0–255
c.rgb.green = 128;
c.rgb.blue = 0;
c.rgb.hexValue = "FF8000"; // Set via hex string (no #)
// CMYK
var c2 = new SolidColor();
c2.cmyk.cyan = 0; // 0–100
c2.cmyk.magenta = 50;
c2.cmyk.yellow = 100;
c2.cmyk.black = 0;
// Grayscale
var c3 = new SolidColor();
c3.gray.gray = 50; // 0–100
// HSB
var c4 = new SolidColor();
c4.hsb.hue = 30; // 0–360
c4.hsb.saturation = 100; // 0–100
c4.hsb.brightness = 100; // 0–100
// Lab
var c5 = new SolidColor();
c5.lab.l = 50; // 0–100
c5.lab.a = 20; // -128–127
c5.lab.b = 40; // -128–127
// Set as foreground color
app.foregroundColor = c;
// Use with selection fill
doc.selection.selectAll();
doc.selection.fill(c);
doc.selection.deselect();
Selection — Selection Object
Access via doc.selection.
Properties
| Property |
Type |
Description |
bounds |
array |
[left, top, right, bottom] bounding rectangle |
solid |
boolean |
Whether selection is a solid rectangle |
Methods
| Method |
Signature |
Description |
selectAll |
() |
Select entire document |
deselect |
() |
Remove selection |
invert |
() |
Invert the selection |
select |
(region, type, feather, antiAlias) |
Select polygon region. Region is array of [x,y] points. SelectionType: REPLACE, ADD, SUBTRACT, INTERSECT |
feather |
(radius) |
Feather the selection edges |
contract |
(radius) |
Contract (shrink) selection |
expand |
(radius) |
Expand selection |
grow |
(tolerance, antiAlias) |
Grow selection to similar adjacent pixels |
similar |
(tolerance, antiAlias) |
Select similar pixels throughout document |
smooth |
(radius) |
Smooth selection edges |
selectBorder |
(width) |
Select only the border of the current selection |
resize |
(widthPct, heightPct, anchor) |
Resize selection boundary |
rotate |
(angle, anchor) |
Rotate selection boundary |
translate |
(deltaX, deltaY) |
Move selection boundary |
fill |
(fillWith, mode, opacity, preserveTransparency) |
Fill selection with color or content. fillWith is SolidColor or string |
stroke |
(strokeColor, width, location, mode, opacity, preserveTransparency) |
Stroke selection border. StrokeLocation: INSIDE, OUTSIDE, CENTER |
copy |
(merged) |
Copy selection to clipboard |
cut |
() |
Cut selection to clipboard |
clear |
() |
Delete selection content |
load |
(from, type, invert) |
Load selection from channel |
store |
(into, type) |
Save selection as channel |
makeWorkPath |
(tolerance) |
Convert to work path |
Practical examples:
var sel = doc.selection;
// Rectangle select (top-left to bottom-right)
sel.select([[0,0],[500,0],[500,300],[0,300]]);
// Select all
sel.selectAll();
// Add to existing selection
sel.select([[600,0],[900,0],[900,300],[600,300]], SelectionType.ADD);
// Feather 10px
sel.feather(10);
// Contract by 5px
sel.contract(5);
// Fill with red
var red = new SolidColor();
red.rgb.red = 255; red.rgb.green = 0; red.rgb.blue = 0;
sel.fill(red);
// Stroke selection with black, 3px, inside
var black = new SolidColor();
black.rgb.hexValue = "000000";
sel.stroke(black, 3, StrokeLocation.INSIDE);
// Copy, paste as new layer
sel.copy();
doc.paste();
// Invert and delete (remove background)
sel.invert();
sel.clear();
sel.deselect();
BlendMode Enum — All Values
Used in layer.blendMode (string form in Photopea) and BlendMode constant (standard):
BlendMode Constant |
Photopea String |
Name |
BlendMode.NORMAL |
"norm" |
Normal |
BlendMode.DISSOLVE |
"diss" |
Dissolve |
BlendMode.DARKEN |
"dark" |
Darken |
BlendMode.MULTIPLY |
"mul " |
Multiply |
BlendMode.COLORBURN |
"idiv" |
Color Burn |
BlendMode.LINEARBURN |
"lbrn" |
Linear Burn |
BlendMode.DARKERCOLOR |
"dkCl" |
Darker Color |
BlendMode.LIGHTEN |
"lite" |
Lighten |
BlendMode.SCREEN |
"scrn" |
Screen |
BlendMode.COLORDODGE |
"div " |
Color Dodge |
BlendMode.LINEARDODGE |
"lddg" |
Linear Dodge (Add) |
BlendMode.LIGHTERCOLOR |
"lgCl" |
Lighter Color |
BlendMode.OVERLAY |
"over" |
Overlay |
BlendMode.SOFTLIGHT |
"sLit" |
Soft Light |
BlendMode.HARDLIGHT |
"hLit" |
Hard Light |
BlendMode.VIVIDLIGHT |
"vLit" |
Vivid Light |
BlendMode.LINEARLIGHT |
"lLit" |
Linear Light |
BlendMode.PINLIGHT |
"pLit" |
Pin Light |
BlendMode.HARDMIX |
"hMix" |
Hard Mix |
BlendMode.DIFFERENCE |
"diff" |
Difference |
BlendMode.EXCLUSION |
"smud" |
Exclusion |
BlendMode.SUBTRACT |
"fsub" |
Subtract |
BlendMode.DIVIDE |
"fdiv" |
Divide |
BlendMode.HUE |
"hue " |
Hue |
BlendMode.SATURATION |
"sat " |
Saturation |
BlendMode.COLOR |
"colr" |
Color |
BlendMode.LUMINOSITY |
"lum " |
Luminosity |
BlendMode.PASSTHROUGH |
"pass" |
Pass Through (groups only) |
// Use either form:
layer.blendMode = BlendMode.SCREEN; // constant
layer.blendMode = "scrn"; // string (Photopea internal form)
LayerKind Enum
| Constant |
Description |
LayerKind.NORMAL |
Regular pixel layer |
LayerKind.TEXT |
Text layer |
LayerKind.SMARTOBJECT |
Smart Object / linked layer |
LayerKind.SOLIDFILL |
Solid color fill layer |
LayerKind.GRADIENTFILL |
Gradient fill layer |
LayerKind.PATTERNFILL |
Pattern fill layer |
LayerKind.BRIGHTNESSCONTRAST |
Brightness/Contrast adjustment layer |
LayerKind.CURVES |
Curves adjustment layer |
LayerKind.LEVELS |
Levels adjustment layer |
LayerKind.HUESATURATION |
Hue/Saturation adjustment layer |
LayerKind.COLORBALANCE |
Color Balance adjustment layer |
LayerKind.CHANNELMIXER |
Channel Mixer adjustment layer |
LayerKind.GRADIENTMAP |
Gradient Map adjustment layer |
LayerKind.INVERSION |
Invert adjustment layer |
LayerKind.POSTERIZE |
Posterize adjustment layer |
LayerKind.THRESHOLD |
Threshold adjustment layer |
LayerKind.SELECTIVECOLOR |
Selective Color adjustment layer |
LayerKind.PHOTOFILTER |
Photo Filter adjustment layer |
LayerKind.EXPOSURE |
Exposure adjustment layer |
LayerKind.VIBRANCE |
Vibrance adjustment layer |
LayerKind.COLORLOOKUP |
Color Lookup adjustment layer |
LayerKind.LAYER3D |
3D layer (not generally useful in Photopea) |
LayerKind.VIDEO |
Video layer |
// Identify layer type
var layer = doc.activeLayer;
if (layer.kind === LayerKind.TEXT) /* text layer */;
if (layer.kind === LayerKind.SMARTOBJECT) /* smart object */;
if (layer.typename === "LayerSet") /* group */;
// Filter: collect all text layers recursively
var textLayers = [];
function collectText(parent) {
for (var i = 0; i < parent.layers.length; i++) {
var l = parent.layers[i];
if (l.typename === "LayerSet") collectText(l);
else if (l.kind === LayerKind.TEXT) textLayers.push(l);
}
}
collectText(doc);
AnchorPosition Enum
| Constant |
Position |
AnchorPosition.TOPLEFT |
Top left |
AnchorPosition.TOPCENTER |
Top center |
AnchorPosition.TOPRIGHT |
Top right |
AnchorPosition.MIDDLELEFT |
Middle left |
AnchorPosition.MIDDLECENTER |
Center |
AnchorPosition.MIDDLERIGHT |
Middle right |
AnchorPosition.BOTTOMLEFT |
Bottom left |
AnchorPosition.BOTTOMCENTER |
Bottom center |
AnchorPosition.BOTTOMRIGHT |
Bottom right |
ElementPlacement Enum
Used with layer.move(relativeObject, placement):
| Constant |
Effect |
ElementPlacement.PLACEBEFORE |
Above the target layer in the |
…(truncated)
1---2name: photopea-embedded-editor3description: "Embed Photopea in web apps using photopea.js. Covers embedding, file I/O, scripting, exporting, layers, text, filters, and the full Photoshop-compatible API."4category: backend-and-data5source_repo: sickn33/agentic-awesome-skills6source_path: "skills/photopea-embedded-editor/SKILL.md"7source_url: https://github.com/sickn33/agentic-awesome-skills/blob/HEAD/skills/photopea-embedded-editor/SKILL.md8metadata:9 source: https://skillmd.com/skills/thedixitjain/photopea-embedded-editor10---111213# Photopea Embedded Editor Skill14## Using photopea.js (yikuansun/PhotopeaAPI) in Websites & Apps1516---1718## When to Use This Skill1920Use this skill for **every task** that involves:21- Embedding Photopea as an image editor inside a webpage or web app22- Controlling an embedded Photopea instance from your JavaScript code23- Automating image editing workflows from a host page (open files, run scripts, export results)24- Building an image editing feature into your product using Photopea as the engine25- Writing scripts to manipulate documents, layers, text, selections, filters, colors, and paths2627**Do NOT** use raw `postMessage` wiring — always use `photopea.js` as the wrapper.2829---3031## Library: photopea.js3233`photopea.js` is a Promises-based JavaScript wrapper around the Photopea Live Messaging API.34Repository: https://github.com/yikuansun/PhotopeaAPI35npm package: https://www.npmjs.com/package/photopea3637### Installation3839**CDN (no build step)**40```html41<script src="https://cdn.jsdelivr.net/npm/photopea@1.1.1/dist/photopea.min.js"></script>42```4344**Self-hosted**45```html46<script src="./photopea.min.js"></script>47```4849**npm (Webpack / Vite / Rollup)**50```bash51npm install photopea52```53```js54import Photopea from "photopea";55```5657---5859## Core API: The `Photopea` Class6061| Method | Description |62|--------|-------------|63| `Photopea.createEmbed(container)` | Creates + injects the iframe, resolves when ready |64| `new Photopea(window.parent)` | Plugin mode: wrap the parent window |65| `pea.runScript(script)` | Run JS string inside Photopea; returns output array |66| `pea.loadAsset(arrayBuffer)` | Load binary file (image, font, brush, etc.) |67| `pea.openFromURL(url, asSmart)` | Open remote URL as new doc or smart object layer |68| `pea.exportImage(type)` | Export current doc; returns `Blob` (`"png"` or `"jpg"`) |6970All methods return Promises — always `await` or `.then()`.7172---7374## Step 1 — Embed7576The container `<div>` **must** have a fixed width and height before calling `createEmbed`.7778```html79<div id="editor" style="width:1000px; height:650px;"></div>80<script src="https://cdn.jsdelivr.net/npm/photopea@1.1.1/dist/photopea.min.js"></script>81<script>82 Photopea.createEmbed(document.getElementById("editor")).then(async (pea) => {83 // pea is ready84 });85</script>86```8788**React:**89```jsx90import { useEffect, useRef } from "react";91import Photopea from "photopea";9293export default function Editor() {94 const containerRef = useRef(null);95 const peaRef = useRef(null);9697 useEffect(() => {98 if (!containerRef.current || peaRef.current) return;99 Photopea.createEmbed(containerRef.current).then((pea) => {100 peaRef.current = pea;101 });102 }, []);103104 return <div ref={containerRef} style={{ width: "100%", height: "650px" }} />;105}106```107108---109110## Step 2 — Opening Files111112```js113// Remote URL → new document114await pea.openFromURL("https://example.com/design.psd", false);115116// Remote URL → smart object layer inside current document117await pea.openFromURL("https://example.com/overlay.png", true);118119// Local file (user input → ArrayBuffer → loadAsset)120document.getElementById("fileInput").addEventListener("change", async (e) => {121 const buf = await e.target.files[0].arrayBuffer();122 await pea.loadAsset(buf);123});124125// Base64 data URI via runScript126await pea.runScript(`app.open("data:image/png;base64,iVBORw0...");`);127```128129---130131## Step 3 — Running Scripts132133`runScript` sends a JS string, returns an array of `app.echoToOE(...)` values + `"done"` last.134135```js136const result = await pea.runScript(`app.echoToOE("hello");`);137// result → ["hello", "done"]138139// Return structured data140const out = await pea.runScript(`141 app.echoToOE(JSON.stringify({142 width: app.activeDocument.width,143 height: app.activeDocument.height,144 layers: app.activeDocument.layers.length145 }));146`);147const info = JSON.parse(out[0]);148```149150---151152## Step 4 — Exporting153154```js155// PNG Blob (via exportImage)156const blob = await pea.exportImage("png");157document.getElementById("preview").src = URL.createObjectURL(blob);158159// JPEG Blob160const blob = await pea.exportImage("jpg");161162// WebP / PSD / quality-controlled JPEG via saveToOE163const result = await pea.runScript(`app.activeDocument.saveToOE("webp:0.85");`);164const webpBlob = new Blob([result[0]], { type: "image/webp" });165166const result = await pea.runScript(`app.activeDocument.saveToOE("psd:true");`);167const psdBlob = new Blob([result[0]], { type: "application/octet-stream" });168169// Trigger download170async function download(pea, filename = "export.png") {171 const blob = await pea.exportImage("png");172 const a = Object.assign(document.createElement("a"), {173 href: URL.createObjectURL(blob),174 download: filename175 });176 a.click();177}178```179180**Export format strings for `saveToOE`:**181182| String | Format |183|--------|--------|184| `"png"` | PNG lossless |185| `"jpg"` | JPEG default |186| `"jpg:0.8"` | JPEG quality 0.0–1.0 |187| `"webp:0.7"` | WebP quality 0.0–1.0 |188| `"psd"` | Full PSD |189| `"psd:true"` | Minified PSD |190| `"svg:true"` | SVG |191192---193194## Step 5 — Loading Assets195196```js197// Font198const buf = await (await fetch("https://example.com/MyFont.otf")).arrayBuffer();199await pea.loadAsset(buf);200// Now usable in textItem.font201202// Brush203await pea.loadAsset(await (await fetch("Nature.ABR")).arrayBuffer());204205// Gradient206await pea.loadAsset(await (await fetch("Gradients.GRD")).arrayBuffer());207```208209---210211## Step 6 — Plugin Mode212213```js214// Your page is inside Photopea's sidebar iframe215const pea = new Photopea(window.parent);216217const out = await pea.runScript(`app.echoToOE(app.activeDocument.width);`);218console.log("Width:", out[0]);219220// Load an asset from your plugin221const buf = await (await fetch("https://my-assets.com/sticker.png")).arrayBuffer();222await pea.loadAsset(buf);223```224225Plugin config:226```json227{228 "environment": {229 "plugins": [{230 "name": "My Plugin",231 "url": "https://my-plugin.example.com",232 "icon": "===https://my-plugin.example.com/icon.png"233 }]234 }235}236```237238---239240## Utility Patterns241242### addImageAndWait — robust async layer insertion243```js244async function addImageAndWait(pea, imgURI) {245 let count = "done";246 while (count === "done")247 count = (await pea.runScript(`app.echoToOE(app.activeDocument.layers.length)`))[0];248 count = parseInt(count);249250 const imageUrlLiteral = JSON.stringify(imgURI);251 await pea.runScript(`app.open(${imageUrlLiteral}, null, true);`);252253 return new Promise((resolve) => {254 const check = async () => {255 const n = parseInt((await pea.runScript(256 `app.echoToOE(app.activeDocument.layers.length)`257 ))[0]);258 n === count + 1 ? resolve() : setTimeout(check, 50);259 };260 check();261 });262}263```264265### getDocumentAsImage — returns `<img>` element266```js267async function getDocumentAsImage(pea) {268 const result = await pea.runScript(`app.activeDocument.saveToOE('png')`);269 return new Promise((resolve) => {270 const fr = new FileReader();271 fr.addEventListener("load", (e) => {272 const img = new Image(); img.src = e.target.result; resolve(img);273 });274 fr.readAsDataURL(new Blob([result[0]], { type: "image/png" }));275 });276}277```278279---280281## Real-World Patterns282283### Pattern A — Open + Export UI284```html285<input type="file" id="fileInput" accept="image/*,.psd">286<button id="exportBtn">Export PNG</button>287<div id="editor" style="width:100%;height:600px;"></div>288<script src="https://cdn.jsdelivr.net/npm/photopea@1.1.1/dist/photopea.min.js"></script>289<script>290let pea;291Photopea.createEmbed(document.getElementById("editor")).then(p => pea = p);292293document.getElementById("fileInput").addEventListener("change", async e => {294 await pea.loadAsset(await e.target.files[0].arrayBuffer());295});296document.getElementById("exportBtn").addEventListener("click", async () => {297 const blob = await pea.exportImage("png");298 const a = Object.assign(document.createElement("a"), {299 href: URL.createObjectURL(blob), download: "export.png"300 });301 a.click();302});303</script>304```305306### Pattern B — Template + Text Edit + Export307```js308async function generateCard(pea, name, tagline) {309 await pea.openFromURL("https://example.com/card.psd", false);310 const nameLiteral = JSON.stringify(name);311 const taglineLiteral = JSON.stringify(tagline);312 await pea.runScript(`313 app.activeDocument.layers.getByName("Name").textItem.contents = ${nameLiteral};314 app.activeDocument.layers.getByName("Tagline").textItem.contents = ${taglineLiteral};315 `);316 return await pea.exportImage("png");317}318```319320### Pattern C — Batch Watermark321```js322async function batchWatermark(pea, imageURLs, watermarkURL) {323 const results = [];324 for (const url of imageURLs) {325 await pea.openFromURL(url, false);326 await pea.openFromURL(watermarkURL, true);327 await pea.runScript(`328 var doc = app.activeDocument, wm = doc.activeLayer;329 wm.translate(doc.width - wm.bounds[2] - 20, doc.height - wm.bounds[3] - 20);330 wm.opacity = 70;331 `);332 results.push(await pea.exportImage("png"));333 await pea.runScript(`app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);`);334 }335 return results;336}337```338339---340341# FULL SCRIPTING API REFERENCE342343> All code in this section runs **inside `pea.runScript("...")`** strings.344> Photopea implements the Adobe Photoshop CC 2015 JavaScript scripting interface.345> Any Photoshop script targeting that version should work in Photopea.346347---348349## `app` — Application Object350351### Properties352353| Property | Type | R/W | Description |354|----------|------|-----|-------------|355| `app.activeDocument` | Document | R/W | The currently active document |356| `app.documents` | Documents | R | Collection of all open documents |357| `app.documents.length` | number | R | Count of open documents |358| `app.documents[i]` | Document | R | Access by zero-based index |359| `app.foregroundColor` | SolidColor | R/W | Current foreground color |360| `app.backgroundColor` | SolidColor | R/W | Current background color |361| `app.preferences.rulerUnits` | Units | R/W | `Units.PIXELS`, `Units.CM`, `Units.INCHES`, `Units.MM`, `Units.PICAS`, `Units.POINTS`, `Units.PERCENT` |362| `app.preferences.typeUnits` | TypeUnits | R/W | `TypeUnits.PIXELS`, `TypeUnits.MM`, `TypeUnits.POINTS` |363| `app.displayDialogs` | DialogModes | R/W | `DialogModes.NO`, `DialogModes.ALL`, `DialogModes.ERROR` |364365### Methods366367| Method | Description |368|--------|-------------|369| `app.open(url)` | Open URL as new document |370| `app.open(url, null, true)` | Open URL as smart object layer in active document |371| `app.echoToOE(string)` | **Photopea extension** — send string to host page (captured by `runScript`) |372| `app.showWindow("magiccut")` | **Photopea extension** — open Magic Cut panel |373| `app.showWindow("vbitmap")` | **Photopea extension** — open Vectorize Bitmap panel |374| `app.UI.zoomIn()` | Zoom in |375| `app.UI.zoomOut()` | Zoom out |376| `app.UI.fitTheArea()` | Fit canvas to viewport |377| `app.UI.pixelToPixel()` | 100% zoom |378| `app.UI.switchFullscreen()` | Toggle fullscreen |379| `app.UI.scroll(dx, dy)` | Scroll by delta |380| `app.UI.scrollTo(x, y)` | Scroll to absolute position |381382**Important:** Always set ruler units to pixels at the start of any script that uses pixel measurements:383```js384var savedUnits = app.preferences.rulerUnits;385app.preferences.rulerUnits = Units.PIXELS;386// ... your code ...387app.preferences.rulerUnits = savedUnits;388```389390---391392## `Document` — Document Object393394Access via `app.activeDocument` or `app.documents[i]`.395396### Properties397398| Property | Type | R/W | Description |399|----------|------|-----|-------------|400| `width` | number | R | Document width in current ruler units |401| `height` | number | R | Document height in current ruler units |402| `resolution` | number | R | DPI (pixels per inch) |403| `name` | string | **R/W** | **Photopea extension** — display label (no history step) |404| `source` | string | **R/W** | **Photopea extension** — file origin URL or `"local,X,NAME"` |405| `mode` | DocumentMode | R | `DocumentMode.RGB`, `GRAYSCALE`, `CMYK`, `LAB`, `BITMAP`, `INDEXEDCOLOR`, `MULTICHANNEL` |406| `bitsPerChannel` | BitsPerChannelType | R | `BitsPerChannelType.EIGHT`, `SIXTEEN`, `THIRTYTWO` |407| `colorProfileName` | string | R | Name of embedded color profile |408| `activeLayer` | Layer/ArtLayer/LayerSet | R/W | Set to activate a layer |409| `currentLayer` | ArtLayer | R/W | Alias for `activeLayer` |410| `layers` | Layers | R | All top-level layers (both art + group) |411| `artLayers` | ArtLayers | R | All top-level art layers only |412| `layerSets` | LayerSets | R | All top-level group layers only |413| `selection` | Selection | R | The current selection |414| `channels` | Channels | R | All channels |415| `historyStates` | HistoryStates | R | Undo history |416| `activeHistoryState` | HistoryState | R/W | Current history position |417| `layerComps` | LayerComps | R | Layer comps collection |418| `guides` | Guides | R | Guides collection |419| `pathItems` | PathItems | R | Vector paths |420| `id` | number | R | Unique document ID |421| `saved` | boolean | R | Whether document has unsaved changes |422| `quickMaskMode` | boolean | R | Whether in Quick Mask mode |423| `backgroundLayer` | ArtLayer | R | The background layer |424| `pixelAspectRatio` | number | R | Custom pixel aspect ratio (0.1–10.0) |425| `histogram` | array | R | 256-element histogram array |426427### Methods428429| Method | Signature | Description |430|--------|-----------|-------------|431| `resizeImage` | `(w, h, res, resampleMethod)` | Resize image pixels. ResampleMethod: `BICUBIC`, `BILINEAR`, `NEARESTNEIGHBOR`, `NONE`, `BICUBICSHARPER`, `BICUBICSMOOTHER` |432| `resizeCanvas` | `(w, h, anchor)` | Resize canvas without scaling. AnchorPosition: `TOPLEFT`, `TOPCENTER`, `TOPRIGHT`, `MIDDLELEFT`, `MIDDLECENTER`, `MIDDLERIGHT`, `BOTTOMLEFT`, `BOTTOMCENTER`, `BOTTOMRIGHT` |433| `rotateCanvas` | `(degrees)` | Rotate entire canvas. Positive = clockwise |434| `flipCanvas` | `(direction)` | `Direction.HORIZONTAL` or `Direction.VERTICAL` |435| `crop` | `([x1,y1,x2,y2], angle, w, h)` | Crop canvas. Angle and dimensions are optional |436| `trim` | `(trimType, top, left, bottom, right)` | Trim transparent/background-color borders. TrimType: `TRANSPARENT`, `TOPLEFT`, `BOTTOMRIGHT` |437| `revealAll` | `()` | Expand canvas to show clipped content |438| `flatten` | `()` | Merge all layers into one |439| `mergeVisibleLayers` | `()` | Merge all visible layers |440| `rasterizeAllLayers` | `()` | Rasterize all vector/text layers |441| `changeMode` | `(mode, options)` | Convert color mode (e.g., `ChangeMode.GRAYSCALE`) |442| `convertProfile` | `(profileName, renderingIntent, blackPointCompensation, dither)` | Convert color profile |443| `duplicate` | `(name, mergedLayers)` | Duplicate the document |444| `close` | `(saveOptions)` | Close document. SaveOptions: `DONOTSAVECHANGES`, `SAVECHANGES`, `PROMPTTOSAVECHANGES` |445| `save` | `()` | Save (requires server config in embed) |446| `saveToOE` | `(format)` | **Photopea extension** — send binary to host. Formats: `"png"`, `"jpg:0.8"`, `"webp:0.7"`, `"psd:true"`, `"svg:true"` |447| `clearHistory` | `()` | **Photopea extension** — clear undo history to free RAM |448| `exportDocument` | `(file, exportType, options)` | Export to filesystem (triggers ZIP). ExportType: `SAVEFORWEB` |449| `paste` | `(intoSelection)` | Paste clipboard into document |450| `suspendHistory` | `(historyName, callback)` | Wrap multiple ops in one history state |451452**Practical examples:**453```js454var doc = app.activeDocument;455456// Resize image to 1920×1080 at 72dpi bicubic457doc.resizeImage(1920, 1080, 72, ResampleMethod.BICUBIC);458459// Expand canvas to 2000px wide, keeping content centered460doc.resizeCanvas(2000, doc.height, AnchorPosition.MIDDLECENTER);461462// Crop to a region463doc.crop([100, 100, 900, 600]);464465// Trim transparent edges466doc.trim(TrimType.TRANSPARENT, true, true, true, true);467468// Flip horizontal469doc.flipCanvas(Direction.HORIZONTAL);470471// Change to grayscale472doc.changeMode(ChangeMode.GRAYSCALE);473474// One undo step for many operations475doc.suspendHistory("Batch Edit", "action");476// (Inside Photopea, all ops become one history state)477478// Export PNG to filesystem (triggers ZIP download)479var opts = new ExportOptionsSaveForWeb();480opts.format = SaveDocumentType.PNG;481opts.PNG8 = false;482opts.quality = 100;483doc.exportDocument(new File("/output.png"), ExportType.SAVEFORWEB, opts);484485// Close without saving486doc.close(SaveOptions.DONOTSAVECHANGES);487```488489---490491## `Layers` / `ArtLayers` / `LayerSets` Collections492493These collections exist on `Document`, `LayerSet` (groups within groups), and can be iterated.494495```js496var doc = app.activeDocument;497498// Access499doc.layers // all top-level (art + groups)500doc.artLayers // top-level art layers only501doc.layerSets // top-level group layers only502503// By index (0 = topmost)504doc.layers[0]505doc.layers[doc.layers.length - 1] // bottommost506507// By name (throws if not found)508doc.layers.getByName("Background")509doc.artLayers.getByName("Logo")510doc.layerSets.getByName("Header Group")511512// Add513var newLayer = doc.artLayers.add(); // new blank art layer514var newGroup = doc.layerSets.add(); // new group515var innerLayer = newGroup.artLayers.add(); // layer inside a group516517// Remove518doc.artLayers.getByName("Temp").remove();519520// Iterate all layers recursively521function walkLayers(parent) {522 for (var i = 0; i < parent.layers.length; i++) {523 var l = parent.layers[i];524 if (l.typename === "LayerSet") walkLayers(l);525 else /* ArtLayer */ processLayer(l);526 }527}528walkLayers(doc);529```530531---532533## `ArtLayer` — Individual Layer534535### Properties536537| Property | Type | R/W | Description |538|----------|------|-----|-------------|539| `name` | string | R/W | Layer name |540| `visible` | boolean | R/W | Layer visibility |541| `opacity` | number | R/W | Layer opacity 0–100 |542| `fillOpacity` | number | R | Fill opacity 0–100 |543| `blendMode` | BlendMode | R/W | Blend mode (see enum below) |544| `kind` | LayerKind | R/W | Layer type (can set to `LayerKind.TEXT` on empty layer) |545| `textItem` | TextItem | R | Text object (only when `kind === LayerKind.TEXT`) |546| `bounds` | array | R | `[left, top, right, bottom]` in current ruler units |547| `parent` | Document/LayerSet | R | Containing object |548| `typename` | string | R | Always `"ArtLayer"` |549| `selected` | boolean | R | **Photopea extension** — is layer highlighted in panel |550| `isBackgroundLayer` | boolean | R | Is this the locked background layer |551| `grouped` | boolean | R | Is clipping mask applied |552| `pixelsLocked` | boolean | R | Pixels locked |553| `positionLocked` | boolean | R | Position locked |554| `transparentPixelsLocked` | boolean | R | Transparent pixels locked |555| `layerMaskDensity` | number | R | Layer mask density 0–100 |556| `layerMaskFeather` | number | R | Layer mask feather 0–250 |557| `vectorMaskDensity` | number | R | Vector mask density 0–100 |558| `vectorMaskFeather` | number | R | Vector mask feather 0–250 |559560### Transform Methods561562| Method | Signature | Description |563|--------|-----------|-------------|564| `translate` | `(deltaX, deltaY)` | Move layer by offset |565| `rotate` | `(angle, anchor)` | Rotate by degrees. AnchorPosition optional (default center) |566| `resize` | `(widthPct, heightPct, anchor)` | Scale as percentage of current size |567| `rasterize` | `(target)` | Rasterize. RasterizeType: `ENTIRE`, `FILLCONTENT`, `LAYERCLIPPINGMASK`, `LINKEDLAYERS`, `SHAPE`, `TEXTCONTENTS`, `VECTORMASK` |568569### Layer Management Methods570571| Method | Signature | Description |572|--------|-----------|-------------|573| `duplicate` | `()` | Duplicate to same document, returns new layer |574| `duplicate` | `(doc, placement)` | Duplicate to another document |575| `remove` | `()` | Delete the layer |576| `merge` | `()` | Merge down; returns the merged ArtLayer |577| `move` | `(relativeLayer, placement)` | Reorder. ElementPlacement: `PLACEBEFORE`, `PLACEAFTER`, `PLACEATBEGINNING`, `PLACEATEND`, `INSIDE` |578| `copy` | `(merged)` | Copy to clipboard |579| `cut` | `()` | Cut to clipboard |580| `clear` | `()` | Cut without clipboard |581582### Adjustment Methods on ArtLayer583584| Method | Signature | Description |585|--------|-----------|-------------|586| `adjustBrightnessContrast` | `(brightness, contrast)` | Brightness -100–100, Contrast -100–100 |587| `adjustColorBalance` | `(shadows, midtones, highlights, preserveLuminosity)` | Each is `[cyan-red, magenta-green, yellow-blue]` array |588| `adjustCurves` | `(curveShape)` | Array of `[input,output]` pairs per channel |589| `adjustLevels` | `(inputRangeStart, inputRangeEnd, gamma, outputRangeStart, outputRangeEnd)` | Levels adjustment |590| `autoLevels` | `()` | Auto levels |591| `autoContrast` | `()` | Auto contrast |592| `desaturate` | `()` | Convert to grayscale values in current mode |593| `equalize` | `()` | Equalize brightness distribution |594| `invert` | `()` | Invert pixel colors |595| `posterize` | `(levels)` | Posterize (2–255 levels) |596| `threshold` | `(level)` | B&W threshold (1–255) |597| `shadowHighlight` | `(shadowAmount, shadowWidth, shadowRadius, highlightAmount, highlightWidth, highlightRadius, colorCorrection, midtoneContrast, blackClip, whiteClip)` | Shadows/Highlights |598| `photoFilter` | `(fillColor, density, luminosity)` | Photo filter |599| `mixChannels` | `(outputChannels, monochrome)` | Channel mixer |600| `selectiveColor` | `(colors, cyan, magenta, yellow, black, method)` | Selective color |601602### Filter Methods on ArtLayer603604| Method | Signature | Description |605|--------|-----------|-------------|606| `applyGaussianBlur` | `(radius)` | Gaussian blur (0.1–250 px radius) |607| `applyMotionBlur` | `(angle, distance)` | Motion blur |608| `applyRadialBlur` | `(amount, blurMethod, blurQuality)` | Radial blur |609| `applySmartBlur` | `(radius, threshold, blurQuality, blurMode)` | Smart blur |610| `applyBlur` | `()` | Simple blur |611| `applyBlurMore` | `()` | Blur more |612| `applyUnSharpMask` | `(amount, radius, threshold)` | Unsharp mask |613| `applySharpen` | `()` | Sharpen |614| `applySharpenEdges` | `()` | Sharpen edges |615| `applySharpenMore` | `()` | Sharpen more |616| `applyAddNoise` | `(amount, distribution, monochromatic)` | Add noise. NoiseDistribution: `GAUSSIAN`, `UNIFORM` |617| `applyDespeckle` | `()` | Despeckle |618| `applyDustAndScratches` | `(radius, threshold)` | Dust and scratches |619| `applyMedianNoise` | `(radius)` | Median noise reduction |620| `applyMaximum` | `(radius)` | Maximum filter (dilate) |621| `applyMinimum` | `(radius)` | Minimum filter (erode) |622| `applyHighPass` | `(radius)` | High pass |623| `applyOffset` | `(horizontal, vertical, undefinedAreas)` | Offset. UndefinedAreas: `SETTOBACKGROUND`, `WRAPAROUND`, `REPEATEDGEPIXELS` |624| `applyRipple` | `(amount, size)` | Ripple. RippleSize: `SMALL`, `MEDIUM`, `LARGE` |625| `applyWave` | `(generators, minWavelength, maxWavelength, minAmplitude, maxAmplitude, horizScale, vertScale, waveType, undefinedAreas, randomSeed)` | Wave filter |626| `applyZigZag` | `(amount, ridges, style)` | Zig-Zag |627| `applyTwirl` | `(angle)` | Twirl |628| `applyPolarCoordinates` | `(conversion)` | Polar coordinates |629| `applySpherize` | `(amount, mode)` | Spherize |630| `applyPinch` | `(amount)` | Pinch (-100–100) |631| `applyShear` | `(curve, undefinedAreas)` | Shear |632| `applyDisplace` | `(horizontalScale, verticalScale, displacementType, undefinedAreas, displacementMapFile)` | Displace |633| `applyClouds` | `()` | Render Clouds |634| `applyDifferenceClouds` | `()` | Difference Clouds |635| `applyLensFlare` | `(brightness, flareCenter, lensType)` | Lens Flare. LensType: `ZOOMWIDE, ZOOMNORMAL, MOVIE` |636| `applyDiffuseGlow` | `(graininess, glowAmount, clearAmount)` | Diffuse Glow |637| `applyGlassEffect` | `(distortion, smoothness, scaling, invert, texture, textureFile)` | Glass |638| `applyOceanRipple` | `(size, magnitude)` | Ocean Ripple |639| `applyLensBlur` | `(source, focalDistance, invertDepthMap, shape, radius, bladeCurvature, rotation, brightness, threshold, amount, distribution, monochromatic)` | Lens Blur |640| `applyAverage` | `()` | Average blur |641| `applyDeInterlace` | `(eliminateFields, createFields)` | De-interlace |642| `applyNTSC` | `()` | NTSC colors |643| `applyCustomFilter` | `(characteristics, scale, offset)` | Custom filter (5×5 matrix) |644| `applyTextureFill` | `(textureFile)` | Texture fill |645| `applyStyle` | `(styleName)` | Apply a layer style preset by name |646| `photoFilter` | `(fillColor, density, luminosity)` | Photo Filter |647648**Practical examples:**649```js650var layer = app.activeDocument.activeLayer;651652// Move to absolute position (layer.bounds[0] = current left edge)653layer.translate(200 - layer.bounds[0], 100 - layer.bounds[1]);654655// Rotate 45° around center656layer.rotate(45);657658// Scale to 50% keeping center659layer.resize(50, 50, AnchorPosition.MIDDLECENTER);660661// Gaussian blur radius 10662layer.applyGaussianBlur(10);663664// Unsharp mask665layer.applyUnSharpMask(50, 2, 0);666667// Levels: input 0–200, gamma 1.2, output 0–255668layer.adjustLevels(0, 200, 1.2, 0, 255);669670// Brightness +20, Contrast +10671layer.adjustBrightnessContrast(20, 10);672673// Invert674layer.invert();675676// Rasterize text677layer.rasterize(RasterizeType.TEXTCONTENTS);678679// Duplicate layer680var copy = layer.duplicate();681copy.name = "Layer Copy";682683// Move layer below another684var target = doc.layers.getByName("Background");685layer.move(target, ElementPlacement.PLACEAFTER);686```687688---689690## `LayerSet` — Group Layer691692A LayerSet is a folder/group in the Layers panel. It has the same layer management methods as `Document`.693694### Properties695696| Property | Type | R/W | Description |697|----------|------|-----|-------------|698| `name` | string | R/W | Group name |699| `visible` | boolean | R/W | Group visibility |700| `opacity` | number | R/W | Group opacity 0–100 |701| `blendMode` | BlendMode | R/W | Group blend mode |702| `bounds` | array | R | Bounding box `[left,top,right,bottom]` |703| `layers` | Layers | R | All layers inside this group |704| `artLayers` | ArtLayers | R | Art layers inside this group |705| `layerSets` | LayerSets | R | Sub-groups inside this group |706| `parent` | Document/LayerSet | R | Parent container |707| `typename` | string | R | Always `"LayerSet"` |708709### Methods710Same as Document for layer management: `layers.add()`, `artLayers.add()`, `layerSets.add()`, `.getByName()`, plus `duplicate()`, `remove()`, `move()`.711712```js713// Create group with layers inside714var group = doc.layerSets.add();715group.name = "Product Card";716717var bgLayer = group.artLayers.add(); bgLayer.name = "Background";718var textLayer = group.artLayers.add(); textLayer.kind = LayerKind.TEXT;719textLayer.textItem.contents = "Buy Now";720textLayer.textItem.size = 36;721722// Collapse/expand group (Photopea specific, not in standard DOM)723// Use visibility as workaround724725// Get specific layer inside a group726var innerLayer = doc.layerSets.getByName("Header Group").artLayers.getByName("Title");727```728729---730731## `TextItem` — Text Layer Content732733Access via `layer.textItem` on any layer with `layer.kind === LayerKind.TEXT`.734735### Core Properties (most commonly used)736737| Property | Type | R/W | Description |738|----------|------|-----|-------------|739| `contents` | string | R/W | The actual text content |740| `font` | string | R/W | Font PostScript name (e.g. `"ArialMT"`, `"Verdana-Bold"`) |741| `size` | number | R/W | Font size in points |742| `color` | SolidColor | R/W | Text color |743| `position` | array | R/W | `[x, y]` origin of text (point text) or bounding box top-left |744| `justification` | Justification | R/W | `Justification.LEFT`, `CENTER`, `RIGHT`, `FULLJUSTIFY` |745| `kind` | TextType | R/W | `TextType.POINTTEXT` or `TextType.PARAGRAPHTEXT` |746| `width` | number | R/W | Width of bounding box (paragraph text only) |747| `height` | number | R/W | Height of bounding box (paragraph text only) |748| `direction` | Direction | R/W | `Direction.HORIZONTAL` or `Direction.VERTICAL` |749750### Typography Properties751752| Property | Type | R/W | Description |753|----------|------|-----|-------------|754| `leading` | number | R/W | Line spacing in points |755| `tracking` | number | R/W | Letter spacing -1000–10000 (1000 = 1 em) |756| `horizontalScale` | number | R/W | Horizontal scaling 0–1000% |757| `verticalScale` | number | R/W | Vertical scaling 0–1000% |758| `baselineShift` | number | R/W | Baseline offset in points |759| `capitalization` | Case | R/W | `Case.NORMAL`, `ALLCAPS`, `SMALLCAPS` |760| `fauxBold` | boolean | R/W | Simulated bold |761| `fauxItalic` | boolean | R/W | Simulated italic |762| `underline` | UnderlineType | R/W | `UnderlineType.NONE`, `UNDERLINELEFT`, `UNDERLINERIGHT` |763| `strikeThru` | StrikeThruType | R/W | `StrikeThruType.NONE`, `STRIKEBOX`, `STRIKEHEIGHT` |764| `antiAliasMethod` | AntiAlias | R/W | `AntiAlias.NONE`, `SHARP`, `CRISP`, `STRONG`, `SMOOTH` |765| `autoKerning` | AutoKernType | R/W | `AutoKernType.MANUAL`, `METRICS`, `OPTICAL` |766| `language` | Language | R/W | `Language.ENGLISH`, etc. |767| `ligatures` | boolean | R/W | Enable ligatures |768| `alternateLigatures` | boolean | R/W | Enable alternate ligatures |769| `oldStyle` | boolean | R/W | Old-style numerals |770| `noBreak` | boolean | R/W | Prevent line breaks in this text |771| `useAutoLeading` | boolean | R/W | Use font's built-in leading |772| `autoLeadingAmount` | number | R/W | Auto leading percentage 0.01–5000 |773| `hyphenation` | boolean | R/W | Enable hyphenation |774775### Paragraph Properties776777| Property | Type | R/W | Description |778|----------|------|-----|-------------|779| `leftIndent` | number | R/W | Left indent -1296–1296 |780| `rightIndent` | number | R/W | Right indent -1296–1296 |781| `firstLineIndent` | number | R/W | First line indent -1296–1296 |782| `spaceBefore` | number | R/W | Space before paragraph -1296–1296 |783| `spaceAfter` | number | R/W | Space after paragraph -1296–1296 |784| `hangingPuntuation` | boolean | R/W | Roman hanging punctuation |785| `textComposer` | TextComposer | R/W | `TextComposer.ADOBEEVERYLINE`, `ADOBESINGLELINE` |786787### Warp Properties788789| Property | Type | R/W | Description |790|----------|------|-----|-------------|791| `warpStyle` | WarpStyle | R/W | `WarpStyle.NONE`, `ARC`, `ARCH`, `BULGE`, `SHELLLOWER`, `SHELLUPPER`, `FLAG`, `WAVE`, `FISH`, `RISE`, `FISHEYE`, `INFLATE`, `SQUEEZE`, `TWIST` |792| `warpDirection` | Direction | R/W | `Direction.HORIZONTAL` or `Direction.VERTICAL` |793| `warpBend` | number | R/W | Warp bend -100–100 |794| `warpHorizontalDistortion` | number | R/W | Horizontal distortion -100–100 |795| `warpVerticalDistortion` | number | R/W | Vertical distortion -100–100 |796797### Photopea Extensions798799| Property | Type | Description |800|----------|------|-------------|801| `totalTextStyle` | string | JSON string with ALL style parameters of the text |802| `transform` | string | JSON array — the affine transform matrix of the text |803804### Methods805806| Method | Description |807|--------|-------------|808| `convertToShape()` | Convert text to a filled shape layer with text as clipping path |809| `createPath()` | Create work path from text outlines |810811**Practical examples:**812```js813var layer = doc.layers.getByName("Headline");814var text = layer.textItem;815816// Set content817text.contents = "Hello World";818819// Style820text.font = "Verdana-Bold";821text.size = 72;822text.color.rgb.hexValue = "FF0000"; // red823824// Position point text at (50, 100)825text.position = [50, 100];826827// Center align828text.justification = Justification.CENTER;829830// Paragraph text with bounding box831text.kind = TextType.PARAGRAPHTEXT;832text.width = new UnitValue("400 pixels");833text.height = new UnitValue("200 pixels");834835// Letter spacing836text.tracking = 100; // 10% spacing837838// Scale text horizontally to 80%839text.horizontalScale = 80;840841// Warp arc842text.warpStyle = WarpStyle.ARC;843text.warpBend = 30;844845// Read all text styles as JSON (Photopea extension)846var styles = JSON.parse(text.totalTextStyle);847app.echoToOE(JSON.stringify(styles));848```849850---851852## Creating a Text Layer from Scratch853854```js855app.preferences.rulerUnits = Units.PIXELS;856857var layer = doc.artLayers.add();858layer.kind = LayerKind.TEXT; // Convert blank layer to text859layer.name = "My Title";860861var text = layer.textItem;862text.contents = "Welcome";863text.font = "ArialMT";864text.size = 48;865text.justification = Justification.CENTER;866text.position = [doc.width / 2, 100];867868var color = new SolidColor();869color.rgb.red = 255;870color.rgb.green = 255;871color.rgb.blue = 255;872text.color = color;873```874875---876877## `SolidColor` — Color Object878879```js880// RGB (most common in Photopea)881var c = new SolidColor();882c.rgb.red = 255; // 0–255883c.rgb.green = 128;884c.rgb.blue = 0;885c.rgb.hexValue = "FF8000"; // Set via hex string (no #)886887// CMYK888var c2 = new SolidColor();889c2.cmyk.cyan = 0; // 0–100890c2.cmyk.magenta = 50;891c2.cmyk.yellow = 100;892c2.cmyk.black = 0;893894// Grayscale895var c3 = new SolidColor();896c3.gray.gray = 50; // 0–100897898// HSB899var c4 = new SolidColor();900c4.hsb.hue = 30; // 0–360901c4.hsb.saturation = 100; // 0–100902c4.hsb.brightness = 100; // 0–100903904// Lab905var c5 = new SolidColor();906c5.lab.l = 50; // 0–100907c5.lab.a = 20; // -128–127908c5.lab.b = 40; // -128–127909910// Set as foreground color911app.foregroundColor = c;912913// Use with selection fill914doc.selection.selectAll();915doc.selection.fill(c);916doc.selection.deselect();917```918919---920921## `Selection` — Selection Object922923Access via `doc.selection`.924925### Properties926927| Property | Type | Description |928|----------|------|-------------|929| `bounds` | array | `[left, top, right, bottom]` bounding rectangle |930| `solid` | boolean | Whether selection is a solid rectangle |931932### Methods933934| Method | Signature | Description |935|--------|-----------|-------------|936| `selectAll` | `()` | Select entire document |937| `deselect` | `()` | Remove selection |938| `invert` | `()` | Invert the selection |939| `select` | `(region, type, feather, antiAlias)` | Select polygon region. Region is array of `[x,y]` points. SelectionType: `REPLACE`, `ADD`, `SUBTRACT`, `INTERSECT` |940| `feather` | `(radius)` | Feather the selection edges |941| `contract` | `(radius)` | Contract (shrink) selection |942| `expand` | `(radius)` | Expand selection |943| `grow` | `(tolerance, antiAlias)` | Grow selection to similar adjacent pixels |944| `similar` | `(tolerance, antiAlias)` | Select similar pixels throughout document |945| `smooth` | `(radius)` | Smooth selection edges |946| `selectBorder` | `(width)` | Select only the border of the current selection |947| `resize` | `(widthPct, heightPct, anchor)` | Resize selection boundary |948| `rotate` | `(angle, anchor)` | Rotate selection boundary |949| `translate` | `(deltaX, deltaY)` | Move selection boundary |950| `fill` | `(fillWith, mode, opacity, preserveTransparency)` | Fill selection with color or content. fillWith is SolidColor or string |951| `stroke` | `(strokeColor, width, location, mode, opacity, preserveTransparency)` | Stroke selection border. StrokeLocation: `INSIDE`, `OUTSIDE`, `CENTER` |952| `copy` | `(merged)` | Copy selection to clipboard |953| `cut` | `()` | Cut selection to clipboard |954| `clear` | `()` | Delete selection content |955| `load` | `(from, type, invert)` | Load selection from channel |956| `store` | `(into, type)` | Save selection as channel |957| `makeWorkPath` | `(tolerance)` | Convert to work path |958959**Practical examples:**960```js961var sel = doc.selection;962963// Rectangle select (top-left to bottom-right)964sel.select([[0,0],[500,0],[500,300],[0,300]]);965966// Select all967sel.selectAll();968969// Add to existing selection970sel.select([[600,0],[900,0],[900,300],[600,300]], SelectionType.ADD);971972// Feather 10px973sel.feather(10);974975// Contract by 5px976sel.contract(5);977978// Fill with red979var red = new SolidColor();980red.rgb.red = 255; red.rgb.green = 0; red.rgb.blue = 0;981sel.fill(red);982983// Stroke selection with black, 3px, inside984var black = new SolidColor();985black.rgb.hexValue = "000000";986sel.stroke(black, 3, StrokeLocation.INSIDE);987988// Copy, paste as new layer989sel.copy();990doc.paste();991992// Invert and delete (remove background)993sel.invert();994sel.clear();995sel.deselect();996```997998---9991000## `BlendMode` Enum — All Values10011002Used in `layer.blendMode` (string form in Photopea) and `BlendMode` constant (standard):10031004| `BlendMode` Constant | Photopea String | Name |1005|----------------------|-----------------|------|1006| `BlendMode.NORMAL` | `"norm"` | Normal |1007| `BlendMode.DISSOLVE` | `"diss"` | Dissolve |1008| `BlendMode.DARKEN` | `"dark"` | Darken |1009| `BlendMode.MULTIPLY` | `"mul "` | Multiply |1010| `BlendMode.COLORBURN` | `"idiv"` | Color Burn |1011| `BlendMode.LINEARBURN` | `"lbrn"` | Linear Burn |1012| `BlendMode.DARKERCOLOR` | `"dkCl"` | Darker Color |1013| `BlendMode.LIGHTEN` | `"lite"` | Lighten |1014| `BlendMode.SCREEN` | `"scrn"` | Screen |1015| `BlendMode.COLORDODGE` | `"div "` | Color Dodge |1016| `BlendMode.LINEARDODGE` | `"lddg"` | Linear Dodge (Add) |1017| `BlendMode.LIGHTERCOLOR` | `"lgCl"` | Lighter Color |1018| `BlendMode.OVERLAY` | `"over"` | Overlay |1019| `BlendMode.SOFTLIGHT` | `"sLit"` | Soft Light |1020| `BlendMode.HARDLIGHT` | `"hLit"` | Hard Light |1021| `BlendMode.VIVIDLIGHT` | `"vLit"` | Vivid Light |1022| `BlendMode.LINEARLIGHT` | `"lLit"` | Linear Light |1023| `BlendMode.PINLIGHT` | `"pLit"` | Pin Light |1024| `BlendMode.HARDMIX` | `"hMix"` | Hard Mix |1025| `BlendMode.DIFFERENCE` | `"diff"` | Difference |1026| `BlendMode.EXCLUSION` | `"smud"` | Exclusion |1027| `BlendMode.SUBTRACT` | `"fsub"` | Subtract |1028| `BlendMode.DIVIDE` | `"fdiv"` | Divide |1029| `BlendMode.HUE` | `"hue "` | Hue |1030| `BlendMode.SATURATION` | `"sat "` | Saturation |1031| `BlendMode.COLOR` | `"colr"` | Color |1032| `BlendMode.LUMINOSITY` | `"lum "` | Luminosity |1033| `BlendMode.PASSTHROUGH` | `"pass"` | Pass Through (groups only) |10341035```js1036// Use either form:1037layer.blendMode = BlendMode.SCREEN; // constant1038layer.blendMode = "scrn"; // string (Photopea internal form)1039```10401041---10421043## `LayerKind` Enum10441045| Constant | Description |1046|----------|-------------|1047| `LayerKind.NORMAL` | Regular pixel layer |1048| `LayerKind.TEXT` | Text layer |1049| `LayerKind.SMARTOBJECT` | Smart Object / linked layer |1050| `LayerKind.SOLIDFILL` | Solid color fill layer |1051| `LayerKind.GRADIENTFILL` | Gradient fill layer |1052| `LayerKind.PATTERNFILL` | Pattern fill layer |1053| `LayerKind.BRIGHTNESSCONTRAST` | Brightness/Contrast adjustment layer |1054| `LayerKind.CURVES` | Curves adjustment layer |1055| `LayerKind.LEVELS` | Levels adjustment layer |1056| `LayerKind.HUESATURATION` | Hue/Saturation adjustment layer |1057| `LayerKind.COLORBALANCE` | Color Balance adjustment layer |1058| `LayerKind.CHANNELMIXER` | Channel Mixer adjustment layer |1059| `LayerKind.GRADIENTMAP` | Gradient Map adjustment layer |1060| `LayerKind.INVERSION` | Invert adjustment layer |1061| `LayerKind.POSTERIZE` | Posterize adjustment layer |1062| `LayerKind.THRESHOLD` | Threshold adjustment layer |1063| `LayerKind.SELECTIVECOLOR` | Selective Color adjustment layer |1064| `LayerKind.PHOTOFILTER` | Photo Filter adjustment layer |1065| `LayerKind.EXPOSURE` | Exposure adjustment layer |1066| `LayerKind.VIBRANCE` | Vibrance adjustment layer |1067| `LayerKind.COLORLOOKUP` | Color Lookup adjustment layer |1068| `LayerKind.LAYER3D` | 3D layer (not generally useful in Photopea) |1069| `LayerKind.VIDEO` | Video layer |10701071```js1072// Identify layer type1073var layer = doc.activeLayer;1074if (layer.kind === LayerKind.TEXT) /* text layer */;1075if (layer.kind === LayerKind.SMARTOBJECT) /* smart object */;1076if (layer.typename === "LayerSet") /* group */;10771078// Filter: collect all text layers recursively1079var textLayers = [];1080function collectText(parent) {1081 for (var i = 0; i < parent.layers.length; i++) {1082 var l = parent.layers[i];1083 if (l.typename === "LayerSet") collectText(l);1084 else if (l.kind === LayerKind.TEXT) textLayers.push(l);1085 }1086}1087collectText(doc);1088```10891090---10911092## `AnchorPosition` Enum10931094| Constant | Position |1095|----------|----------|1096| `AnchorPosition.TOPLEFT` | Top left |1097| `AnchorPosition.TOPCENTER` | Top center |1098| `AnchorPosition.TOPRIGHT` | Top right |1099| `AnchorPosition.MIDDLELEFT` | Middle left |1100| `AnchorPosition.MIDDLECENTER` | Center |1101| `AnchorPosition.MIDDLERIGHT` | Middle right |1102| `AnchorPosition.BOTTOMLEFT` | Bottom left |1103| `AnchorPosition.BOTTOMCENTER` | Bottom center |1104| `AnchorPosition.BOTTOMRIGHT` | Bottom right |11051106---11071108## `ElementPlacement` Enum11091110Used with `layer.move(relativeObject, placement)`:11111112| Constant | Effect |1113|----------|--------|1114| `ElementPlacement.PLACEBEFORE` | Above the target layer in the panel |1115| `ElementPlacement.PLACEAFTER` | Below the target layer in the panel |1116| `ElementPlacement.PLACEATBEGINNING` | Top of the layer stack |1117| `ElementPlacement.PLACEATEND` | Bottom of the layer stack |1118| `ElementPlacement.INSIDE` | Into a LayerSet (makes layer a child) |11191120---11211122## `ResampleMethod` Enum11231124Used with `doc.resizeImage()`:11251126| Constant | Description |1127|----------|-------------|1128| `ResampleMethod.BICUBIC` | High quality, good for smooth gradients |1129| `ResampleMethod.BICUBICSHARPER` | Best for reduction |1130| `ResampleMethod.BICUBICSMOOTHER` | Best for enlargement |1131| `ResampleMethod.BILINEAR` | Medium quality |1132| `ResampleMethod.NEARESTNEIGHBOR` | No anti-aliasing, fastest |1133| `ResampleMethod.NONE` | No resampling (change resolution only) |11341135---11361137## `SaveOptions` Enum11381139Used with `doc.close(saveOption)`:11401141| Constant | Meaning |1142|----------|---------|1143| `SaveOptions.DONOTSAVECHANGES` | Discard all changes and close |1144| `SaveOptions.SAVECHANGES` | Save then close |1145| `SaveOptions.PROMPTTOSAVECHANGES` | Show dialog (may block in headless) |11461147---11481149## `ExportOptionsSaveForWeb` — Export to Filesystem11501151Used with `doc.exportDocument()` to write files that Photopea packages into a ZIP.11521153```js1154// Export PNG1155var pngOpts = new ExportOptionsSaveForWeb();1156pngOpts.format = SaveDocumentType.PNG;1157pngOpts.PNG8 = false; // PNG-241158pngOpts.quality = 100;1159pngOpts.transparency = true;1160doc.exportDocument(new File("/export.png"), ExportType.SAVEFORWEB, pngOpts);11611162// Export JPEG1163var jpgOpts = new ExportOptionsSaveForWeb();1164jpgOpts.format = SaveDocumentType.JPEG;1165jpgOpts.quality = 80; // 0–1001166doc.exportDocument(new File("/export.jpg"), ExportType.SAVEFORWEB, jpgOpts);11671168// Export GIF1169var gifOpts = new ExportOptionsSaveForWeb();1170gifOpts.format = SaveDocumentType.GIF;1171gifOpts.colors = 256;1172gifOpts.dither = 100;1173gifOpts.transparency = true;1174doc.exportDocument(new File("/export.gif"), ExportType.SAVEFORWEB, gifOpts);1175```11761177---11781179## `executeAction` — Advanced Operations11801181Used for operations not exposed in the standard DOM (adjustments applied as adjustment layers,1182Smart Object editing, etc.). Takes the Photoshop Action Manager approach.11831184```js1185// Open Smart Object for editing1186var l = doc.layers.getByName("SmartObj");1187doc.activeLayer = l;1188executeAction(stringIDToTypeID("placedLayerEditContents"));1189// Smart Object is now the active document1190doc.activeLayer.rotate(90);1191doc.save();1192doc.close();11931194// Apply Hue/Saturation as destructive adjustment1195var desc = new ActionDescriptor();1196var list = new ActionList();1197var channel = new ActionDescriptor();1198channel.putEnumerated(stringIDToTypeID("presetKind"), stringIDToTypeID("presetKindType"), stringIDToTypeID("presetKindDefault"));1199channel.putInteger(stringIDToTypeID("hue"), 20); // hue shift1200channel.putInteger(stringIDToTypeID("saturation"), 30); // saturation1201channel.putInteger(stringIDToTypeID("lightness"), 0);1202list.putObject(stringIDToTypeID("hueSaturationAdjustmentV2Layer"), channel);1203desc.putList(stringIDToTypeID("adjustment"), list);1204executeAction(stringIDToTypeID("hueSaturation"), desc, DialogModes.NO);12051206// Select a layer by name using AM1207function selectLayerByName(name) {1208 var desc = new ActionDescriptor();1209 var ref = new ActionReference();1210 ref.putName(charIDToTypeID("Lyr "), name);1211 desc.putReference(charIDToTypeID("null"), ref);1212 desc.putBoolean(charIDToTypeID("MkVs"), false);1213 executeAction(charIDToTypeID("slct"), desc, DialogModes.NO);1214}1215```12161217---12181219## Complete Practical Script Examples12201221### 1. Rename all text layers based on their contents1222```js1223app.preferences.rulerUnits = Units.PIXELS;1224var doc = app.activeDocument;12251226function processLayers(parent) {1227 for (var i = 0; i < parent.layers.length; i++) {1228 var l = parent.layers[i];1229 if (l.typename === "LayerSet") processLayers(l);1230 else if (l.kind === LayerKind.TEXT) {1231 l.name = l.textItem.contents.substring(0, 30);1232 }1233 }1234}1235processLayers(doc);1236app.echoToOE("done");1237```12381239### 2. Export each layer as a separate PNG1240```js1241app.preferences.rulerUnits = Units.PIXELS;1242var doc = app.activeDocument;12431244for (var i = 0; i < doc.layers.length; i++) {1245 // Hide all layers1246 for (var j = 0; j < doc.layers.length; j++) doc.layers[j].visible = false;1247 // Show only this layer1248 doc.layers[i].visible = true;1249 // Export1250 var opts = new ExportOptionsSaveForWeb();1251 opts.format = SaveDocumentType.PNG;1252 opts.PNG8 = false;1253 opts.quality = 100;1254 doc.exportDocument(1255 new File("/" + doc.layers[i].name + ".png"),1256 ExportType.SAVEFORWEB, opts1257 );1258}12591260// Restore visibility1261for (var i = 0; i < doc.layers.length; i++) doc.layers[i].visible = true;1262```12631264### 3. Find and replace text across all text layers1265```js1266var searchText = "2024";1267var replaceText = "2025";12681269function findReplaceText(parent) {1270 for (var i = 0; i < parent.layers.length; i++) {1271 var l = parent.layers[i];1272 if (l.typename === "LayerSet") findReplaceText(l);1273 else if (l.kind === LayerKind.TEXT) {1274 var t = l.textItem;1275 if (t.contents.indexOf(searchText) !== -1) {1276 t.contents = t.contents.split(searchText).join(replaceText);1277 }1278 }1279 }1280}1281findReplaceText(app.activeDocument);1282app.echoToOE("Find & Replace complete");1283```12841285### 4. Grid of duplicate layers1286```js1287app.preferences.rulerUnits = Units.PIXELS;1288var doc = app.activeDocument;1289var layer = doc.activeLayer;1290var cols = 4, rows = 3;1291var padX = 20, padY = 20;1292var w = layer.bounds[2] - layer.bounds[0];1293var h = layer.bounds[3] - layer.bounds[1];12941295for (var r = 0; r < rows; r++) {1296 for (var c = 0; c < cols; c++) {1297 if (r === 0 && c === 0) continue; // skip original1298 var copy = layer.duplicate();1299 var targetX = layer.bounds[0] + c * (w + padX);1300 var targetY = layer.bounds[1] + r * (h + padY);1301 copy.translate(targetX - copy.bounds[0], targetY - copy.bounds[1]);1302 copy.opacity = 100 - (r * cols + c) * 5;1303 }1304}1305```13061307### 5. Apply watermark from URL1308```js1309app.preferences.rulerUnits = Units.PIXELS;1310var doc = app.activeDocument;13111312// Open watermark as smart object layer1313app.open("https://example.com/watermark.png", null, true);1314var wm = doc.activeLayer;13151316// Resize to 20% of document width1317var wmW = wm.bounds[2] - wm.bounds[0];1318var targetW = doc.width * 0.2;1319var scalePct = (targetW / wmW) * 100;1320wm.resize(scalePct, scalePct, AnchorPosition.TOPLEFT);13211322// Move to bottom-right with 20px margin1323var wmNewW = wm.bounds[2] - wm.bounds[0];1324var wmNewH = wm.bounds[3] - wm.bounds[1];1325wm.translate(1326 doc.width - wmNewW - 20 - wm.bounds[0],1327 doc.height - wmNewH - 20 - wm.bounds[1]1328);1329wm.opacity = 60;1330app.echoToOE("watermark applied");1331```13321333### 6. Get all layer info as JSON1334```js1335function getLayerInfo(parent, depth) {1336 depth = depth || 0;1337 var result = [];1338 for (var i = 0; i < parent.layers.length; i++) {1339 var l = parent.layers[i];1340 var info = {1341 name: l.name,1342 type: l.typename,1343 visible: l.visible,1344 opacity: l.opacity,1345 depth: depth1346 };1347 if (l.typename === "ArtLayer") {1348 info.kind = l.kind.toString();1349 info.bounds = [l.bounds[0], l.bounds[1], l.bounds[2], l.bounds[3]];1350 if (l.kind === LayerKind.TEXT) {1351 info.text = l.textItem.contents;1352 info.font = l.textItem.font;1353 info.size = l.textItem.size;1354 }1355 } else if (l.typename === "LayerSet") {1356 info.children = getLayerInfo(l, depth + 1);1357 }1358 result.push(info);1359 }1360 return result;1361}1362app.echoToOE(JSON.stringify(getLayerInfo(app.activeDocument)));1363```13641365---13661367## Common Mistakes & Gotchas13681369| Problem | Cause | Fix |1370|---------|-------|-----|1371| `createEmbed` never resolves | Container has no size | Add `width` + `height` CSS to the container `<div>` |1372| `runScript` returns `["done"]` with no data | No `echoToOE` in script | Add `app.echoToOE(value)` for anything you want back |1373| `result[0]` is `"done"`, not the expected value | `echoToOE` not reached | Check script logic for early exit or errors |1374| Images won't load (network error) | CORS | Server must respond with `Access-Control-Allow-Origin: *` |1375| `openFromURL(url, true)` layer not ready | Async loading lag | Use `addImageAndWait` utility |1376| `exportImage` only PNG/JPG | `exportImage` limitation | Use `runScript("saveToOE('webp:0.85')")` for other formats |1377| Pixel coordinates behave unexpectedly | Wrong ruler units | Always set `app.preferences.rulerUnits = Units.PIXELS` first |1378| Text `size` set but looks different | Wrong type units | Set `app.preferences.typeUnits = TypeUnits.PIXELS` |1379| Layer not found by name | Wrong layer level | Layers are scoped; use recursive search for nested layers |1380| `layer.bounds[0]` returns a UnitValue, not number | Ruler units issue | Force `Units.PIXELS` before reading bounds |1381| Smart Object edit hangs | Missing `doc.save(); doc.close()` | Always save + close when done editing SO |1382| React double-mount in dev | Strict Mode | Use `if (peaRef.current) return` guard in `useEffect` |13831384---13851386## Limitations13871388- This skill covers host-page integration patterns; it does not replace Photopea's own terms, API documentation, or licensing guidance.1389- Remote URL loading depends on browser CORS behavior, network availability, and the user's Photopea account/session state.1390- `runScript` executes scripts inside the embedded Photopea document context. Only run scripts you understand and only with user-approved files.1391- Serialize dynamic values with `JSON.stringify` before embedding them in a `runScript` string. Never concatenate user-provided URLs, layer names, or text directly into Photopea script source.1392- Export behavior can vary by document size, browser memory limits, and the formats supported by the active Photopea runtime.13931394---13951396## Sources13971398- photopea.js: https://github.com/yikuansun/PhotopeaAPI1399- npm: https://www.npmjs.com/package/photopea1400- Photopea Live Messaging API: https://www.photopea.com/api/live1401- Photopea Script reference: https://www.photopea.com/learn/scripts1402- Photoshop JS Scripting reference (compatible): https://theiviaxx.github.io/photoshop-docs/Photoshop/index.html1403- Plugin dev gists (addImageAndWait, getDocumentAsImage): https://gist.github.com/yikuansun/c0f1a602b4e9d4e344a41c4f49ded3bf14041405---14061407**Source:** [`sickn33/agentic-awesome-skills`](https://github.com/sickn33/agentic-awesome-skills) → `skills/photopea-embedded-editor/SKILL.md`14081409**Also appears in:** `sickn33/agentic-awesome-skills/plugins/agentic-awesome-skills/skills/photopea-embedded-editor/SKILL.md`, `sickn33/agentic-awesome-skills/plugins/agentic-awesome-skills-claude/skills/photopea-embedded-editor/SKILL.md`