Add news source logos (#143)

* Download favicons; Display first one

* Refine image loading

* Switch to static images

* Remove unused var

* Fix

* Clean up

* Fix width fallback
This commit is contained in:
Evan Salter
2025-12-09 09:59:18 -06:00
committed by GitHub
parent 694c7cec10
commit 711482d59a
5 changed files with 104 additions and 70 deletions

16
src/image_utils.py Normal file
View File

@@ -0,0 +1,16 @@
import logging
from PIL import Image
logger = logging.getLogger(__name__)
def scale_to_max_dimensions(img, max_width, max_height):
h_to_w_ratio = img.height / img.width
w_to_h_ratio = img.width / img.height
if img.height > max_height:
img = img.resize((int(max_height * w_to_h_ratio), max_height), Image.Resampling.LANCZOS)
if img.width > max_width:
img = img.resize((max_width, int(max_width * h_to_w_ratio)), Image.Resampling.LANCZOS)
return img