This Python script monitors the new/ folder for new image files, automatically processes them by removing backgrounds using AI, resizing to 512x512 pixels, and organizing the results.
- Real-time Monitoring: Continuously watches the
new/folder for new image files - Background Removal: Uses AI-powered background removal with rembg (with fallback)
- Automatic Resizing: Converts images to 512x512 pixel squares with proper centering
- File Organization: Moves processed images to
processed/and originals toold/ - Robust Processing: Falls back to original image if background removal fails
- Supported Formats: JPG, JPEG, PNG, BMP, TIFF, TIF, WEBP
- Clone or download this repository
- Create a virtual environment:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
- Install dependencies:
pip install -r requirements.txt
-
Ensure the following folders exist (they will be created automatically if missing):
new/- Place new images hereprocessed/- Processed stickers will be saved hereold/- Original images will be moved here after processing
-
Run the script:
python main.py
-
The script will run continuously. Add image files to the
new/folder and they will be automatically processed. -
To stop the script, press
Ctrl+C.
rembg- AI-powered background removalpillow- Image processingwatchdog- File system monitoringonnxruntime- Required by rembg for AI inference
If you encounter a ModuleNotFoundError for onnxruntime, try installing it separately:
pip install onnxruntimestikers/
├── main.py # Main script
├── requirements.txt # Python dependencies
├── README.md # This file
├── AGENTS.md # Development guidelines
├── .gitignore # Git ignore rules
├── new/ # Input folder (monitor this)
├── processed/ # Output folder (processed stickers)
└── old/ # Archive folder (original images)
This project is open source. Feel free to use and modify as needed.