Image Processing
Use img-process (shipped in bin/) for common operations. For complex or custom workflows, generate a Pillow script adapted to the user's environment.
Quick Reference — img-process CLI
Use img-process when: the operation is standard (resize, convert, trim, thumbnail, optimise, OG card, batch). This is faster and avoids generating a script each time.
Generate a custom script when: the operation needs logic img-process doesn't cover (compositing multiple images, watermarks, complex text layouts, conditional processing).
Prerequisites
Pillow is required for both img-process and custom scripts:
If Pillow is unavailable, use alternatives:
Output Format Guide
Core Patterns
Save with Format-Specific Quality
Different formats need different save parameters. Always handle RGBA-to-JPG compositing — JPG does not support transparency, so composite onto a white background first.
Resize with Aspect Ratio
When only width or height is given, calculate the other from aspect ratio. Use Image.LANCZOS for high-quality downscaling.
Trim Whitespace (Auto-Crop)
Remove surrounding whitespace from logos and icons. Convert to RGBA first, then use getbbox() to find content bounds.
Thumbnail
Fit within max dimensions while maintaining aspect ratio:
Optimise for Web
Resize + compress in one step. Convert to WebP for best compression. Typical settings: width 1920, quality 85.
Cross-Platform Font Discovery
System font paths differ by OS. Try multiple paths, fall back to Pillow's default. On Linux, fc-list can discover fonts dynamically.
OG Card Generation (1200x630)
Composite text on a background image or solid colour. Apply semi-transparent overlay for text readability. Centre text horizontally.
Common Workflows
Logo Cleanup (client-supplied JPG with white background)
Prepare Hero Image for Production
Batch Process
Pipeline with Gemini Image Gen
Generate images with the gemini-image-gen skill, then process them:

