Skip to content

Commit

Permalink
Simplify EXIF transposition to not read the EXIF data twice
Browse files Browse the repository at this point in the history
  • Loading branch information
akx committed Jul 4, 2023
1 parent 355b1e1 commit ed42651
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions gradio/processing_utils.py
Expand Up @@ -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(
Expand Down

0 comments on commit ed42651

Please sign in to comment.