A Python CLI tool for common image processing operations including resizing, background removal, and vectorization.
- Pillow: Image manipulation
- rembg: Background removal
- opencv-python: Image processing and inpainting
- numpy: Numerical operations
- onnxruntime: AI model inference for advanced watermark removal
- Resize: Resize images to specific dimensions with optional aspect ratio preservation
- Remove Background: Automatically remove backgrounds from images
- Vectorize: Convert raster images to SVG vector format
- Auto-Crop: Automatically detect and remove blank borders from images
- Favicon: Generate multi-size favicon (.ico) files for websites
- Remove Watermark: Remove watermarks from the bottom-right corner using content-aware inpainting
- Clone this repository
- Install Python dependencies:
pip install -r requirements.txt- For vectorization, install potrace:
# Ubuntu/Debian
sudo apt-get install potrace
# macOS
brew install potracepython main.py resize input.jpg output.jpg --width 800 --height 600
python main.py resize input.jpg output.jpg --width 800 --height 600 --keep-aspectpython main.py remove-bg input.png output.pngpython main.py vectorize input.jpg output.svg
python main.py vectorize input.jpg output.svg --colors 16# Automatically remove blank borders
python main.py auto-crop input.png output.png
# Adjust sensitivity (lower = more aggressive cropping)
python main.py auto-crop input.png output.png --threshold 5# Generate favicon with default sizes (16x16, 32x32, 48x48)
python main.py favicon logo.png favicon.ico
# Generate favicon with custom sizes
python main.py favicon logo.png favicon.ico --sizes 16 32 48 64 128 256
# Generate high-quality favicon for modern browsers
python main.py favicon logo.png favicon.ico --sizes 32 64 128Remove watermarks from the bottom-right corner of images using OpenCV's content-aware inpainting:
python main.py remove-watermark-v1 input.jpg output.jpg
python main.py remove-watermark-v1 input.jpg output.jpg --width 25 --height 20 --method nsOptions:
--width: Watermark width as percentage of image width (default: 30)--height: Watermark height as percentage of image height (default: 15)--method: Inpainting method -telea(fast) orns(Navier-Stokes, higher quality)
Advanced watermark removal using the LaMa (Large Mask Inpainting) AI model for superior results.
Note: This implementation is based on the logic from dinoBOLT/Gemini-Watermark-Remover, adapted and transformed to Python.
Setup Instructions:
-
Download the model (
lama_fp32.onnx): -
Place the file:
Move the downloaded
lama_fp32.onnxfile into theassets/folder inside the project directory.Your folder structure must look like this:
images-helper/ ├── assets/ │ └── lama_fp32.onnx <-- The file goes here (approx. 200MB) ├── src/ │ └── helpers/ │ └── ... ├── main.py └── ...
Usage:
python main.py remove-watermark-v2 input.jpg output.jpg
python main.py remove-watermark-v2 input.jpg output.jpg --model path/to/custom/model.onnxFeatures:
- Uses state-of-the-art AI inpainting model (LaMa)
- Automatically detects and removes watermarks from bottom-right corner (15% × 15%)
- Preserves original image quality outside the watermark region
- Requires
lama_fp32.onnxmodel inassets/directory
Options:
--model: Custom path to lama_fp32.onnx model (default: assets/lama_fp32.onnx)
images-helper/
├── main.py # CLI entry point
├── src/
│ ├── __init__.py
│ └── helpers/ # Image processing functions
│ ├── __init__.py
│ ├── resize.py
│ ├── remove_background.py
│ ├── vectorize.py
│ ├── auto_crop.py
│ ├── favicon.py
│ └── remove_watermark.py
├── requirements.txt
└── README.md
To add a new image processing function:
- Create a new file in
src/helpers/(e.g.,src/helpers/my_feature.py) - Implement your function with a clear signature:
def my_feature(input_path: str, output_path: str, **kwargs) -> None:
"""
Description of what this does.
Args:
input_path: Path to input image
output_path: Path to save processed image
**kwargs: Additional parameters
"""
# Your implementation
pass- Export it in
src/helpers/__init__.py:
from .my_feature import my_feature
__all__ = [
# ... existing exports
'my_feature',
]- Add a command in
main.py:
# Import at top
from src.helpers.my_feature import my_feature
# Add parser in main()
feature_parser = subparsers.add_parser('my-feature', help='Description')
feature_parser.add_argument('input', type=str, help='Input image path')
feature_parser.add_argument('output', type=str, help='Output image path')
# Add any additional arguments
# Add handler in the routing section
elif args.command == 'my-feature':
my_feature(str(input_path), args.output)
print(f"✓ Feature applied successfully: {args.output}")MIT