| name | imagemagick |
| description | Image manipulation and conversion using ImageMagick inside a secure Docker container |
| runtime | docker |
ImageMagick Skill
Powerful image manipulation and conversion using ImageMagick running inside a Docker container. Resize, crop, rotate, apply effects, convert formats, create thumbnails, add watermarks, and more - all without installing ImageMagick locally.
Overview
This skill provides access to ImageMagick's comprehensive image processing capabilities through a containerized runtime. All processing happens inside an isolated Docker container with resource limits and no network access, ensuring security while maintaining full ImageMagick functionality.
When to Use This Skill
Use this skill when you need to:
- Convert images between formats (JPEG, PNG, GIF, TIFF, WebP, PDF)
- Resize and scale images
- Create thumbnails with cropping
- Rotate, flip, and crop images
- Apply effects (blur, sharpen, sepia, grayscale)
- Add borders and frames
- Composite images (watermarks, overlays)
- Batch process multiple images
- Create image montages and collages
- Extract image metadata
- Generate PDFs from images
Prerequisites
Docker
ImageMagick runs inside a Docker container, so Docker must be installed:
brew install --cask docker
sudo apt-get update
sudo apt-get install docker.io
sudo systemctl start docker
sudo systemctl enable docker
Verify Docker Installation
docker --version
docker ps
Configuration
Add to your .skill-engine.toml:
[skills.imagemagick]
source = "docker:dpokidov/imagemagick:latest"
runtime = "docker"
description = "ImageMagick image processing"
[skills.imagemagick.docker]
image = "dpokidov/imagemagick:latest"
entrypoint = "magick"
volumes = ["${PWD}:/workdir"]
working_dir = "/workdir"
memory = "1g"
network = "none"
rm = true
Configuration Explained
- image:
dpokidov/imagemagick:latest - ImageMagick Docker image (~100MB)
- entrypoint:
magick - Runs ImageMagick 7.x command
- volumes:
${PWD}:/workdir - Mounts current directory as /workdir in container
- working_dir:
/workdir - Sets container working directory
- memory:
1g - Limits container to 1GB RAM
- network:
none - Disables network access (processes local files only)
- rm:
true - Automatically removes container after execution
Usage
ImageMagick skill uses pass-through syntax - all arguments after -- are passed directly to ImageMagick:
skill run imagemagick -- [imagemagick command] [arguments]
All file paths are relative to your current directory, which is mounted as /workdir in the container.
Common Operations
Format Conversion
skill run imagemagick -- convert input.png output.jpg
skill run imagemagick -- convert input.jpg output.png
skill run imagemagick -- convert input.jpg output.webp
skill run imagemagick -- convert input.png output.gif
skill run imagemagick -- convert input.jpg output.tiff
Resize & Scale
skill run imagemagick -- convert input.jpg -resize 800x600! output.jpg
skill run imagemagick -- convert input.jpg -resize 800x600 output.jpg
skill run imagemagick -- convert input.jpg -resize 800 output.jpg
skill run imagemagick -- convert input.jpg -resize x600 output.jpg
skill run imagemagick -- convert input.jpg -resize 50% output.jpg
skill run imagemagick -- convert input.jpg -resize 800x600\> output.jpg
skill run imagemagick -- convert input.jpg -resize 800x600\< output.jpg
Thumbnails
skill run imagemagick -- convert input.jpg -thumbnail 150x150 thumb.jpg
skill run imagemagick -- convert input.jpg -thumbnail 150x150^ -gravity center -extent 150x150 thumb.jpg
skill run imagemagick -- convert input.jpg -thumbnail 150x150 -quality 85 thumb.jpg
skill run imagemagick -- convert input.jpg -thumbnail 300x300 large.jpg -thumbnail 150x150 medium.jpg -thumbnail 75x75 small.jpg
Crop
skill run imagemagick -- convert input.jpg -crop 100x100+50+50 output.jpg
skill run imagemagick -- convert input.jpg -gravity center -crop 200x200+0+0 output.jpg
skill run imagemagick -- convert input.jpg -crop 400x300+100+50 output.jpg
skill run imagemagick -- convert input.jpg -crop 100x100+50+50 +repage output.jpg
Rotate & Flip
skill run imagemagick -- convert input.jpg -rotate 90 output.jpg
skill run imagemagick -- convert input.jpg -rotate 180 output.jpg
skill run imagemagick -- convert input.jpg -rotate 270 output.jpg
skill run imagemagick -- convert input.jpg -flop output.jpg
skill run imagemagick -- convert input.jpg -flip output.jpg
Color Effects
skill run imagemagick -- convert input.jpg -colorspace Gray output.jpg
skill run imagemagick -- convert input.jpg -sepia-tone 80% output.jpg
skill run imagemagick -- convert input.jpg -negate output.jpg
skill run imagemagick -- convert input.jpg -brightness-contrast 20x0 output.jpg
skill run imagemagick -- convert input.jpg -brightness-contrast 0x30 output.jpg
skill run imagemagick -- convert input.jpg -brightness-contrast 10x20 output.jpg
skill run imagemagick -- convert input.jpg -colorize 30,0,0 output.jpg
Image Effects
skill run imagemagick -- convert input.jpg -blur 0x8 output.jpg
skill run imagemagick -- convert input.jpg -gaussian-blur 0x5 output.jpg
skill run imagemagick -- convert input.jpg -sharpen 0x1 output.jpg
skill run imagemagick -- convert input.jpg -edge 1 output.jpg
skill run imagemagick -- convert input.jpg -emboss 2 output.jpg
skill run imagemagick -- convert input.jpg -charcoal 2 output.jpg
skill run imagemagick -- convert input.jpg -paint 4 output.jpg
skill run imagemagick -- convert input.jpg -sketch 0x20+120 output.jpg
Borders & Frames
skill run imagemagick -- convert input.jpg -border 10x10 -bordercolor black output.jpg
skill run imagemagick -- convert input.jpg -border 5x5 -bordercolor blue output.jpg
skill run imagemagick -- convert input.jpg -frame 10x10+5+5 output.jpg
skill run imagemagick -- convert input.jpg -alpha set -background none -vignette 0x0 output.png
Watermarks & Compositing
skill run imagemagick -- composite -gravity southeast watermark.png input.jpg output.jpg
skill run imagemagick -- composite -dissolve 30 -gravity southeast watermark.png input.jpg output.jpg
skill run imagemagick -- composite -gravity center watermark.png input.jpg output.jpg
skill run imagemagick -- composite -geometry +100+50 overlay.png input.jpg output.jpg
Text Annotation
skill run imagemagick -- convert input.jpg -pointsize 30 -fill white -annotate +10+40 "Sample Text" output.jpg
skill run imagemagick -- convert input.jpg -gravity south -background black -fill white -pointsize 20 -annotate +0+10 "Copyright 2024" output.jpg
skill run imagemagick -- convert input.jpg -gravity center -pointsize 50 -fill red -annotate +0+0 "DRAFT" output.jpg
Quality & Compression
skill run imagemagick -- convert input.jpg -quality 85 output.jpg
skill run imagemagick -- convert input.jpg -quality 95 output.jpg
skill run imagemagick -- convert input.jpg -quality 75 -strip output.jpg
skill run imagemagick -- convert input.jpg -strip output.jpg
skill run imagemagick -- convert input.png -quality 95 output.png
Batch Processing
for file in *.png; do
skill run imagemagick -- convert "$file" "${file%.png}.jpg"
done
for file in *.jpg; do
skill run imagemagick -- convert "$file" -resize 800x600 "resized_${file}"
done
for file in *.jpg; do
skill run imagemagick -- convert "$file" -thumbnail 150x150^ -gravity center -extent 150x150 "thumb_${file}"
done
for file in *.{jpg,gif,bmp}; do
skill run imagemagick -- convert "$file" "${file%.*}.png"
done
Image Montage
skill run imagemagick -- montage *.jpg -geometry +2+2 -tile 3x3 montage.jpg
skill run imagemagick -- montage *.jpg -geometry 200x200+5+5 -tile 4x output.jpg
skill run imagemagick -- montage *.jpg -label '%f' -geometry +2+2 labeled_montage.jpg
skill run imagemagick -- montage *.jpg -tile 5x -geometry 150x150+2+2 contact_sheet.jpg
PDF Operations
skill run imagemagick -- convert image1.jpg image2.jpg image3.jpg output.pdf
skill run imagemagick -- convert *.jpg document.pdf
skill run imagemagick -- convert input.pdf -quality 100 page-%03d.jpg
skill run imagemagick -- convert input.pdf[0] first_page.jpg
Image Information
skill run imagemagick -- identify input.jpg
skill run imagemagick -- identify -verbose input.jpg
skill run imagemagick -- identify -format "%m" input.jpg
skill run imagemagick -- identify -format "%wx%h" input.jpg
skill run imagemagick -- identify -format "%b" input.jpg
Advanced Examples
Create Image with Text
skill run imagemagick -- convert -size 800x600 xc:white -pointsize 50 -fill black -annotate +100+300 "Hello World" text_image.jpg
skill run imagemagick -- convert -size 800x600 gradient:blue-white -pointsize 60 -fill white -annotate +50+300 "Welcome" gradient_text.jpg
Batch Resize with Quality Control
for img in *.jpg; do
skill run imagemagick -- convert "$img" \
-resize 1200x1200\> \
-quality 85 \
-strip \
"web_${img}"
done
Create Polaroid Effect
skill run imagemagick -- convert input.jpg \
-bordercolor white -border 15 \
-bordercolor grey60 -border 1 \
-background none -rotate 6 \
-background white -flatten \
polaroid.jpg
Vignette Effect
skill run imagemagick -- convert input.jpg \
-background black \
-vignette 0x20 \
vignette.jpg
Picture Frame
skill run imagemagick -- convert input.jpg \
-mattecolor white -frame 20x20+10+10 \
-mattecolor black -frame 3x3+0+0 \
framed.jpg
File Paths
Working with Files
All file paths are relative to your current directory:
cd /path/to/images
skill run imagemagick -- convert photo.jpg result.png
skill run imagemagick -- convert input/photo.jpg output/result.png
cd /path/to/images
skill run imagemagick -- convert photo.jpg result.png
skill run imagemagick -- convert /path/to/images/photo.jpg result.png
Container Path Mapping
- Host:
$PWD/photo.jpg → Container: /workdir/photo.jpg
- Host:
$PWD/images/photo.jpg → Container: /workdir/images/photo.jpg
Supported Formats
Input Formats
JPEG, PNG, GIF, TIFF, BMP, WebP, SVG, PDF, PSD, ICO, RAW (many variants)
Output Formats
JPEG, PNG, GIF, TIFF, BMP, WebP, PDF, ICO, and more
Special Formats
- xc:color - Create solid color image (e.g.,
xc:white, xc:#FF0000)
- gradient:color1-color2 - Create gradient
- pattern:name - Built-in patterns
Security Features
Resource Limits
- Memory: 1GB limit prevents excessive RAM usage
- Network: Disabled - no outbound connections
- Filesystem: Only current directory mounted (read/write)
Container Isolation
- Runs in isolated container namespace
- No access to host system files outside mounted directory
- Container auto-removed after execution
- No persistent container state
Performance Tips
-
Use appropriate quality settings:
- Web:
-quality 75-85
- Print:
-quality 90-95
- Archive:
-quality 95-100
-
Strip metadata for smaller files:
skill run imagemagick -- convert input.jpg -strip output.jpg
-
Batch process efficiently:
skill run imagemagick -- mogrify -resize 800x600 -quality 85 *.jpg
-
Use correct format for the use case:
- Photos: JPEG
- Graphics/logos: PNG
- Animations: GIF
- Web: WebP (smaller than JPEG/PNG)
Troubleshooting
Docker Not Running
docker ps
open /Applications/Docker.app
sudo systemctl start docker
Out of Memory
If processing large images, increase memory limit in .skill-engine.toml:
[skills.imagemagick.docker]
memory = "2g"
File Not Found
Ensure you're in the correct directory:
pwd
ls -la
cd /path/to/images
skill run imagemagick -- convert photo.jpg result.png
Permission Errors
ls -la photo.jpg
chmod 644 photo.jpg
Image Quality Issues
skill run imagemagick -- convert input.jpg -quality 95 output.jpg
Common Errors
| Error | Cause | Solution |
|---|
| "No such file" | Wrong directory or path | Use pwd and ls to verify location |
| "Permission denied" | File permissions | chmod 644 filename |
| "Memory allocation failed" | Out of memory | Increase memory limit in config |
| "Cannot connect to Docker" | Docker not running | Start Docker Desktop/service |
| "Unable to open image" | Corrupted or unsupported file | Check file format with identify |
ImageMagick Commands Reference
Main Commands
- convert - Convert image format or apply operations
- identify - Get image information
- mogrify - Modify image in-place (overwrites original)
- composite - Overlay images
- montage - Create image grid/collage
- compare - Compare two images
Usage Examples
skill run imagemagick -- convert input.jpg -resize 800x600 output.jpg
skill run imagemagick -- mogrify -resize 800x600 image.jpg
skill run imagemagick -- composite watermark.png input.jpg output.jpg
Docker Image Details
- Image:
dpokidov/imagemagick:latest
- Base: Alpine Linux
- Size: ~100MB
- ImageMagick Version: 7.x
- Platforms: linux/amd64, linux/arm64
Resources
Quick Reference
Essential Operations Table
| Operation | Command |
|---|
| Convert format | convert input.png output.jpg |
| Resize | convert input.jpg -resize 800x600 output.jpg |
| Thumbnail | convert input.jpg -thumbnail 150x150^ -gravity center -extent 150x150 thumb.jpg |
| Rotate | convert input.jpg -rotate 90 output.jpg |
| Crop | convert input.jpg -crop 100x100+10+10 output.jpg |
| Grayscale | convert input.jpg -colorspace Gray output.jpg |
| Blur | convert input.jpg -blur 0x8 output.jpg |
| Sharpen | convert input.jpg -sharpen 0x1 output.jpg |
| Border | convert input.jpg -border 5x5 -bordercolor black output.jpg |
| Watermark | composite -gravity southeast watermark.png input.jpg output.jpg |
| Get info | identify input.jpg |
| To PDF | convert *.jpg output.pdf |