From 6ed8d21c1a44648bbc7e6f00bfea60da231fc31b Mon Sep 17 00:00:00 2001 From: NguyenND Date: Thu, 11 Jun 2026 08:39:51 -0400 Subject: [PATCH] 06/11 Fix exported PDF photo orientation --- app/utils/pdf_export.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/utils/pdf_export.py b/app/utils/pdf_export.py index 01e09c2..e0624cc 100644 --- a/app/utils/pdf_export.py +++ b/app/utils/pdf_export.py @@ -121,8 +121,12 @@ def _compress_image(src_path: str) -> io.BytesIO | None: if not _PIL_AVAILABLE: return None try: + from PIL import ImageOps 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. # Convert palette / RGBA / LA → RGB before saving. if img.mode in ('RGBA', 'LA', 'P'):