$npx -y skills add Bria-AI/bria-skill --skill image-utilsClassic image manipulation with Python Pillow - resize, crop, composite, format conversion, watermarks, brightness/contrast adjustments, and web optimization. Use this skill when post-processing AI-generated images, preparing images for web delivery, batch processing image direct
| 1 | # Image Utilities |
| 2 | |
| 3 | Pillow-based utilities for deterministic pixel-level image operations. Use for resize, crop, composite, format conversion, watermarks, and other standard image processing tasks. |
| 4 | |
| 5 | ## When to Use This Skill |
| 6 | |
| 7 | - **Post-processing AI-generated images**: Resize, crop, optimize for web after generation |
| 8 | - **Format conversion**: PNG ↔ JPEG ↔ WEBP with quality control |
| 9 | - **Compositing**: Overlay images, paste subjects onto backgrounds |
| 10 | - **Batch processing**: Resize to multiple sizes, add watermarks |
| 11 | - **Web optimization**: Compress and resize for fast delivery |
| 12 | - **Social media preparation**: Crop to platform-specific aspect ratios |
| 13 | |
| 14 | ## When NOT to Use This Skill — Use `bria-ai` Instead |
| 15 | |
| 16 | This skill handles **deterministic pixel-level operations** only. For any **generative or AI-powered** image work, use the `bria-ai` skill instead: |
| 17 | |
| 18 | - **Generating images from text prompts** → use `bria-ai` |
| 19 | - **AI background removal or replacement** → use `bria-ai` |
| 20 | - **AI image editing (inpainting, object removal/addition)** → use `bria-ai` |
| 21 | - **Style transfer or AI-driven visual effects** → use `bria-ai` |
| 22 | - **Creating product lifestyle shots with AI** → use `bria-ai` |
| 23 | - **Image upscaling with AI super-resolution** → use `bria-ai` |
| 24 | |
| 25 | **Rule of thumb**: If the task requires *creating new visual content* or *understanding image semantics*, use `bria-ai`. If the task requires *transforming existing pixels* (resize, crop, format convert, watermark), use this skill. |
| 26 | |
| 27 | If `bria-ai` is not available, install it with: |
| 28 | ```bash |
| 29 | npx skills add bria-ai/bria-skill |
| 30 | ``` |
| 31 | |
| 32 | ## Quick Reference |
| 33 | |
| 34 | | Operation | Method | Description | |
| 35 | |-----------|--------|-------------| |
| 36 | | **Loading** | `load(source)` | Load from URL, path, bytes, or base64 | |
| 37 | | | `load_from_url(url)` | Download image from URL | |
| 38 | | **Saving** | `save(image, path)` | Save with format auto-detection | |
| 39 | | | `to_bytes(image, format)` | Convert to bytes | |
| 40 | | | `to_base64(image, format)` | Convert to base64 string | |
| 41 | | **Resizing** | `resize(image, width, height)` | Resize to exact dimensions | |
| 42 | | | `scale(image, factor)` | Scale by factor (0.5 = half) | |
| 43 | | | `thumbnail(image, size)` | Fit within size, maintain aspect | |
| 44 | | **Cropping** | `crop(image, left, top, right, bottom)` | Crop to region | |
| 45 | | | `crop_center(image, width, height)` | Crop from center | |
| 46 | | | `crop_to_aspect(image, ratio)` | Crop to aspect ratio | |
| 47 | | **Compositing** | `paste(bg, fg, position)` | Overlay at coordinates | |
| 48 | | | `composite(bg, fg, mask)` | Alpha composite | |
| 49 | | | `fit_to_canvas(image, w, h)` | Fit onto canvas size | |
| 50 | | **Borders** | `add_border(image, width, color)` | Add solid border | |
| 51 | | | `add_padding(image, padding)` | Add whitespace padding | |
| 52 | | **Transforms** | `rotate(image, angle)` | Rotate by degrees | |
| 53 | | | `flip_horizontal(image)` | Mirror horizontally | |
| 54 | | | `flip_vertical(image)` | Flip vertically | |
| 55 | | **Watermarks** | `add_text_watermark(image, text)` | Add text overlay | |
| 56 | | | `add_image_watermark(image, logo)` | Add logo watermark | |
| 57 | | **Adjustments** | `adjust_brightness(image, factor)` | Lighten/darken | |
| 58 | | | `adjust_contrast(image, factor)` | Adjust contrast | |
| 59 | | | `adjust_saturation(image, factor)` | Adjust color saturation | |
| 60 | | | `blur(image, radius)` | Apply Gaussian blur | |
| 61 | | **Web** | `optimize_for_web(image, max_size)` | Optimize for delivery | |
| 62 | | **Info** | `get_info(image)` | Get dimensions, format, mode | |
| 63 | |
| 64 | ## Requirements |
| 65 | |
| 66 | ```bash |
| 67 | pip install Pillow requests |
| 68 | ``` |
| 69 | |
| 70 | ## Basic Usage |
| 71 | |
| 72 | ```python |
| 73 | from image_utils import ImageUtils |
| 74 | |
| 75 | # Load from URL |
| 76 | image = ImageUtils.load_from_url("https://example.com/image.jpg") |
| 77 | |
| 78 | # Or load from various sources |
| 79 | image = ImageUtils.load("/path/to/image.png") # File path |
| 80 | image = ImageUtils.load(image_bytes) # Bytes |
| 81 | image = ImageUtils.load("data:image/png;base64,...") # Base64 |
| 82 | |
| 83 | # Resize and save |
| 84 | resized = ImageUtils.resize(image, width=800, height=600) |
| 85 | ImageUtils.save(resized, "output.webp", quality=90) |
| 86 | |
| 87 | # Get image info |
| 88 | info = ImageUtils.get_info(image) |
| 89 | print(f"{info['width']}x{info['height']} {info['mode']}") |
| 90 | ``` |
| 91 | |
| 92 | ## Resizing & Scaling |
| 93 | |
| 94 | ```python |
| 95 | # Resize to exact dimensions |
| 96 | resized = ImageUtils.resize(image, width=800, height=600) |
| 97 | |
| 98 | # Resize maintaining aspect ratio (fit within bounds) |
| 99 | fitted = ImageUtils.resize(image, width=800, height=600, maintain_aspect=True) |
| 100 | |
| 101 | # Resize by width only (height auto-calculated) |
| 102 | resized = ImageUtils.resize(image, width=800) |
| 103 | |
| 104 | # Scale by factor |
| 105 | half = ImageUtils.scale(image, 0.5 |