fix: resize gallery thumbnails for current high density cards
This commit is contained in:
@@ -421,12 +421,19 @@ def create_app(settings=None, start_worker=True):
|
||||
raise FlowError(E.INVALID_REQUEST, "Invalid cloud image") from None
|
||||
if thumbnail:
|
||||
thumb = cached.with_name(cached.stem + "-thumb.jpg")
|
||||
if not thumb.exists():
|
||||
from PIL import Image
|
||||
from PIL import Image
|
||||
|
||||
with Image.open(cached) as img:
|
||||
img.thumbnail((300, 400))
|
||||
img.save(thumb, "JPEG")
|
||||
with Image.open(cached) as img:
|
||||
# The 430px cards need up to 860px on 2x displays. Replace the
|
||||
# existing cache in place so old 300px previews are upgraded.
|
||||
expected_edge = min(860, max(img.size))
|
||||
regenerate = not thumb.exists()
|
||||
if not regenerate:
|
||||
with Image.open(thumb) as existing:
|
||||
regenerate = max(existing.size) != expected_edge
|
||||
if regenerate:
|
||||
img.thumbnail((860, 860), Image.Resampling.LANCZOS)
|
||||
img.convert("RGB").save(thumb, "JPEG", quality=88, optimize=True)
|
||||
return FileResponse(thumb, media_type="image/jpeg")
|
||||
from PIL import Image
|
||||
|
||||
|
||||
Reference in New Issue
Block a user