Smart image processing - resize, compress, convert (auto-detects single file or batch)
From media-toolsnpx claudepluginhub leobrival/serum-plugin --plugin media-tools<file_or_folder> [options]/imageGenerate hero image using DALL-E 3 with brand-consistent visual style
/imageGenerate images using Gemini 3 Pro Image model. Spawns a lightweight agent to keep main context clean.
Smart image processing that automatically handles single files or batch operations.
$ARGUMENTS
This command automatically detects input type:
| Input | Behavior |
|---|---|
Single file (photo.jpg) | Process that file |
Directory (./photos/) | Process all images in directory |
Glob pattern (*.png) | Process matching files |
| Multiple files | Process each file |
Parse $ARGUMENTS to determine:
INPUT_TYPE = detect_type(input)
- "file" if input is a single image file
- "directory" if input is a folder path
- "glob" if input contains wildcards (*, ?)
- "multiple" if comma-separated or multiple paths
Single file:
files=("$input")
Directory:
files=($(find "$input" -maxdepth 1 -type f \( -iname "*.jpg" -o -iname "*.jpeg" -o -iname "*.png" -o -iname "*.gif" -o -iname "*.webp" -o -iname "*.tiff" -o -iname "*.avif" \)))
Glob pattern:
files=($input)
If more than 1 file, show preview and ask confirmation:
Found 24 images to process:
- photo1.jpg (2.4 MB)
- photo2.png (1.8 MB)
- ... and 22 more
Settings:
- Resolution: 1920 (original → 1920px width)
- Ratio: 16:9 (will crop to fit)
- Format: webp
- Quality: 85%
- Output: ./processed/
Proceed? [Yes/No]
If Resolution is "original": Keep original dimensions If Resolution is "custom": Ask user for width If Ratio is "original": Keep original aspect ratio
Calculate height from ratio:
16:9 → height = width × 9/16
9:16 → height = width × 16/9
3:2 → height = width × 2/3
1:1 → height = width
4:5 → height = width × 5/4
4:3 → height = width × 3/4
21:9 → height = width × 9/21
| Output Setting | Behavior |
|---|---|
same | Same directory, new extension |
subfolder | Create ./processed/ subdirectory |
custom | Ask user for path |
For each file, build and execute command:
With resize and crop:
magick "$input" \
-resize ${width}x${height}^ \
-gravity center \
-extent ${width}x${height} \
-quality $quality \
-strip \
"$output"
Compress only (original resolution and ratio):
magick "$input" \
-quality $quality \
-strip \
"$output"
Resize without crop (original ratio):
magick "$input" \
-resize ${width}x \
-quality $quality \
-strip \
"$output"
✓ Processed 24 images
Summary:
- Total input: 45.2 MB
- Total output: 12.8 MB
- Compression: 72% smaller
Output: ./processed/
/image photo.jpg --Resolution 1920 --Ratio 16:9 --Format webp
/image photo.jpg --Format webp --Quality 75
/image ./photos/ --Resolution 1280 --Format webp --Output subfolder
/image "*.png" --Format webp --Quality 85
/image ./uploads/ --Resolution 1280 --Ratio 4:5 --Format jpg
/image ./content/ --Resolution 1080 --Ratio 9:16 --Format jpg --Quality 90
| Use Case | Resolution | Ratio | Format | Quality |
|---|---|---|---|---|
| Web hero | 1920 | 16:9 | webp | 85 |
| Thumbnail | 640 | 16:9 | webp | 75 |
| Instagram post | 1280 | 1:1 | jpg | 85 |
| Instagram story | 1080 | 9:16 | jpg | 85 |
| Twitter/X | 1280 | 16:9 | jpg | 85 |
| 1920 | 1.91:1 | jpg | 85 | |
| OG image | 1200 | 1.91:1 | jpg | 85 |
| 4K wallpaper | 3840 | 16:9 | png | 95 |
magick command)brew install imagemagick