Update README.md

This commit is contained in:
Cris Charles authored and GitHub committed 2026-04-09 02:08:48 +08:00
1 parent a00d189a65
commit 77878f33d3
1 file changed
+37 -4
+37 -4
View File
@@ -1,7 +1,40 @@
// Commands: # Crop White Backgrounds from Photos
`python crop_white_background.py --folder photo` This Python script automatically crops white (or near-white) backgrounds from scanned or photographed images. It handles scanner dust and tiny specks by using a density-based approach, ensuring only the real photo content is kept.
or All cropped images are saved into a **`cropped`** folder inside the input folder.
`python crop_white_background.py photo\*.jpg` ---
## Features
- Crop white/near-white backgrounds from scanned photos.
- Ignores scanner dust and tiny specks.
- Supports batch processing using folders or glob patterns.
- Saves all outputs in a `cropped` folder automatically.
- Adjustable `threshold`, `padding`, and `min-density` parameters.
---
## Requirements
- Python 3.8+
- [Pillow](https://pypi.org/project/Pillow/) ≥ 9.0.0
- [NumPy](https://pypi.org/project/numpy/) ≥ 1.22.0
Install dependencies via pip:
```bash
pip install -r requirements.txt
# Crop a single image
python crop_white_background.py photo/image1.jpg
# Crop a single image with custom parameters
python crop_white_background.py photo/image1.jpg --threshold 220 --padding 20 --min-density 30
# Crop all JPEG images in a folder using glob pattern
python crop_white_background.py photo/*.jpg
# Crop all images in a folder using --folder
python crop_white_background.py --folder photo/