Photo image files are rotated according to EXIF Orientation metadata tag, but the tag is still present in the resulting image, leading to double rotation
Images (photos) taken on modern cameras and mobile devices contain EXIF metadata describing attributes such as the place and date/time a photo was taken, the focal length. Importantly for this issue I’m reporting, many devices capture only landscape photos but record whether the photo was taken with the camera rotated. The metadata records rotation away from landscape format in units of 90°, so portrait photos are captured as landscape but tagged with “rotate by 90°” (or “rotate by 270°”).
When I take a landscape photo, import into KoBoToolbox, and then export it as collected data, the image is correct. This is because the Orientation tag has a “Orientation not required” value.
When I take a portrait photo from a camera that uses the Orientation tag to capture rotation, the photo file inside KoBoToolbox is rotated and rewritten according to the Orientation tag, but the Orientation tag is not removed from the file. When the file is exported from KoBoToolbox, and the photo rendered for a user, the photo is oriented according to the Orientation tag. Unfortunately, because as the image has already been oriented somewhere inside the KoBo universe, the photo is now turned twice, and it’s no longer correct.
The solution is an either/or one, somewhere inside either KoBoCollect or the import side of KoBoToolbox (I cannot identify which is at fault here)
EITHER: do not change the photo orientation but leave that to the final renderer to do so according to the EXIF metadata
OR: continue to change the photo orientation but remove the Orientation tag from the EXIF metadata so that no further orientation processing is performed
The correct solution should be the first one.
Method to reproduce
Create a simple form containing a photo uploader
Using KoBoCollect, take a photo on a device that produces an EXIF Orientation tag for portrait photos and upload it via the form
Download the photo from KoBoToolbox and render on any system that understands EXIF Orientation. (This includes the standard thumbnail and picture viewers in Windows 10 File Explorer.)
Notice that landscape photos render correctly, but portrait photos are sideways
Contrast with same photo source, with the photo file copied directly to the renderer (Windows 10 File Explorer, for example), where portrait photos are displayed vertical as expected
You can check EXIF tags with a tool as EXIFTOOL (Windows). Variants for Linux-based systems also abound.
Hi, this is a big issue also for my project and I was about to post it myself. Any update @Kal_Lam ?
@roaima is that right that the photos uploaded & downloaded through Kobo must be always rotated 90° to the right to get back to the original orientation? If that so I could write a script in GIMP or R as temporary patch to this issue. It seems so in my data.
@simblanco I’ve added EXIFTOOL to my automated workflow that extracts data and images from the KoBo Server. The images are downloaded and then EXIFTOOL is used to strip the Orientation tag from the downloaded images. This makes them render correctly from this point on.
Portrait pictures are displayed sideways because KoBo breaks them. I’ve described the bug in significant detail (here and on github), including a method by which the problem can be repeated. Is there a benefit to seeing people’s pictures rotated wrongly by 90°?
@dbielby you could use EXIFTOOL as I described in an earlier post to strip out the Orientation tag from pictures that have been mangled by KoBo.
Thankfully, someone else has opened an issue for this in the appropriate repository (ODK Collect) and even submitted a pull request to fix it:
Once that is merged and included in a release of ODK Collect, hopefully the problem will go away. KoBoCollect is maintained by the same folks as ODK Collect, but its releases sometimes come slightly afterwards. If you are keen to get the fix as quickly as possible, there are no disadvantages to using ODK Collect with KoBoToolbox.