Image Manipulation with ImageMagick
This skill enables image processing and manipulation tasks using ImageMagick across Windows, Linux, and macOS systems.
When to Use This Skill
Use this skill when you need to:
- Resize images (single or batch)
- Get image dimensions and metadata
- Convert between image formats
- Create thumbnails
- Process wallpapers for different screen sizes
- Batch process multiple images with specific criteria
Prerequisites
- ImageMagick installed on the system
- Windows: PowerShell with ImageMagick available as
magick(or atC:\Program Files\ImageMagick-*\magick.exe) - Linux/macOS: Bash with ImageMagick installed via package manager (
apt,brew, etc.)
Core Capabilities
1. Image Information
- Get image dimensions (width x height)
- Retrieve detailed metadata (format, color space, etc.)
- Identify image format
2. Image Resizing
- Resize single images
- Batch resize multiple images
- Create thumbnails with specific dimensions
- Maintain aspect ratios
3. Batch Processing
- Process images based on dimensions
- Filter and process specific file types
- Apply transformations to multiple files
Operating Workflow
- Resolve
magickbefore using it- PowerShell: store the executable in
$magickand invoke with& $magick - Bash: require
command -v magickbefore processing
- PowerShell: store the executable in
- Inspect first: use
magick identify -format "%wx%h" "path/to/image.jpg"for dimensions ormagick identify -verbose "path/to/image.jpg"for full metadata - Transform with quoted paths and explicit outputs:
- Resize:
magick "input.jpg" -resize 427x240 "output.jpg" - Thumbnail:
magick "$img" -resize 427x240 "thumbnails/thumb_$filename" - Exact resize only when intended:
-resize 427x240! - Minimum-fill resize only when intended:
-resize 427x240^
- Resize:
- Batch with platform-native loops:
- PowerShell:
Get-ChildItem "path/to/images/*" | ForEach-Object { ... } - Bash:
for img in path/to/images/*; do ...; done
- PowerShell:
- Filter by dimensions when processing only matching source images:
- PowerShell:
$dimensions = & $magick identify -format "%w,%h" $_.FullName - Bash:
dimensions=$(magick identify -format "%w,%h" "$img")
- PowerShell:
Detailed command examples and reusable snippets live in references/command-examples.md.
Required follow-up reads
| Need | Read | When |
|---|---|---|
| Platform-specific commands and batch loops | references/command-examples.md |
Building PowerShell or Bash operations |
Safety Constraints
- Always quote file paths that may contain spaces
- Do not overwrite originals by accident: write to an output directory or distinct filename unless the user explicitly requests in-place edits
- Use PowerShell call syntax: invoke a stored executable path with
& $magick - Verify dimensions before expensive or conditional batch work to avoid unnecessary processing
- Choose resize semantics deliberately: plain
WxHpreserves aspect ratio within the box,WxH!distorts to exact dimensions, andWxH^fills at least the target dimensions - Expect memory pressure on large batches; process files iteratively and avoid loading unrelated images
Validation Guidance
- Confirm ImageMagick is available before generating commands
- Run
identifyon representative input before and after transformations when dimensions, format, color space, or metadata matter - For batch commands, validate on one file first, then apply the same command shape in the loop
- Check output files exist and dimensions match the requested behavior
- On older Linux systems with ImageMagick 6.x,
convertmay be needed instead ofmagick; prefermagickwhen available
Limitations
- Large batch operations may be memory-intensive
- Some complex operations may require additional ImageMagick delegates
- On older Linux systems, use
convertinstead ofmagick(ImageMagick 6.x vs 7.x)