From 25f0cc30ee12347a991bd5a291e1969db67c0a7d Mon Sep 17 00:00:00 2001 From: Aarni Koskela Date: Mon, 3 Jul 2023 10:26:37 +0300 Subject: [PATCH] Simplify EXIF transposition to not read the EXIF data twice --- gradio/processing_utils.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/gradio/processing_utils.py b/gradio/processing_utils.py index 577e10b0db4b2..e4fecdf4fe0bd 100644 --- a/gradio/processing_utils.py +++ b/gradio/processing_utils.py @@ -58,9 +58,7 @@ def decode_base64_to_image(encoding: str) -> Image.Image: image_encoded = extract_base64_data(encoding) img = Image.open(BytesIO(base64.b64decode(image_encoded))) try: - exif = img.getexif() - # 274 is the code for image rotation and 1 means "correct orientation" - if exif.get(274, 1) != 1 and hasattr(ImageOps, "exif_transpose"): + if hasattr(ImageOps, "exif_transpose"): img = ImageOps.exif_transpose(img) except Exception: log.warning(