Execute custom JavaScript in Photopea to automate advanced image editing tasks beyond standard tools. Access full Photopea DOM for direct manipulation of documents, layers, and more.
Retrieve available font PostScript names in Photopea for use with add_text and edit_text commands. Filter fonts by name using an optional search string.
Remove the current selection in your Photopea document to clear marching ants after completing selection-based operations like fills or adjustments. Leaves pixel data unchanged.
Retrieve active document metadata including name, width, height, resolution (DPI), layer count, and color mode. Use to verify document dimensions before positioning layers or making selections.
Add a non-destructive solid color fill layer covering the entire canvas. This adjustment-style layer can be toggled, recolored, or deleted without affecting other layers. Adjust its opacity or blend mode using set_layer_properties.
Retrieve the complete layer hierarchy of the active document as JSON, including layer names, types, and indices for use in subsequent editing operations.
Open an existing image file in Photopea for editing. Supports PSD, PNG, JPG, WebP, SVG, and other common formats. The opened file becomes the active document.
Applies a solid color fill to the active selection on the current layer. Requires an existing selection — create one with make_selection. Supports custom hex color, opacity, and blend mode. Modifies pixel data directly.
Group multiple layers into a layer folder by specifying layer names. Use with get_layers to find names, and ungroup_layers to reverse. Organize your layers panel efficiently.
Update layer properties such as opacity, blend mode, visibility, name, or locked state. Only specified properties are changed; others remain unchanged. First inspect current values with get_layers, then modify only what you need.
Start a new design project by creating a blank document with custom width, height, resolution, color mode, and background fill. Use this as the first step for image editing or graphic design workflows.
Add a new empty layer to the active document, making it active. Use this before drawing operations such as fill selection or add gradient to isolate edits on a separate layer.
Add a text layer to the active document at a given position. Configure font, size, color, alignment, bold, italic, letter spacing, line height. Specify paragraphBounds to create a text box with word wrapping.
Move a layer by relative x/y offset in pixels. Specify target layer by name or index, and provide horizontal (positive right) and vertical (positive down) offsets to reposition from current location.
Load custom fonts from a URL into Photopea to use in text layers. Supports TTF, OTF, and WOFF2. After loading, use list_fonts to get the font name for add_text or edit_text.
Place an image from a URL or local file into the active document. Creates a new layer; optionally set position (x, y) and resize (width, height) while preserving aspect ratio.
Modify the content or style of an existing text layer in Photopea. Specify only properties to change; omit others to keep current values. Use get_layers to find layer names.