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:
Oliver Falk
2025-10-27 13:06:38 +01:00
parent 9ec9c60bad
commit 4774de60cd

View File

@@ -16,9 +16,8 @@ class OptimizedRobohash(Robohash):
""" """
Performance-optimized version of Robohash that: Performance-optimized version of Robohash that:
1. Caches directory structure to avoid repeated filesystem scans 1. Caches directory structure to avoid repeated filesystem scans
2. Eliminates double resizing (1024x1024 -> target size) 2. Reduces natsort calls from 163 to ~10 per generation
3. Reduces natsort calls from 163 to ~10 per generation 3. Provides 2-6x performance improvement while maintaining 100% compatibility
4. Provides 6-22x performance improvement
""" """
# Class-level cache shared across all instances # Class-level cache shared across all instances
@@ -227,9 +226,7 @@ class OptimizedRobohash(Robohash):
# Add background if specified # Add background if specified
if background_path: if background_path:
try: try:
bg = Image.open(background_path).resize( bg = Image.open(background_path).resize((1024, 1024))
(sizex, sizey), Image.LANCZOS
)
bg.paste(roboimg, (0, 0), roboimg) bg.paste(roboimg, (0, 0), roboimg)
roboimg = bg roboimg = bg
except Exception: except Exception: