Edit images with precision using ImageMagick 7, sips, transparent-background, and Pillow — with intelligent routing to AI semantic editing (Gemini/nano-banana-pro) for content-aware operations. Covers cropping, resizing, compositing, annotating, format conversion, color adjustment, background removal, batch processing, and montage creation. Triggers on image editing, crop, resize, composite, annotate, remove background, format conversion.
Edit images with precision using ImageMagick 7, sips, transparent-background, and Pillow — with intelligent routing to AI semantic editing (Gemini/nano-banana-pro) for content-aware operations. Covers cropping, resizing, compositing, annotating, format conversion, color adjustment, background removal, batch processing, and montage creation. Triggers on image editing, crop, resize, composite, annotate, remove background, format conversion.
Image Forge
Pixel-precise image editing with three-tier routing: deterministic CLI tools for exact operations, AI models for semantic edits, vision models for analysis.
Routing Decision
Use AI when the edit requires understanding what is in the image. Use ImageMagick when the edit requires knowing exactly what to do to the pixels.
Delegate to the nano-banana-pro skill when the edit requires understanding image content:
Remove a person/object from a photo
Change sky, weather, time of day
Apply artistic style transfer
Inpaint/outpaint regions
Generate new image from scratch
Content-aware fill after object removal
Nano Banana regenerates, it does not edit. Every call re-rolls the entire frame, even when the prompt asks to preserve regions verbatim. Expect ~40% of pixels to drift outside the target area — measured empirically, not hypothesized. For surgical regional edits (change the face, keep everything else identical), use the hybrid pattern in references/compositing.md § Surgical Regional Edits: let NB produce a drifted reference, then composite only the target region onto the pristine original with a feathered alpha mask.
Nano Banana also supports only discrete aspect ratios (1:1, 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, 21:9). For inputs at other ratios (e.g. 3:1 panoramics), see references/recipes.md § Aspect Ratio Padding for the pad-generate-crop recipe.
Tier 3: Vision Analysis (Claude Read tool)
Use the Read tool to inspect images before/after edits:
Verify an edit succeeded
Describe image contents
Check composition and framing
Identify colors, objects, text in image
Background Removal
Use transparent-background (InSPyReNet model) for AI background removal. It produces clean alpha mattes with smooth anti-aliased edges — far superior to ImageMagick's -transparent/-fuzz approach, which leaves white fringing in concave regions and jagged edges.
When to use each:
Method
When
Quality
transparent-background
Any photo/render with complex foreground (hair, translucent edges, concave regions)
Smooth alpha, no fringing
magick -transparent white -fuzz N%
Simple shapes on pure white, quick-and-dirty
Fast but aliased edges, misses interior white
magick floodfill
Remove background from corners only, preserve interior white
Only hits connected regions
Python API (recommended):
from transparent_background import Remover
from PIL import Image
remover = Remover()
img = Image.open("input.jpg").convert("RGB")
out = remover.process(img, type="rgba")
out.save("output.png")
Always +repage after -crop — Virtual canvas offset persists without it
-modulate order is B,S,H — Brightness, Saturation, Hue (not H,S,L)
Settings persist, operators execute immediately — Order matters in magick commands
Use rembg for background removal — rembg i input.jpg output.png (add -a for alpha matting)
Quote geometry — >, <, ^ are shell metacharacters
-alpha off is permanent in IM7 — Use -alpha deactivate/-alpha activate for temporary toggle
Inspect before editing — Run image_info.py first to know dimensions, format, alpha state
Pipeline for multi-step — Use image_pipeline.py instead of chaining shell commands
Nano Banana drifts the whole frame — Never trust NB to leave regions unchanged. For regional edits, use the surgical composite pattern (see compositing.md § Surgical Regional Edits). Verify with magick compare -metric AE -fuzz 5% before after diff.png — low AE means clean, ~40%+ means full regeneration.
References
Detailed references in ~/.claude/skills/image-forge/references/: