Portrait photos imported through KoBoCollect are sideways (bug report)

Summary:

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

Detail:

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

  1. Create a simple form containing a photo uploader
  2. Using KoBoCollect, take a photo on a device that produces an EXIF Orientation tag for portrait photos and upload it via the form
  3. 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.)
  4. Notice that landscape photos render correctly, but portrait photos are sideways
  5. 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.

Thanks
Chris

1 Like

Thank you for the details, @roaima! Will have a closer look and get back to you soon.

Hi @roaima
Out of curiosity, could you explain the mode/s of download that are affected by this

Stephane

1 Like

It’s primarily through the V1 API but I think it’s also via the Forms Management interface (alongside downloading data as a spreadsheet, etc.)

If that’s sufficient, great. Otherwise I’ll pick this up on Monday/Tuesday, when I’m back in the office, with specifics

2 Likes

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.

Thanks!!

@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.

For example on Windows

EXIFTOOL -If "$Orientation" -Orientation= "5738-1620155725386.jpg"

(Change the double quotes to single quotes if you’re running on a UNIX/Linux platform, so that $Orientation isn’t treated as a shell variable.)

1 Like

Hi @roaima and @simblanco, thank you for bringing this to our attention. I’ve created an issue to track it and hopefully it can be sorted out soon.

1 Like

We are still seeing photos in the wrong position. Is there a way to offer photo rotate to manually correct the photos in Kobo?

Welcome to the community, @dbielby! Could you share with us a screenshot of the issue so that we could understand your issue pictorially?

Hello @Kal_Lam,

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.

Thanks
Chris

Of course not.

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.

1 Like