Spaces:
Sleeping
Sleeping
A newer version of the Gradio SDK is available:
6.9.0
metadata
title: Image Cutter
emoji: ๐
colorFrom: green
colorTo: blue
sdk: gradio
sdk_version: 6.2.0
app_file: app.py
pinned: false
โ๏ธ Image Grid Cutter
Blog: www.airabbit.blog
A powerful Gradio-based tool to split images into customizable grids, crop individual tiles, and generate animated GIFs.
๐ฏ Features
1. Grid Cutting
- Upload any image and split it into a customizable grid (up to 16ร16 = 256 tiles)
- Live preview with grid lines overlaid on the image
- Adjustable rows and columns with real-time updates
- Download all tiles as a ZIP file
2. Individual Tile Cropping
- Navigate through tiles with Previous/Next buttons
- Jump to first or last tile instantly
- Crop each tile individually using an interactive crop tool
- Background options: Choose transparent or custom color fill for cropped areas
- Apply a single crop uniformly to all tiles
- Download edited tiles as ZIP
3. GIF / MP4 Animation
- Generate animated GIFs from your tiles
- Export MP4 videos with the same animation styles, plus optional transitions
- Animation styles:
- Reveal (build up): Tiles appear one by one, building the complete image
- Cycle (one at a time): Each tile appears alone in sequence
- Flash (all tiles): Each tile shown centered, one after another
- Shuffle (random order): Tiles revealed in random order
- Single tile mode: Create a slideshow of individual tiles
- Adjustable frame duration (50ms - 1000ms)
- Transparent or custom color backgrounds
๐ Getting Started
Prerequisites
- Python 3.8+
- pip
Installation
Clone the repository:
git clone https://github.com/yourusername/image-grid-cutter.git cd image-grid-cutterCreate a virtual environment (recommended):
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activateInstall dependencies:
pip install -r requirements.txtRun the app:
python app.pyOpen your browser: Navigate to
http://127.0.0.1:7860
Docker
docker build -t image-cutter .
docker run --rm -p 7860:7860 image-cutter
๐ How It Works
Step 1: Cut Your Image
- Go to the "1. Cut" tab
- Upload an image (drag & drop, paste, or click to upload)
- Adjust the Rows and Columns sliders to define your grid
- The preview updates in real-time showing grid lines
- Click "โ๏ธ Cut Image" to split the image
- Download all tiles as a ZIP file
Step 2: Crop Tiles (Optional)
- Go to the "2. Crop (Optional)" tab
- Choose your background fill: Transparent or a custom color
- Use โ โถ arrows or โฎ First / Last โญ buttons to navigate tiles
- Use the crop tool in the editor to crop the current tile
- Click "๐พ Save This Tile" to save individual crops
- Or click "โ Apply to All" to apply the same crop to every tile
- Download the edited tiles as ZIP
Step 3: Generate Animation
- Go to the "3. Export" tab
- Select an animation style from the dropdown
- Enable "Single tile per frame" for slideshow mode
- Adjust the frame duration in milliseconds
- Click "๐ฌ Generate GIF" or "๐ฅ Generate MP4"
- Download your animated GIF or MP4 video
๐จ Use Cases
- Sprite sheets: Extract individual sprites from game assets
- Puzzle creation: Split images into puzzle pieces
- Social media grids: Create Instagram grid posts
- Animation frames: Generate frame-by-frame animations
- Image analysis: Divide images for detailed inspection
- Collage preparation: Prepare tiles for collage projects
๐ ๏ธ Technical Details
Dependencies
| Package | Version | Purpose |
|---|---|---|
| Gradio | โฅ6.0.0 | Web UI framework |
| Pillow | โฅ10.0.0 | Image processing |
| NumPy | โฅ1.24.0 | Numerical operations |
File Structure
image-grid-cutter/
โโโ app.py # Main Gradio application
โโโ requirements.txt # Python dependencies
โโโ README.md # This file
โโโ LICENSE # Apache 2.0 license
โโโ .gitignore # Git ignore rules
Key Functions
split_image_into_grid()- Divides image into equal-sized tilescreate_grid_preview()- Generates preview with grid overlayprocess_image()- Main cutting logic with ZIP creationgenerate_gif_from_tile_list()- Creates animated GIFs from tilessave_single_tile()- Handles individual tile cropping with background options
๐ License
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
๐ค Contributing
Contributions are welcome! Feel free to:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
๐ฌ Contact
- Blog: www.airabbit.blog
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference