06/11 Fix exported PDF photo orientation

This commit is contained in:
2026-06-11 08:39:51 -04:00
parent 24064409a8
commit 6ed8d21c1a
+4
View File
@@ -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'):