Open epou opened 10 months ago
Be aware of the EXIF.Orientation tag.
@nikaxx proposed two possible solutions:
- retain the original EXIF orientation metadata.
- rotate the image based on the EXIF orientation metadata value, save the already rotated image to the server, and remove the tag completely or reset the EXIF orientation tag to "0".
A value of "0" in EXIF orientation tag signifies that the tag should be ignored according to the documentation.
Please also note to transform previous images that are already on the server, after choosing one of the two proposed solutions to keep the consistency.
Example of how to find EXIF orientation tag:
from PIL import Image, ExifTags, ImageOps
from PIL.ExifTags import TAGS
# find exif orientation metadata of an image
def find_image_exif_orientation(original_image_file):
orientation = None
with Image.open(original_image_file) as pilImg:
img_exif = pilImg.getexif()
if img_exif is not None:
for key, val in img_exif.items():
if key in ExifTags.TAGS and key == 274:
orientation = val
#print('{}: {} key number:{}'.format(TAGS[key], val, key))
return orientation
Example
Also see: https://github.com/Mosquito-Alert/mosquito_alert/issues/52