In [2]:
! pip install pillow
In [4]:
import PIL
In [5]:
from matplotlib.pyplot import imshow
import numpy as np
from PIL import Image
In [7]:
! ls mrss-maker/sample-images/
In [ ]:
pil_im = Image.open('mrss-maker/sample-images/_D3R5967.jpg', 'r')
%matplotlib inline
In [12]:
from PIL import Image
import functools
In [13]:
def image_transpose_exif(im):
exif_orientation_tag = 0x0112 # contains an integer, 1 through 8
exif_transpose_sequences = [ # corresponding to the following
[],
[Image.FLIP_LEFT_RIGHT],
[Image.ROTATE_180],
[Image.FLIP_TOP_BOTTOM],
[Image.FLIP_LEFT_RIGHT, Image.ROTATE_90],
[Image.ROTATE_270],
[Image.FLIP_TOP_BOTTOM, Image.ROTATE_90],
[Image.ROTATE_90],
]
try:
seq = exif_transpose_sequences[im._getexif()[exif_orientation_tag] - 1]
except Exception:
return im
else:
return functools.reduce(lambda im, op: im.transpose(op), seq, im)
In [18]:
i = Image.open('../samples/wedding/20160523_162239.jpg')
j = Image.open('../samples/wedding/20160523_162251.jpg')
k = Image.open('../samples/wedding/20160523_162305.jpg')
In [25]:
k
Out[25]:
In [ ]: