ワンクリックで
image-files
Image manipulation using ImageMagick command-line tools for resizing, converting, optimizing, and batch processing
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
Image manipulation using ImageMagick command-line tools for resizing, converting, optimizing, and batch processing
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
Rust development patterns for video processing, trait abstractions, error handling, and Linux device interaction
C# static analysis tool for call graphs, unused code detection, impact analysis, HTML documentation generation, and Graphviz diagram export
RDBMS access patterns for DuckDB, MySQL (keycloak), PostgreSQL (dw, x3rocs), SQL Server (sage1000, x3), and DBISAM (Exportmaster) using ODBC and native drivers
Elasticsearch 5.2 operations using HTTP API - searching, indexing, bulk operations, scroll API, and alias management
| name | Image Files |
| description | Image manipulation using ImageMagick command-line tools for resizing, converting, optimizing, and batch processing |
When helping users work with image files, follow these guidelines:
Tool Availability: ImageMagick is installed and available on the system path. Use magick command (modern syntax) or legacy commands (convert, identify, mogrify)
If it is not on the path look in C:\Program Files\ImageMagick-7.1.2-Q16-HDRI
Modern vs Legacy Syntax:
magick convert input.jpg output.pngconvert input.jpg output.pngCommon Operations:
-resize with geometry (e.g., 800x600, 50%, 800x).jpg to .png)-quality for JPEG compression (1-100)-strip to remove EXIF datamogrify for in-place edits or shell loops for batch conversionsPreserve Aspect Ratio: Use geometry without ! suffix (e.g., 800x600 not 800x600!)
Output Paths: Always specify full output path to avoid overwriting originals
Format Support: Common formats include JPG, PNG, GIF, BMP, TIFF, WebP, PDF
Error Handling: Check file exists before processing, verify output was created
Performance: For batch operations, process files in parallel if system has multiple cores
User: Resize this image to 800px wide, maintaining aspect ratio
Claude: I'll use ImageMagick to resize the image:
- Preserve aspect ratio with 800x geometry
- Keep original format
- Save to new filename to preserve original
magick convert input.jpg -resize 800x output.jpg
User: Convert all PNG files to JPEG and reduce file size
Claude: I'll batch convert PNG to JPEG with optimization:
- Strip metadata with -strip
- Set quality to 85 (good balance)
- Process all PNG files in directory
for file in *.png; do magick convert "$file" -strip -quality 85 "${file%.png}.jpg"; done
User: Create thumbnails for all images in a folder
Claude: I'll generate thumbnails:
- Resize to 200x200 (constrained, maintain aspect)
- Save with _thumb suffix
- Preserve format
for img in *.jpg; do magick convert "$img" -resize 200x200 "thumbs/${img%.jpg}_thumb.jpg"; done
User: What are the dimensions of this image?
Claude: I'll use identify to get image details:
magick identify input.jpg
# or: identify input.jpg
Common ImageMagick operations and patterns.
Maintain Aspect Ratio:
# Resize to width of 800px (height auto)
magick convert input.jpg -resize 800x output.jpg
# Resize to height of 600px (width auto)
magick convert input.jpg -resize x600 output.jpg
# Resize to fit within 800x600 box
magick convert input.jpg -resize 800x600 output.jpg
# Resize to 50% of original
magick convert input.jpg -resize 50% output.jpg
Force Exact Dimensions (distorts if needed):
magick convert input.jpg -resize 800x600! output.jpg
Resize and Crop to Exact Dimensions:
# Crop to center after resize
magick convert input.jpg -resize 800x600^ -gravity center -extent 800x600 output.jpg
# JPG to PNG
magick convert input.jpg output.png
# PNG to JPG with quality
magick convert input.png -quality 90 output.jpg
# Multiple formats
magick convert input.tiff output.jpg output.png
# PDF to images (one per page)
magick convert document.pdf page-%03d.jpg
JPEG Optimization:
# Reduce quality (85 is good balance)
magick convert input.jpg -quality 85 output.jpg
# Strip metadata and optimize
magick convert input.jpg -strip -quality 85 output.jpg
# Progressive JPEG
magick convert input.jpg -interlace Plane -quality 85 output.jpg
PNG Optimization:
# Basic PNG optimization
magick convert input.png -strip output.png
# Reduce PNG colors (for smaller file)
magick convert input.png -colors 256 output.png
# Crop to specific region (width x height + x_offset + y_offset)
magick convert input.jpg -crop 800x600+100+50 output.jpg
# Auto-trim whitespace
magick convert input.jpg -trim output.jpg
# Add border
magick convert input.jpg -border 10x10 -bordercolor white output.jpg
# Basic info (format, dimensions, size)
magick identify input.jpg
# Verbose info (all metadata)
magick identify -verbose input.jpg
# Just dimensions
magick identify -format "%wx%h" input.jpg
Using mogrify (in-place modification):
# DANGEROUS: Overwrites originals!
magick mogrify -resize 800x *.jpg
# Safer: Output to different directory
mkdir resized
magick mogrify -path resized -resize 800x *.jpg
Using loop (safer):
# Bash loop for batch resize
mkdir output
for img in *.jpg; do
magick convert "$img" -resize 800x "output/$img"
done
# PowerShell loop
mkdir output
Get-ChildItem *.jpg | ForEach-Object {
magick convert $_.Name -resize 800x "output/$($_.Name)"
}
# Convert all PNG to JPG
for file in *.png; do
magick convert "$file" -quality 90 "${file%.png}.jpg"
done
# Convert all to WebP
for file in *.jpg; do
magick convert "$file" -quality 90 "${file%.jpg}.webp"
done
# Optimize all JPEGs in place (with backup)
mkdir originals
for img in *.jpg; do
cp "$img" "originals/$img"
magick convert "$img" -strip -quality 85 "$img"
done
# Process files in parallel (requires GNU parallel)
ls *.jpg | parallel magick convert {} -resize 800x output/{}
# Or using xargs (Unix/Linux)
ls *.jpg | xargs -P 4 -I {} magick convert {} -resize 800x output/{}
# Add text watermark
magick convert input.jpg \
-gravity southeast \
-pointsize 24 \
-fill white \
-annotate +10+10 'Copyright 2025' \
output.jpg
# Add image watermark
magick convert input.jpg watermark.png \
-gravity southeast \
-geometry +10+10 \
-composite \
output.jpg
# Combine images horizontally
magick convert img1.jpg img2.jpg +append output.jpg
# Combine images vertically
magick convert img1.jpg img2.jpg -append output.jpg
# Create montage/grid
magick montage *.jpg -tile 3x3 -geometry +5+5 grid.jpg
# Convert to grayscale
magick convert input.jpg -colorspace Gray output.jpg
# Blur
magick convert input.jpg -blur 0x8 output.jpg
# Sharpen
magick convert input.jpg -sharpen 0x1 output.jpg
# Rotate
magick convert input.jpg -rotate 90 output.jpg
# Flip/Flop
magick convert input.jpg -flip output.jpg # vertical flip
magick convert input.jpg -flop output.jpg # horizontal flip
# Sepia tone
magick convert input.jpg -sepia-tone 80% output.jpg
# Remove white background (make transparent)
magick convert input.jpg -fuzz 10% -transparent white output.png
# Replace background color
magick convert input.jpg -fuzz 10% -fill blue -opaque white output.jpg
# Add _thumb suffix
for img in *.jpg; do
magick convert "$img" -resize 200x200 "${img%.jpg}_thumb.jpg"
done
# Add thumb_ prefix
for img in *.jpg; do
magick convert "$img" -resize 200x200 "thumb_$img"
done
# Recursively process images, maintaining directory structure
find . -name "*.jpg" -type f | while read file; do
dir=$(dirname "$file")
name=$(basename "$file")
mkdir -p "output/$dir"
magick convert "$file" -resize 800x "output/$dir/$name"
done
# Generate multiple quality versions
for quality in 95 85 75 60; do
magick convert input.jpg -quality $quality "output_q${quality}.jpg"
done
# Create common responsive sizes
for width in 320 640 768 1024 1920; do
magick convert input.jpg -resize ${width}x "responsive/image_${width}w.jpg"
done
if [ -f "input.jpg" ]; then
magick convert input.jpg -resize 800x output.jpg
else
echo "Error: input.jpg not found"
fi
magick convert input.jpg -resize 800x output.jpg
if [ -f "output.jpg" ]; then
echo "Success: output.jpg created"
else
echo "Error: conversion failed"
fi
# Always quote variables
for img in *.jpg; do
magick convert "$img" -resize 800x "output/$img"
done
# Quality (1-100, default 92)
-quality 85
# Sampling factor (4:2:0 for smaller files)
-sampling-factor 4:2:0
# Progressive
-interlace Plane
# Strip metadata
-strip
# Compression level (0-9, higher = smaller but slower)
-quality 95 # PNG quality is compression level
# Bit depth
-depth 8
# Remove alpha channel
-alpha off
# WebP quality
-quality 90
# Lossless WebP
-define webp:lossless=true
# Optimize for web: resize, strip metadata, optimize quality
magick convert input.jpg \
-resize 1920x \
-strip \
-quality 85 \
-sampling-factor 4:2:0 \
-interlace Plane \
output.jpg
# PNG screenshots to optimized JPEG
for png in *.png; do
magick convert "$png" -strip -quality 90 "${png%.png}.jpg"
done
# Facebook/Twitter cover (1200x630)
magick convert input.jpg \
-resize 1200x630^ \
-gravity center \
-extent 1200x630 \
social_cover.jpg
# Instagram square (1080x1080)
magick convert input.jpg \
-resize 1080x1080^ \
-gravity center \
-extent 1080x1080 \
instagram.jpg
# Check if installed
magick --version
convert --version
# Windows: Check PATH environment variable
# Linux: sudo apt-get install imagemagick
# macOS: brew install imagemagick
# Check file permissions
ls -l input.jpg
# Make readable
chmod 644 input.jpg
# Limit memory usage
magick convert input.jpg -limit memory 1GB -resize 800x output.jpg
# Process in smaller batches
# Edit ImageMagick policy.xml
# Location: /etc/ImageMagick-7/policy.xml
# Remove or comment out restrictive policies for PDF, PS, etc.
magick convert - Convert and modify imagesmagick identify - Display image informationmagick mogrify - Modify images in placemagick montage - Create composite imagesmagick compare - Compare two imagesconvert - Same as magick convertidentify - Same as magick identifymogrify - Same as magick mogrifymontage - Same as magick montagecompare - Same as magick comparemagick convert) for future compatibility