File size: 3,833 Bytes
06d9c6f 8f8047a 2bb9242 06d9c6f 4068228 d87a006 4068228 d87a006 4068228 d87a006 4068228 d87a006 4068228 d87a006 4068228 d87a006 4068228 d87a006 4068228 d87a006 4068228 d87a006 4068228 d87a006 4068228 d87a006 4068228 d87a006 4068228 d87a006 4068228 d87a006 4068228 d87a006 4068228 d87a006 4068228 d87a006 4068228 d87a006 4068228 d87a006 4068228 d87a006 4068228 d87a006 4068228 d87a006 4068228 d87a006 4068228 d87a006 4068228 d87a006 4068228 d87a006 4068228 d87a006 4068228 d87a006 4068228 d87a006 4068228 d87a006 4068228 06d9c6f 4068228 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
---
title: Imager
emoji: π
colorFrom: yellow
colorTo: pink
sdk: gradio
sdk_version: 5.1.0
app_file: gradio_imager.py
pinned: false
license: apache-2.0
---
# IMAGER - Advanced Image Processing Tool πΌοΈ
IMAGER is a versatile image processing toolkit that offers both a CLI interface for bulk processing and a user-friendly Gradio web interface. It supports various image manipulation features including background removal, resizing, cropping, and background color adjustment.
## Features π
- **Background Removal**: Automatically remove image backgrounds using the `rembg` library
- **Smart Cropping**: Autocrop images based on content
- **Flexible Resizing**: Resize images while maintaining aspect ratio
- **Padding Control**: Add customizable padding around images
- **Background Customization**: Set custom background colors or use color names
- **Preset Settings**: Choose from predefined configurations (S/M/L, light/dark themes)
- **Dual Interface**: Use either CLI for batch processing or Gradio web interface for single images
## Installation π§
```bash
# Install required packages
pip install Pillow rembg onnxruntime gradio
```
## CLI Usage (imager.py) π»
Perfect for bulk processing images. Place images in the `./input` directory and run:
```bash
python imager.py -b -c -r 800x600 -p 10
```
### Command-Line Arguments
- `-b, --background_removal`: Enable background removal
- `-c, --crop`: Enable autocropping
- `-r, --resize AxB`: Resize to AxB pixels (maintains aspect ratio)
- `-p, --padding PIXELS`: Add padding around the image
- `-bg, --background BACKGROUND`: Add background (color name, hex code, or image path)
### CLI Example
```bash
# Process images with background removal, crop, and resize to 320x280
python imager.py -b -c -r 320x280 -p 10
# Add a green background
python imager.py -b -c -r 320x280 -p 10 -bg green
```
## Gradio Web Interface (gradio_imager.py) π
For processing single images with real-time preview:
```bash
python gradio_imager.py
```
### Web Interface Features
1. Upload an image or use example images
2. Choose from preset settings or customize:
- Enable/disable cropping
- Toggle background removal
- Set custom dimensions (e.g., "480x480")
- Adjust padding (0-200 pixels)
- Choose background color
### Standard Settings βοΈ
- **Light Theme**: S (240x240), M (480x480), L (960x960)
- **Dark Theme**: Same sizes with dark background (#2A373D)
## Background Color Palettes π¨
### Grayscale Monochrome
| Color Name | Hex Code |
|----------------|----------|
| Light Gray | #D1D1D3 |
| Lavender Gray | #C6C6C7 |
| Silver Foil | #AFAFB0 |
| Quick Silver | #A4A4A5 |
| Spanish Gray | #999999 |
### Feminine Soft Neutrals
| Color Name | Hex Code |
|---------------|----------|
| Alabaster | #F4EEE1 |
| Dark Vanilla | #C4BDAC |
| Dust Storm | #EBCFC4 |
| Pale Silver | #D3C4BE |
| Desert Sand | #E9CCB1 |
### Neutral Brown
| Color Name | Hex Code |
|-----------------|----------|
| CafΓ© Noir | #4E3829 |
| Coffee | #6B513E |
| Beaver | #8E7766 |
| Khaki | #B09C8D |
| Champagne Pink | #E6D7CE |
## Code Structure π
- `imager.py`: CLI interface for batch processing
- `gradio_imager.py`: Gradio web interface
- `image_processor.py`: Core image processing functions
- `/data/examples/`: Example images for testing
## Technical Stack π οΈ
- `Gradio` for web interface
- `PIL` for image processing
- `rembg` for background removal
- `onnxruntime` for ML operations
## Contributing π€
Contributions are welcome! Feel free to fork the repository and submit pull requests.
## License π
This project is open-source and available under the MIT License.
---
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference |