Skip to content

Commit

Permalink
fix: rotate images on acquisition of source
Browse files Browse the repository at this point in the history
  • Loading branch information
jrdh authored Jul 16, 2024
1 parent 55f04e3 commit 89eddd3
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions iiif/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

import aiohttp
import humanize
from PIL import Image
from PIL import Image, ImageOps
from jpegtran import JPEGImage

mimetypes.init()
Expand Down Expand Up @@ -119,13 +119,8 @@ def convert_image(image_path: Path, target_path: Path, quality: int = 80,
# given this is usually run in a separate process, make sure we have disabled bomb errors
disable_bomb_errors()
with Image.open(image_path) as image:
if image.format.lower() == 'jpeg':
exif = image.getexif()
# this is the orientation tag, remove it if it's there
exif.pop(0x0112, None)
image.info['exif'] = exif.tobytes()

target_path.parent.mkdir(parents=True, exist_ok=True)
ImageOps.exif_transpose(image, in_place=True)
image = image.convert(mode='RGB')
image.save(target_path, format='jpeg', quality=quality, subsampling=subsampling)

Expand Down

0 comments on commit 89eddd3

Please sign in to comment.