#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2011
    Posts
    28
    Rep Power
    0

    Browser rotates images


    Hello all,

    Not sure we're exactly to post this, thought I'd start here.

    I've only tested this on a Mac so far.

    I've been working on a project using SWFUpload and I thought my problem was with my resizing math on upload, but then got a surprise.

    The problem was, on upload, portait shaped pictures are being rotated right.

    So in finder (the mac file explorer) I right click and open the original image with firefox - it rotates it right, I try safari, chrome, opera - they all open the original image and rotate it right! No upload, the local image! Weird.

    All the google searching I do get's me info about rotating images after upload or something.

    Anyone seen this before and why it does it?

    Thanks,

    - A

    EDIT: I think I found the culprit, exif_read_data()

    I'll post back when I fix it.

    - A
    Last edited by anonvisitore; November 7th, 2011 at 11:24 AM. Reason: Think I found answer
  2. #2
  3. Transforming Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,247
    Rep Power
    9400
    There is absolutely nothing that will rotate images during an upload: not a browser doing it beforehand, not anything doing it after.

    No offense, but you are mistaken about the orientation of the "original" image.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2011
    Posts
    28
    Rep Power
    0
    Originally Posted by requinix
    There is absolutely nothing that will rotate images during an upload: not a browser doing it beforehand, not anything doing it after.

    No offense, but you are mistaken about the orientation of the "original" image.
    So, when I open the original image in a browser on my local computer and the browser rotates the image - it does this because... ?

    You seem pretty sure about your statement, can you offer any more insight?

    Thanks,

    - A
  6. #4
  7. Transforming Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,247
    Rep Power
    9400
    I'm very familiar with browsers, file uploads, HTTP, and server-side languages. Nothing in that entire process cares whether the file is an image, let alone will arbitrarily rotate it.

    What you're seeing in the browser is what the image actually looks like. If the Finder shows it differently then that's the Finder showing it differently.
    I found somebody on CNET who had a similar problem. It sounds like they rotated the image themselves at one point, but the image itself wasn't modified - only its EXIF data, which Finder uses (and 99% of everything else does not).
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2011
    Posts
    28
    Rep Power
    0
    Originally Posted by requinix
    I'm very familiar with browsers, file uploads, HTTP, and server-side languages. Nothing in that entire process cares whether the file is an image, let alone will arbitrarily rotate it.

    What you're seeing in the browser is what the image actually looks like. If the Finder shows it differently then that's the Finder showing it differently.
    I found somebody on CNET who had a similar problem. It sounds like they rotated the image themselves at one point, but the image itself wasn't modified - only its EXIF data, which Finder uses (and 99% of everything else does not).
    I'm not sure that the CNET issue is the same.
    I'm pretty sure it's the exif data that's rotating the photo in the browser or not rotating it there.

    After exporting from my camera, the photo's look correct in:
    iPhoto, finder, preview, bridge and photoshop. It's only when I open it in a browser that it rotates right 90 degree's.

    I'm able to see the exif data using a sample from the PHP manual, there's another sample that shows testing for the 'IFD0.Orientation', the problem photo's are showing IFD0.Orientation: 8, which the second doc sample shows needing to be rotated 90 deg left - just what mine need. So... I'm thinking that I'll need to test the exit data of each of my uploads and correct them as needed. My concern is about consistency.

    Thanks for your input.

    - A
  10. #6
  11. Transforming Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,247
    Rep Power
    9400
    Yes, fixing the EXIF after an upload is a good way of correcting the problem.
    The real issue is that the image data is oriented in one way while the EXIF data claims it's oriented in another way; if you believe the EXIF over the image then you have the right solution.
  12. #7
  13. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2011
    Posts
    28
    Rep Power
    0
    Originally Posted by requinix
    Yes, fixing the EXIF after an upload is a good way of correcting the problem.
    The real issue is that the image data is oriented in one way while the EXIF data claims it's oriented in another way; if you believe the EXIF over the image then you have the right solution.
    Also, after some testing various exports from iPhoto.
    This issue only shows it'self is when I export as 'original'. If I export as JPEG there's no problem.
    I bet if I ran my exif test against one of these photo's it would say "no headers".

    At least it's probably somewhat of a "corner case" with the users for the current clients of the product, but I'm going to want to catch these.

    Thanks for your time in replying.

    - AV
  14. #8
  15. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2014
    Posts
    1
    Rep Power
    0

    Example of problem


    Here is a link to a page on my website that exhibits the problem the original poster seems to be indicating.

    New Math

    There are four images on the page. The first two are the same .jpg file but one is rotated 90 degrees (using Preview on a Mac).

    If you "View Image" (or the equivalent in your browser), the two images are indeed rotated with respect to each other. But on the page, within the [img src=...] tag they have the same rotation (orientation).

    I believe this is the problem the original poster alluded to.

    I found this thread when I was looking for a way to solve the "problem" of the browser deciding to orient the image within a page differently from what it looks like inside a page.

    I do not know the source of the images, but I am guessing an iPhone, but perhaps some other smartphone.

    My personal interest is just in finding out if there is something that will force the browser to not orient the image this way. I am posting in part, however, because it seems that no one in the thread bothered to actually look at an example (there seems to be a bit of denial going on -- "Who are you going to believe, me or your own eyes?"). So I provided one.

IMN logo majestic logo threadwatch logo seochat tools logo