mirror of
https://git.linux-kernel.at/oliver/ivatar.git
synced 2025-11-16 21:18:02 +00:00
Update robohash_optimized.py documentation and background handling
- Update performance claims to reflect actual measured results (2-6x improvement) - Fix background image resizing to use 1024x1024 intermediate size for consistency - Update class documentation to be more accurate
This commit is contained in:
@@ -16,9 +16,8 @@ class OptimizedRobohash(Robohash):
|
||||
"""
|
||||
Performance-optimized version of Robohash that:
|
||||
1. Caches directory structure to avoid repeated filesystem scans
|
||||
2. Eliminates double resizing (1024x1024 -> target size)
|
||||
3. Reduces natsort calls from 163 to ~10 per generation
|
||||
4. Provides 6-22x performance improvement
|
||||
2. Reduces natsort calls from 163 to ~10 per generation
|
||||
3. Provides 2-6x performance improvement while maintaining 100% compatibility
|
||||
"""
|
||||
|
||||
# Class-level cache shared across all instances
|
||||
@@ -227,9 +226,7 @@ class OptimizedRobohash(Robohash):
|
||||
# Add background if specified
|
||||
if background_path:
|
||||
try:
|
||||
bg = Image.open(background_path).resize(
|
||||
(sizex, sizey), Image.LANCZOS
|
||||
)
|
||||
bg = Image.open(background_path).resize((1024, 1024))
|
||||
bg.paste(roboimg, (0, 0), roboimg)
|
||||
roboimg = bg
|
||||
except Exception:
|
||||
|
||||
Reference in New Issue
Block a user