12/08/2021

Rotation(orientation) correction when uploading photos from mobile (python, pillow)

 Try to use ImageOps function.

Solution is simple refer to below code:

.

#pip install Pillow
from PIL import Image, ImageOps
image = Image.open('img.jpg') #open image
#### orient fix
image = ImageOps.exif_transpose(image)
#### go futher!

.


Thank you.

πŸ™‡πŸ»‍♂️

www.marearts.com