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:
parent
f8d354749d
commit
36622a6ed8
2 changed files with 8 additions and 3 deletions
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue