06/11 Fix exported PDF photo orientation
This commit is contained in:
@@ -121,8 +121,12 @@ def _compress_image(src_path: str) -> io.BytesIO | None:
|
|||||||
if not _PIL_AVAILABLE:
|
if not _PIL_AVAILABLE:
|
||||||
return None
|
return None
|
||||||
try:
|
try:
|
||||||
|
from PIL import ImageOps
|
||||||
img = PILImage.open(src_path)
|
img = PILImage.open(src_path)
|
||||||
|
|
||||||
|
# Apply EXIF orientation tag so rotated phone photos appear upright.
|
||||||
|
img = ImageOps.exif_transpose(img)
|
||||||
|
|
||||||
# Strip transparency — JPEG does not support alpha channels.
|
# Strip transparency — JPEG does not support alpha channels.
|
||||||
# Convert palette / RGBA / LA → RGB before saving.
|
# Convert palette / RGBA / LA → RGB before saving.
|
||||||
if img.mode in ('RGBA', 'LA', 'P'):
|
if img.mode in ('RGBA', 'LA', 'P'):
|
||||||
|
|||||||
Reference in New Issue
Block a user