| name | imagemagick |
| description | Use this skill for image processing with ImageMagick — resize, crop, convert format, add watermark/text, composite, annotate, adjust colors, create thumbnails, batch process, make montages/collages, merge images into a strip, and manipulate PNG/JPG/GIF/WebP/SVG images. Note that PDF/PS/EPS processing is disabled by sandbox policy. Triggers on 'merge images into one', 'combine images side by side', 'create image strip', 'image grid', 'resize image', 'crop image', 'convert png to jpg', 'add watermark', 'make thumbnail', 'image collage', 'montage', 'batch convert images', 'compress image', 'rotate image', 'overlay images', 'annotate image', 'adjust brightness', 'imagemagick'. |
ImageMagick Skill for Computer-Use Agents
Process static images with ImageMagick (magick / identify). This skill adds agent-specific safety rules and decision logic on top of ImageMagick knowledge the model already has.
For additional recipes (compositing, montages, batch processing, color adjustments, and more), see references/recipes.md.
Safety Policy
No-overwrite default
Do not overwrite input files. Always write to a new output path unless the user explicitly requests in-place modification.
Verify output
After processing, verify the output exists and has reasonable dimensions:
magick identify -format "%f %wx%h %m %b\n" "$OUTPUT"
Other rules
- Quote all file paths.
- Do not delete the input file unless the user explicitly requests it.
- Only use local file paths. Do not pass user-supplied URLs directly to ImageMagick.
- Clean up temp files after successful operations.
- Use
-limit memory 256MiB -limit disk 512MiB for large batch operations to prevent OOM in shared environments.
Sandbox policy
The sandbox has an ImageMagick policy that restricts resource usage and disables risky coders (PS, EPS, PDF via Ghostscript). If a command fails with a policy error, do not try to bypass it -- inform the user.
Inspect First
Always check image properties before complex operations:
magick identify "$INPUT"
magick identify -verbose "$INPUT" | head -30
magick identify -format "%wx%h" "$INPUT"
magick identify -format "%m %wx%h %b" "$INPUT"
Command Syntax
ImageMagick 7 uses the magick command. Common subcommands:
magick "$INPUT" [operations] "$OUTPUT"
magick identify "$INPUT"
magick composite overlay.png base.png out.png
magick montage *.jpg -geometry +2+2 out.png
Key rule: input comes first, operations in the middle, output last.
Core Recipes
1. Inspect image
magick identify -format "%f %wx%h %m %[colorspace] %b\n" "$INPUT"
2. Merge Images Into a Horizontal Strip
Use this when the user says "merge images", "combine images side by side", "create image strip", "make one long image", or "put images next to each other". This means arranging images in a single horizontal row -- not overlaying or blending them.
magick montage image1.jpg image2.jpg image3.jpg \
-resize x2048 \
-geometry +20+0 \
-tile x1 \
-background none \
"$OUTPUT"
-resize x2048: normalize all images to the same height (adjust as needed)
-geometry +20+0: 20px horizontal gap between images, no vertical gap
-tile x1: single row (x1 = 1 row, unlimited columns)
-background none: transparent gaps (use white or black if output is JPG)
For vertical strips, use -tile 1x instead of -tile x1.
3. Resize
magick "$INPUT" -resize 800x600 "$OUTPUT"
magick "$INPUT" -resize 800x "$OUTPUT"
magick "$INPUT" -resize x600 "$OUTPUT"
magick "$INPUT" -resize 800x600! "$OUTPUT"
magick "$INPUT" -resize 800x600\> "$OUTPUT"
4. Crop
magick "$INPUT" -crop 400x300+0+0 +repage "$OUTPUT"
magick "$INPUT" -gravity center -crop "%[fx:min(w,h)]x%[fx:min(w,h)]+0+0" +repage "$OUTPUT"
magick "$INPUT" -trim +repage "$OUTPUT"
Always use +repage after crop to reset the virtual canvas.
5. Convert format
magick "$INPUT" "$OUTPUT.jpg"
magick "$INPUT" "$OUTPUT.png"
magick "$INPUT" "$OUTPUT.webp"
magick "$INPUT" -quality 85 "$OUTPUT.jpg"
| Format | Quality range | Notes |
|---|
| JPEG | 1-100 (default 92) | Lossy; 85 is good balance |
| PNG | 0-9 compression level | Lossless; higher = smaller + slower |
| WebP | 1-100 | Lossy by default; -define webp:lossless=true for lossless |
6. Add text / watermark
magick "$INPUT" \
-gravity south -pointsize 36 -fill white \
-annotate +0+20 "Sample Text" \
"$OUTPUT"
magick "$INPUT" \
-gravity center -pointsize 72 -fill "rgba(255,255,255,0.3)" \
-annotate +0+0 "DRAFT" \
"$OUTPUT"
For user-supplied text with special characters, write text to a temp file using printf '%s' (not echo with double quotes) and use @filename:
_tmpfile="$(mktemp)"
printf '%s' 'User supplied text here' > "$_tmpfile"
magick "$INPUT" -gravity south -pointsize 36 -fill white \
-annotate +0+20 "@$_tmpfile" "$OUTPUT"
rm -f "$_tmpfile"
7. Composite / overlay
magick "$INPUT" "$LOGO" \
-gravity northeast -geometry +10+10 \
-composite "$OUTPUT"
magick "$INPUT" \( "$OVERLAY" -alpha set -channel A -evaluate set 50% \) \
-gravity center -composite "$OUTPUT"
8. Thumbnail
magick "$INPUT" -thumbnail 200x200 "$OUTPUT"
magick "$INPUT" -thumbnail 200x200^ -gravity center -extent 200x200 "$OUTPUT"
-thumbnail strips metadata and is faster than -resize for preview generation.
Common Failure Modes
| Error | Fix |
|---|
not authorized / policy error | Sandbox policy blocks this coder (e.g. PDF/PS). Inform user. |
| Output is 0 bytes | Check input exists; check format compatibility |
| Crop produces wrong region | Add +repage after -crop |
| Text renders as boxes | Font not available; use -list font to find available fonts |
| Colors look wrong after convert | Add -colorspace sRGB before output |
| Image too large, OOM | Add -limit memory 256MiB -limit disk 512MiB |
| Transparency lost in JPG output | JPG doesn't support alpha; use PNG/WebP or -background white -flatten |
Special chars break -annotate | Write text to a file, use @filename |
Command Construction Checklist
- What is the input path? Inspect it if unknown.
- What is the output path and format?
- Does the operation change dimensions? Use
-resize or -crop.
- Does the operation change format? Specify output extension.
- Is there a crop? Add
+repage.
- Is there text overlay? Escape special characters or use
@file.
- Is the output JPG? Handle transparency with
-flatten.
- Large batch? Add resource limits.
- Verify output with
magick identify.
Agent Behavior Rules
- Before constructing any command, identify: source format/dimensions, desired output format/dimensions, and quality requirements.
- Inspect with
magick identify if image properties are unknown.
- Choose the simplest applicable command.
- Never overwrite the input file unless explicitly asked.
- Quote every path.
- Use
@filename for user-supplied text to avoid shell injection in -annotate.
- Add
+repage after any -crop operation.
- When converting to JPG, flatten transparency first.
- Verify output with
magick identify.
- If ImageMagick fails, read the error and adjust -- do not retry the same command.
- If a policy error occurs, do not attempt to bypass it.
- For compositing, montages, batch processing, and advanced operations, read
references/recipes.md.
References