imager / README.md
devskale
readme
4068228
|
raw
history blame
3.83 kB
---
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