Skip to main content
Glama

ps_layer_mask

Destructive

Create, delete, apply, or draw gradients on layer masks. Use with a selection to mask content to a frame, or fade edges with a linear gradient.

Instructions

Manage the active layer's mask — choose with op. create: add a layer mask; if a selection is active it reveals the selection and hides the rest (the one-call "mask the placed image to the frame opening" — make the selection first, then create); with no selection, a reveal-all mask; adjustment layers load the current selection into their built-in mask. delete: remove the mask (layer pixels preserved). apply: DESTRUCTIVE — permanently bake the mask into the pixels (outside-mask pixels lost). gradient: draw a linear fade into the mask (fade_to names the side that ends hidden; start/end place the fade; auto-creates the mask; replaces existing mask content and clears any active selection first) — the standard fade for reflections, sky blends, and soft edge falloff. Verify with ps_get_preview. Prefer keeping masks non-destructive unless flattening for export. Don't write Mk Chnl At=Msk or Grdn AM scripts in execute_script — this tool already does both.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
opYescreate: add a layer mask on the active layer (if a selection is active it reveals the selection — the "mask to the frame opening" answer; adjustment layers load the selection into their built-in mask). delete: remove the mask (layer pixels preserved). apply: DESTRUCTIVE — bake the mask into pixels (pixels outside the mask are lost). gradient: draw a linear white→black fade INTO the mask (auto-creates a reveal-all mask if none) — the universal fade-out primitive (reflections, sky blends, edge feathering). REPLACES existing mask content.
endNoop=gradient: 0-1 fraction where the fade completes — fully hidden from here on. Must be greater than start.
startNoop=gradient: 0-1 fraction along the fade direction where the fade begins — the layer stays fully visible up to here.
extentNoop=gradient: measure start/end over the active layer's pixel bounds (default) or the whole canvas. A layer with no pixel bounds falls back to canvas.layer
fade_toNoop=gradient: the side that ends fully HIDDEN (mask black). The opposite side stays fully visible. E.g. a water reflection fades with fade_to=bottom.bottom

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
toNoop=gradient: fully-hidden end of the drawn fade, doc pixels.
fromNoop=gradient: fully-visible end of the drawn fade, doc pixels.
extentNoop=gradient: 'layer' or 'canvas' — reports the extent actually used.
contextNo
fade_toNo
layer_nameNo
bounds_usedNo
maskAppliedNo
maskCreatedNo
maskDeletedNo
created_maskNoop=gradient: true when the reveal-all mask had to be created first.
hadSelectionNo
mask_gradientNo
activeLayerKindNo
modifiedExistingMaskNo
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations provide destructiveHint: true, and the description goes further by detailing side effects: apply is DESTRUCTIVE and permanently bakes the mask with outside pixels lost; gradient replaces existing mask content and clears any active selection first; delete preserves layer pixels. This adds behavioral context beyond the annotation and is consistent with it.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is dense but well-organized, starting with a summary line and then breaking out each `op` with relevant details and a strong closing note about avoiding manual AM scripts. Every sentence serves a purpose, and the structure aids quick comprehension without unnecessary fluff.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (4 operations, 5 parameters), the description is remarkably complete. It covers all operations, side effects, prerequisites (selection needed for create), the relationship to preview verification, and best-practice guidance. The presence of an output schema means return values don't need explanation, so nothing is missing.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Even though schema coverage is 100%, the description adds meaningful context beyond field names and types. It explains the semantics of `op` operations (e.g., 'create' reveals selection, adjustment layers load selection into built-in mask), and for gradient it clarifies that the tool auto-creates the mask, replaces existing content, and clears the active selection—details not fully captured in schema descriptions.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: managing the active layer's mask via the `op` parameter, with specific sub-operations (create, delete, apply, gradient). It distinguishes itself from sibling tools by focusing on masks and explicitly cross-references ps_get_preview and execute_script, making its role unambiguous.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Provides rich usage guidance: when to use each op (e.g., gradient for reflections, sky blends, edge falloff), preference for non-destructive masks unless flattening for export, and an explicit warning not to write `Mk Chnl At=Msk` or `Grdn` scripts in execute_script because the tool already handles them. This clearly frames when to use the tool and when not to.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/editmamei/editmamei'

If you have feedback or need assistance with the MCP directory API, please join our Discord server