When Should I Auto-Orient My Images?
Published May 8, 2020 • 2 min read
Roboflow Screenshot: Auto-Orient Enabled, Discard EXIF rotations and standardize pixel ordering.
The recommended Roboflow setting is "Auto-Orient: Enabled"

When should you auto-orient your images?

The short answer: almost always.

When an image is captured, it contains metadata that dictates the orientation by which it should be displayed relative to how the pixels are arranged on disk. This directive (stored in the EXIF orientation field) speeds up encoding the image at capture-time so cameras can efficiently sample data from their sensors without unwanted artifacts.

This means that most cameras store images' pixels exactly the same whether the camera is oriented in landscape or portrait mode. They just flip a bit to signal to the viewer whether to display the pixels as-is or to rotate them by 90 or 180 degrees when displaying the image.

Unfortunately, this can cause issues if the application displaying the images is unaware of the metadata and naively displays the image without respecting its EXIF orientation.

Two dice with bounding boxes misaligned and properly aligned based on image orientation.
Left: EXIF Orientation mismatch between annotation and image, Right: Correct Exif Orientation

This is an easy thing to mess up (especially when programming our own image pipelines). And, in fact, is one of the most common bugs encountered in computer vision projects. If some of your images are stored on disk as x,y and some are y,x, you're going to be feeding your model bad info without even knowing it.

Fortunately, Roboflow fixes this problem for you by default. All you have to do is enable "Auto-Orient" in your pre-processing settings.

When not to auto-orient

So why do we even give you the option to turn this off? Well, in very specific circumstances, you may want to use this as a speed optimization.

One example would be if you're creating a mobile app that runs on a specific device where you know that all of your images will have the same EXIF orientation. To avoid having to rotate the pixel values at runtime, you may want to leave them in the same coordinate system. So long as you train your model with the same type of inputs (and your labeling tool properly deals with this), you shouldn't have any problems.

Cite this Post

Use the following entry to cite this post in your research:

Brad Dwyer. (May 8, 2020). When Should I Auto-Orient My Images?. Roboflow Blog: https://blog.roboflow.com/exif-auto-orientation/

Discuss this Post

If you have any questions about this blog post, start a discussion on the Roboflow Forum.

Written by

Brad Dwyer
Roboflow cofounder and CTO. Building the computer vision infrastructure for developers. Previously founded Hatchlings and created Product Hunt's AR App of the Year.