Search code examples
file-uploadautorotatephoto-upload

Simple file upload auto rotates photos


I have a simple file upload. Nothing extravegent and especially nothing that should be auto rotating photos. But my pictures are auto rotating. If I upload a picture on my computer, that opens up in every program (paint, windows picture viewer, etc.) right side up, it'll be sideways when uploaded to my website. Is this a common problem with an easy fix?

Thank You


Solution

  • A lot of image viewers nowadays evaluate exif data, specifically the 'Orientation' tag. This tag may be filled in by a digital camera and holds the orientation which the picture was shot in (horizontal/vertical). If it's present and the viewer supports it, the image is auto-rotated to fit the original orientation, so what might happen is that your local viewers evaluates the tag and auto-rotates and your website doesn't (or vice versa, although this is not very likely).

    You can check your image for exif tags e.g. here. Look for the Orientation tag.

    A quick solution would be to clear the exif tags from your images before uploading to get consistent behaviour between local and website viewing, or if you like it more advanced, modify your code and rotate the image occording to it's original Orientation after uploading.