fix: Improve transparency handling and optimization levels
- Handle transparency in whitespace trimming - Use IntEnum for optimization levels - Add proper level comparisons - Treat transparent pixels as white for boundary detection - Preserve transparency in output - Fix black artifacts in transparent areas
This commit is contained in:
+16
@@ -2,6 +2,19 @@
|
||||
|
||||
import os
|
||||
import multiprocessing
|
||||
from enum import IntEnum
|
||||
|
||||
class OptimizationLevel(IntEnum):
|
||||
"""Optimization levels for image processing.
|
||||
|
||||
Levels:
|
||||
1: Only trim whitespace
|
||||
2: Trim + convert to 1-bit monochrome
|
||||
3: All optimizations + optipng
|
||||
"""
|
||||
TRIM = 1 # Only trim whitespace
|
||||
MONOCHROME = 2 # Trim + convert to 1-bit monochrome
|
||||
FULL = 3 # All optimizations + optipng
|
||||
|
||||
# Number of parallel processes to use for operations that support parallelization
|
||||
# Defaults to number of CPU cores - 1, but never less than 1
|
||||
@@ -14,5 +27,8 @@ PARALLEL_PROCESSES = int(os.getenv('NOTES_CLEANER_PARALLEL_PROCESSES', DEFAULT_P
|
||||
OPTIPNG_OPTIMIZATION_LEVEL = int(os.getenv('NOTES_CLEANER_OPTIPNG_LEVEL', '7')) # 0-7, higher = better compression but slower
|
||||
TRIM_PADDING_PIXELS = int(os.getenv('NOTES_CLEANER_TRIM_PADDING', '20')) # Padding around content after trimming
|
||||
|
||||
# Image processing settings
|
||||
MONOCHROME_THRESHOLD = int(os.getenv('NOTES_CLEANER_MONO_THRESHOLD', '200')) # 0-255, higher = more white
|
||||
|
||||
# Temporary directory settings
|
||||
TEMP_DIR_PREFIX = 'notes_cleaner_'
|
||||
|
||||
Reference in New Issue
Block a user