Fix: EXIF-Orientierung bei Foto-Upload korrigieren (dogs + profile)

ImageOps.exif_transpose() vor convert("RGB") aufrufen, damit
hochkant aufgenommene Portrait-Fotos korrekt ausgerichtet gespeichert
werden und nicht um 90° gedreht angezeigt werden.
This commit is contained in:
rene 2026-04-18 12:40:35 +02:00
parent f8d354749d
commit 36622a6ed8
2 changed files with 8 additions and 3 deletions

View file

@ -134,7 +134,10 @@ async def upload_photo(
content = await file.read()
try:
img = Image.open(io.BytesIO(content)).convert("RGB")
from PIL import ImageOps
img = Image.open(io.BytesIO(content))
img = ImageOps.exif_transpose(img) # EXIF-Orientierung anwenden
img = img.convert("RGB")
buf = io.BytesIO()
img.save(buf, format="JPEG", quality=90)
content = buf.getvalue()

View file

@ -84,11 +84,13 @@ async def upload_avatar(
except ImportError:
pass
from PIL import Image
from PIL import Image, ImageOps
content = await file.read()
try:
img = Image.open(io.BytesIO(content)).convert("RGB")
img = Image.open(io.BytesIO(content))
img = ImageOps.exif_transpose(img) # EXIF-Orientierung anwenden
img = img.convert("RGB")
buf = io.BytesIO()
img.save(buf, format="JPEG", quality=90)
content = buf.getvalue()