From 4774de60cd47d8c42395c0aac865c0d24e8b0967 Mon Sep 17 00:00:00 2001 From: Oliver Falk Date: Mon, 27 Oct 2025 13:06:38 +0100 Subject: [PATCH] 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 --- ivatar/robohash_optimized.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/ivatar/robohash_optimized.py b/ivatar/robohash_optimized.py index ac37801..aeb42e6 100644 --- a/ivatar/robohash_optimized.py +++ b/ivatar/robohash_optimized.py @@ -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: