The dumb reason your fancy Computer Vision app isn’t working: Exif Orientation

Adam Geitgey
Oct 9 · 6 min read

How Digital Cameras Auto-Rotate Images

Why does this break so many Python Computer Vision Applications?

Google Vision’s API demo fails to rotate a portrait-oriented image captured with a standard cell phone.
Finder on a Mac always displays images with Exif rotation applied. There is no way to see that the image data is actually sideways inside the file.

Fixing the Problem

pip3 install image_to_numpy
import matplotlib.pyplot as plt
import image_to_numpy
# Load your image file
img = image_to_numpy.load_image_file("my_file.jpg")
# Show it on the screen (or whatever you want to do)
plt.imshow(img)
plt.show()

Adam Geitgey

Written by

Interested in computers and machine learning. Likes to write about it.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade