Overview
Call meitu image-cutout to separate the foreground subject from the image and output a transparent-background PNG. Only the five subject types are supported: people, pets, products, icons, and seals; optional portrait, product, and graphic models, or omit the model parameter to auto-detect.
Dependencies
- meitu-cli:
npm install -g meitu-cli@latest - Credentials: prefer env vars
MEITU_OPENAPI_ACCESS_KEY/MEITU_OPENAPI_SECRET_KEY, or preset~/.meitu/credentials.json; execute this only when the user explicitly asks to write local credentials.meitu config set-ak --value "..."/meitu config set-sk --value "..."
Path alias: below in the text
$VISUAL={OPENCLAW_HOME}/workspace/visual/
Core Workflow
Preflight → [Context: 跳过(工具型抠图,无创意自由度)] → Execute → Deliver
Preflight
meitu --version→ if not installed, promptnpm install -g meitu-cli@latestmeitu auth verify --json→ if credentials are invalid, guide configuration- Detect mode: cwd has
openclaw.yaml→ project mode; else → one-off Check$VISUALdirectory → determine capabilities - output_dir resolution (MUST be completed within Preflight):
Resolve output_dir: openclaw.yaml →
./output/| else →$VISUAL/output/meitu-cutout/mkdir -p {output_dir}
Execute
Input parsing
The user provides an image, supporting two forms:
- Local file path (e.g.,
./photo.jpg) - Image URL (e.g.,
https://example.com/photo.jpg)
If the user only says "help me cut out the image" but does not provide an image → ask: "Please provide the image to cut out (local path or URL)."
Model selection
| Image subject | model_type |
Output |
|---|---|---|
| Portraits, ID photos, half-body photos | 0 |
Transparent-background PNG, preserving hair detail |
| Products, merchandise, e-commerce images | 1 |
Transparent-background PNG, optimizing product edges |
| Design assets, icons, seals | 2 |
Transparent-background PNG |
| Pets or uncertain type | Omit | The server automatically selects the model and outputs a transparent-background PNG |
model_type Only allowed 0、1、2. Non-five-category subjects such as architecture, plants, vehicles, food, and furniture, as well as white-background isolation, are not supported, and the restriction must not be bypassed via prompts or alternative APIs; when a white background needs to be generated, switch to image-edit。
Tool invocation
Single image cutout:
meitu image-cutout --image_url {image_url_or_path} --json --download-dir {output_dir} --skill_name skill_meitu-cutout
When a model is explicitly specified, append --model_type 0、--model_type 1 or --model_type 2; when omitted, automatically select the type.
Batch processing
Batch process an entire directory:
meitu batch image-cutout --input-dir {input_dir} --output-dir {output_dir} --skill_name skill_meitu-cutout
When the entire batch shares a fixed model, append --model-type 0、--model-type 1 or --model-type 2. When specifying item by item, use a JSON/YAML configuration; the item field modelType(compatible with model_type) maps to the single-command model_type. Batch processing default concurrency is 3, output .png。
Note: A single command does not support --image_list; input parameters only accept --image_url(alias --image)。
Result check
Parse --json output:
ok: true→ success,downloaded_files[0].saved_pathis the locally downloaded result PNG (transparent background); if not used--download-dir, then takemedia_urls[0]ok: false→ checkcodeandhint
Error fallback
| Level | Action | Description |
|---|---|---|
| L1 | Adjust model selection | When auto-detection is inaccurate, switch to --model_type 0、1 or 2 |
| L2 | Check image format/size | Ensure the image is accessible and not corrupted |
| L3 | Stop and report an error | After 2 consecutive failures, output code + hint |
If it is not one of the five subject types or white-background isolation, return unsupported directly; do not call or retry.
Special errors:
ORDER_REQUIRED→ Prompt the user to top up, displayaction_urlCREDENTIALS_MISSING→ Prompt to configure AK/SK
Deliver
Directly use the output_dir parsed by Preflight.
mv {file} {output_dir}/{date}_{name}_cutout.png
Output
- Format: PNG (transparent background)
- Naming:
{YYYY-MM-DD}_{descriptive-name}_cutout.png- Example:
2026-03-23_product-photo_cutout.png
- Example:
- Location: Determined by the Deliver step (project →
./output/, one-time →$VISUAL/output/meitu-cutout/)