A powerful image processing tool that converts images to white-on-transparent format, optimized for logos and graphics.
- Converts various image formats (JPG, PNG, SVG, WEBP) to white-on-transparent PNG/WEBP/SVG
- Smart edge detection and detail preservation
- Adaptive thresholding for optimal results on different image types
- Handles both light-on-dark and dark-on-light inputs
- Maintains fine details while reducing noise
- Command-line interface for easy integration
pip install -r requirements.txtBasic usage:
whitetrace input_file [--output OUTPUT_FILE] [--format {png,webp,svg}] [--threshold VALUE] [--invert] [--debug]Arguments:
input_file: Path to input image file--output: Path to output file (default:input_white.<ext>)--format: Output format:png,webp, orsvg(default: inferred from output filename orpng)--threshold: Threshold value 0-255 (default: 200)--invert: Invert thresholding result (use if subject is lighter than background)--debug: Output intermediary files for inspection
from whitetrace.processing.threshold import apply_threshold
from PIL import Image
# Load image
image = Image.open('input.png')
# Process image
result = apply_threshold(
image,
threshold=200, # Adjust threshold (0-255)
invert=False # Set True for light-on-dark images
)
# Save result
result.save('output.png')-
Image Loading
- Supports JPG, PNG, SVG, WEBP inputs
- SVG files are rasterized before processing
-
Preprocessing
- RGB to grayscale conversion
- Bilateral filtering for noise reduction
- Local standard deviation calculation for detail detection
-
Adaptive Thresholding
- Detail-aware processing with dual thresholding
- Fine-grained threshold for detailed areas
- Larger block size for smooth regions
-
Transparency Handling
- Converts binary mask to RGBA
- White foreground (#FFFFFF) with full opacity
- Transparent background (alpha = 0)
- SVG output quality depends on vectorization accuracy
- Very fine details might be lost in some cases
- Complex gradients may not be preserved
- Performance impact on very large images
-
Algorithm Enhancements
- Machine learning-based edge detection
- Improved gradient handling
- Better preservation of small text
- Multi-scale processing for better detail retention
-
Feature Additions
- Batch processing with parallel execution
- GUI interface
- Watch folder functionality
- Preview mode
- Custom color support
- Additional output formats
-
Performance Optimization
- GPU acceleration
- Streaming processing for large files
- Memory usage optimization
- Caching mechanism for batch processing
-
Quality Improvements
- Advanced noise reduction
- Better handling of anti-aliased edges
- Improved SVG vectorization
- Support for preserving metadata
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the Creative Commons Attribution-ShareAlike 4.0 International License (CC-BY-SA).
This means you are free to:
- Share — copy and redistribute the material in any medium or format
- Adapt — remix, transform, and build upon the material for any purpose
Under the following terms:
- Attribution — You must give appropriate credit
- ShareAlike — If you remix, transform, or build upon the material, you must distribute your contributions under the same license
For more details: https://creativecommons.org/licenses/by-sa/4.0/
Created and maintained by the WhiteTrace development team.