Commit Graph
12 Commits
Author SHA1 Message Date
Esa Kataja 6e083f39e8 Implement parallel processing for optimization steps using ThreadPoolExecutor. 2024-12-03 23:45:35 +02:00
Esa Kataja 825338a2a3 Swap optimization steps: convert to monochrome before trimming whitespace. Include uv.lock in the commit. 2024-12-03 23:41:40 +02:00
Esa Kataja a78b9c25d1 Improve PDF generation with proper A4 sizing and borders
- Move PDF border size to settings.py
- Use standard A4 dimensions (210x297mm)
- Fix aspect ratio preservation in layout function
- Use img2pdf's built-in layout function with proper border specification
2024-12-03 22:53:23 +02:00
Esa Kataja 0f105880e6 fix: improve content detection in trim_whitespace
- Add thresholding to better separate content from background
- Invert image so content becomes white for getbbox detection
- Fix issue where white and transparent areas weren't being trimmed
2024-12-03 22:32:19 +02:00
Esa Kataja a979712c8c perf: optimize PNG compression only on final operations
- Add is_final parameter to trim_whitespace and convert_to_monochrome
- Only optimize PNGs on the final operation of each level
- Remove optimization from extract command
- Level 1: optimize in trim_whitespace
- Level 2: optimize in convert_to_monochrome
- Level 3: defer to optipng
2024-12-03 22:23:54 +02:00
Esa Kataja 75dc1c3e2c fix: properly handle transparency in trim_whitespace
Simplify transparency handling by flattening image with white
background for bounds detection while preserving original
transparency in the final crop. This fixes the issue where
transparent areas were being treated as black during trimming.
2024-12-03 22:06:51 +02:00
Esa Kataja 84e1a6a82e refactor: consolidate image trimming and standardize processing
- Replace OpenCV-based trim_whitespace with PIL implementation
- Remove redundant trim_whitespace_pil function
- Add initial trim step to extract command
- Standardize image processing to 2048px wide grayscale using Lanczos
2024-12-03 21:47:03 +02:00
Esa Kataja 682a1f13ee 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
2024-12-03 21:38:55 +02:00
Esa Kataja 3d143ce5a2 feat: Add optimize command
- Add whitespace trimming functionality
- Add optional PNG optimization with optipng
- Add progress tracking and error handling
- Improve imports organization
- Add proper docstrings and return values
2024-12-03 21:10:38 +02:00
Esa Kataja bad7612027 feat: Add cleanup of temporary files in finalize command
- Remove all temporary PNG files after PDF creation
- Remove temporary directory
- Update command feedback messages
2024-12-03 20:55:56 +02:00
Esa Kataja 9bacbb0dcf feat: Improved deskew to focus on horizontal lines
- Modified deskew function to better detect staff lines
- Added morphological operations to enhance horizontal lines
- Used probabilistic Hough transform for more precise line detection
- Added .png to gitignore
2024-12-03 20:53:17 +02:00
Esa Kataja eb11d95764 feat: Add PDF cleaner with deskew and image enhancement
Features:
- Page deskewing using contour detection
- Image enhancement with edge preservation
- High-resolution output (min 2048px width)
- Black and white conversion with proper contrast
2024-12-03 19:25:02 +02:00