1

I am a programmer, and I made an app for sharing images. I will not say the app's name because this is a genuine question, not a way to promote the app.

People are starting to use my app, and I have noticed that some photos show with wrong orientation. (See screenshot).

What would be your recommendation, 1, 2, 3, or something else?

  1. When a user uploads an image, read the EXIF data and adjust the original image's orientation and the created thumbnail.
  2. When a user selects an image from their phone, before uploading, show the image to the user and give the user a button to rotate the image themself.
  3. Or don't do anything as the wrong orientation maybe was done intentionally by the photographer.

app screenshot

2

Do all three by adding a “remember my choice” check box Boolean to the dialogue of the second option.

1

The answer of @bob-macaroni-mcstevens is wise, and a certain degree of editing before uploading is something I am considering adding to the features roadmap.

However, I have discovered the problem, and I am answering my own question as it could be helpful to someone else.

The orientation of an image is generally stored in the EXIF metadata contained within the image.

When the image is displayed, the software that displays the image usually uses the EXIF orientation to display the image correctly.

My app API backend is written in python, and I am using the PIL library to create the thumbnails. I discovered that when a resized image is saved using the PIL library, the EXIF metadata is removed from the image.

Without the EXIF data, my app displays the thumbnails as they are. Without any orientation correction.

To fix the issue, I had to extract the EXIF data from the original image and make sure it was saved in the resized thumbnail.

Code snip to extract Exif data

# extracting the raw Exif data
with PIL.Image.open(fp, 'r') as img:
    try:
        raw_exif = img.info['exif']
    except (AttributeError, KeyError):
        raw_exif = b''

Code snip to store Exif data in the resized image

with PIL.Image.open(self.original_filepath, 'r') as img:
    img.save(resized_filepath, exif=self.raw_exif)

The key fix was to pass the exif parameter to the save method.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.