Image Process
When to Use
Use this skill when the user already has local image files and needs deterministic post-processing:
- Resize, crop, thumbnail, rotate, convert format, compress, set quality, or strip EXIF.
- Normalize a batch of images for web, social, app, marketplace, or document delivery.
- Produce non-destructive output files while preserving originals.
Do not use this skill for semantic AI edits such as "remove this person", "make the subject prettier", "change the background to a beach", or "generate a new image". Those require image design/editing or an AI image tool.
Workflow
- Confirm inputs:
- exact file paths or glob range.
- target operation, dimensions, output format, output directory, and whether metadata should be stripped.
- Protect originals:
- default to writing into an output directory or adding a suffix.
- do not overwrite originals unless the user explicitly confirms overwrite.
- For batches:
- list or count matched files before processing.
- confirm if the operation is destructive, lossy, or large-scale.
- Process in a stable order:
- auto-orient from EXIF, crop/fit, resize, convert, strip metadata, save quality.
- Verify outputs:
- path, dimensions, format, file size, and failures.
Script
Use scripts/image_process.py when Python and Pillow are available.
Examples:
python scripts/image_process.py --input cover.png --output-dir out --width 1080 --format webp --quality 85 --strip-exif
python scripts/image_process.py --input "images/*.png" --output-dir out --width 1080 --height 1080 --fit cover --format jpg --quality 90
Install dependency if needed:
python -m pip install Pillow
Do not install dependencies without user approval in restricted or shared environments.
Return Format
Return:
{
"ok": true,
"outputs": [
{
"path": "output.webp",
"dimensions": "1080x1080",
"format": "WEBP",
"file_size": 123456,
"operations": ["resize", "convert", "strip_exif"]
}
],
"failed": []
}
For failures, return the failed files and cause.
Dependencies
- Python 3.
- Pillow for image processing.
- Local read/write permissions.
- Optional HEIC/HEIF support may require extra libraries.
Limits and Known Issues
- This skill does not perform AI semantic edits.
- Format conversion can be lossy.
- EXIF stripping removes metadata such as camera, date, and GPS fields.
- Cropping with
covermay remove image edges. - Large batches should be previewed before execution.
Examples
User: "把 generated 目录下的 png 都转成 1080 宽的 webp,质量 85,去掉 EXIF。"
Handling: count matching files, confirm output directory, run the script with width, format, quality, and strip-exif, then return output paths and any failures.