From 500d090dfcfca776f0cac45013047b3aae7daa9c Mon Sep 17 00:00:00 2001 From: Daniel Bedeleanu Date: Wed, 22 Apr 2026 10:32:38 +0300 Subject: [PATCH] fix: strip EXIF from image blob in backend before processing Backend receives the original blob which may have EXIF orientation metadata. Strip it before processing to ensure backend analyzes the same raw image space that Gemini analyzed (which had EXIF stripped before sending). This ensures rotation_degrees are applied correctly to the same image state. --- backend/routers/items.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/backend/routers/items.py b/backend/routers/items.py index 3d269230..ff38c3a7 100644 --- a/backend/routers/items.py +++ b/backend/routers/items.py @@ -161,6 +161,10 @@ def create_item( image_bytes = base64.b64decode(item.extracted_image_bytes) log.info(f"[CREATE_ITEM] Received {len(image_bytes)} bytes for photo processing (base64 decoded)") + # Strip EXIF orientation to match what Gemini analyzed + image_bytes = strip_exif_orientation(image_bytes) + log.info(f"[CREATE_ITEM] After EXIF strip: {len(image_bytes)} bytes") + photo_result = _auto_save_photo_from_extraction( item_id=db_item.id, image_bytes=image_bytes,