From f565ed2438491ed659bae2fef7927a07604182e8 Mon Sep 17 00:00:00 2001 From: Faris Ansari Date: Wed, 25 Mar 2026 19:51:40 +0530 Subject: [PATCH] fix: apply exif orientation before stripping the tag (#37998) --- frappe/utils/image.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/frappe/utils/image.py b/frappe/utils/image.py index dd70e796ed..1680bfc744 100644 --- a/frappe/utils/image.py +++ b/frappe/utils/image.py @@ -3,7 +3,7 @@ import io import os -from PIL import Image +from PIL import Image, ImageOps import frappe @@ -32,6 +32,8 @@ def strip_exif_data(content, content_type) -> bytes: """ original_image = Image.open(io.BytesIO(content)) + # Apply EXIF orientation to pixels before stripping the tag. + original_image = ImageOps.exif_transpose(original_image) output = io.BytesIO() # ref: https://stackoverflow.com/a/48248432 if content_type == "image/jpeg" and original_image.mode in ("RGBA", "P"):