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
|
|
@ -134,7 +134,10 @@ async def upload_photo(
|
||||||
|
|
||||||
content = await file.read()
|
content = await file.read()
|
||||||
try:
|
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()
|
buf = io.BytesIO()
|
||||||
img.save(buf, format="JPEG", quality=90)
|
img.save(buf, format="JPEG", quality=90)
|
||||||
content = buf.getvalue()
|
content = buf.getvalue()
|
||||||
|
|
|
||||||
|
|
@ -84,11 +84,13 @@ async def upload_avatar(
|
||||||
except ImportError:
|
except ImportError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
from PIL import Image
|
from PIL import Image, ImageOps
|
||||||
|
|
||||||
content = await file.read()
|
content = await file.read()
|
||||||
try:
|
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()
|
buf = io.BytesIO()
|
||||||
img.save(buf, format="JPEG", quality=90)
|
img.save(buf, format="JPEG", quality=90)
|
||||||
content = buf.getvalue()
|
content = buf.getvalue()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue