How to solve incorrect photo rotation after sync or upload

Surprisingly, photo rotation is a complicated issue for software to handle.

thinkstock camera
Credit: ThinkStock

Louis Skrabec wants the angle on photo orientation:

I downloaded photos from my camera to my Windows PC. I rotated photos taken in portrait orientation 90 degrees using the photo editing feature and saved the changes. Then created a new shared album in iCloud and uploaded the photos. All portrait photos that I rotated to proper positions are back in landscape orientation. What did I do wrong? How do I fix them?

Rotation is a surprisingly complicated issue! What you’re seeing is a common mismatch between editing and display software.

Modern digital cameras and smartphones track the orientation of your device and rotate the preview you see to be the right away up, no matter what you do. Some devices might only allow 90-degree clockwise and counter-clockwise rotation from what’s considered upright, but any usable smartphone can handle 180 degrees.

But an image sensor always captures the data without regard to orientation: it’s just grabbing photons and recording the measurements relative to the physical array in which it’s located. Some cameras can store this as a raw file, unique to each camera brand, that’s the mostly prefiltered data captured by a sensor. Others can only output in JPEG or another format, or you can opt to get JPEG and raw or JPEG instead of raw. (Raw is often capitalized as RAW, but it’s not an initialism.)

If the camera were to produce with data stored in the same orientation as you took the picture, except for the single orientation that matches how data comes out of the sensor array, it would need to create a second image file into which to map each pixel from one orientation to the other, then delete that original file.

Earlier cameras lacked the computational power to handle this rotation, which was also RAM intensive: The image would need to be rotated before the sensor data was converted to a file format that compressed image data, like JPEG. “Lossy” file formats like JPEG use approximations via mathematical formats to describe regions of an image; some camera makers’ raw formats are lossy as well. (“Lossless” compression is less efficient, but by identifying redundant patterns in a hunk of data, it allows an exact reproduction of the original data from the compressed file.)

It’s possible to rotate JPEGs without adding additional image quality loss if the image resolution divides perfectly into the 8 by 8 or 16 by 16 grids that a given JPEG algorithm used. Not all cameras had the perfect units years ago, and not all still do.

But if a camera (or other software) rotates a JPEG after it’s been saved in that format, each decompression, rotation, and recompression progressively ruins the image.

The trick that camera makers came up with was to avoid rotating pixels and, instead, set a flag in the EXIF metadata that’s incorporated in any image their camera exports. The orientation flag has one of eight values, representing each rotation of 0 degrees, 90 degrees, 180 degrees, and 270 degrees, as well as mirror flips (flipped top to bottom and left to right, and clockwise rotated top to bottom and left to right). (Rotations that aren’t aren’t at right angles always involves modifying image data to approximate the new angle.)

Eight different orientations can be represented with a value for the EXIF Orientation tag.
Two images, one in the same rotation as the image-sensor array in the iPhone and the other rotated, have their Orientation value tagged in EXIF data.

Any software that can display an image should be able to read this orientation flag and display a photo in the correct orientation. Likewise, any image-editing software, on opening a file and decompressing it (if necessary) to make it editable should also orient it first.

However, image software in Windows prior to Windows 8 couldn’t read the orientation flag, and many Mac OS X apps used to suffer from the same problem, including iPhoto 4 and earlier versions.

As one example, GraphicConverter for OS X has a lot of EXIF rotation options to assist with import and editing.

I’m surprised whatever software Louis is using in 2016 would have this problem, but it would seem to be a mismatch between whatever it encoded in EXIF and what iCloud read from the upload—iCloud doesn’t strip EXIF data.

Unfortunately, doesn’t let you edit photos once they’re uploaded. In order to get the correct online rotation, you’ll need to either use an iOS device or an OS X devices with iCloud Photo Library synced to that collection, or use different software to handle the rotation and re-upload.

If you’re handy with the command line, in OS X or Windows, you can also use the free ExifTool to modify embedded EXIF data in photographs.

Ask Mac 911

We’re always looking for problems to solve! Email yours to including screen captures as appropriate. Mac 911 cannot reply to email with troubleshooting advice nor can we publish answers to every question.

Subscribe to the Best of Macworld Newsletter