

"My images are all upside down" - digitalpbk
http://www.gigpeppers.com/my-images-are-all-upside-down/

======
micampe
_“Because your crop and scale function ignores and drops the EXIF orientation
tag.”_

------
route3
During the holiday break I spent some time learning about EXIF data and
subsequently released Exif.in[0], a simple HTTP API for viewing EXIF data
inside images and requesting EXIF-stripped copies as well.

If you're a developer who needs to occasionally inspect EXIF data from user
uploads, please check it out. Contact me if you have additional questions, I'm
happy to help.

[0] <http://exif.in>

~~~
edent
Really useful! Thanks. Have you seen <http://regex.info/exif.cgi>

------
rem1313
What puzzles me is that Windows XP up to Windows 7 built-in picture viewer
does not support proper orientation of iPhone photos with the original EXIF
metadata in place. Picasa (on Windows) handles that perfectly, as well as
(obviously) all apps in OS X. What the hell Microsoft? Is this a political
thing or is there a valid technical reason?

~~~
smackfu
Here's my guess as to why it would work like that. Random software package
either supports the EXIF orientation or it doesn't. If it doesn't, Joe User
just sees the photo rotated wrong, and they want to fix it. Joe knows he can
rotate photos in Windows Picture Viewer. So he opens the file in Windows
Picture Viewer and it ignores the EXIF orientation too, so he just hits rotate
then goes about his business. If Windows Picture Viewer respected the EXIF
orientation, it would be much less useful for this task.

Given that, OS X Preview has a different approach. It respects the EXIF
orientation when you open a file, but when you re-save a file, it silently
rotates the file and resets the orientation. Not sure if that is better or
worse.

------
smackfu
There are a lot of sites that throw away the EXIF orientation tag when
resizing photos. It's very obvious now that you can upload directly from the
iPhone.

------
Steuard
There's a lot of discussion of what's behind this issue in the Mozilla feature
request at <https://bugzilla.mozilla.org/show_bug.cgi?id=298619>, and more at
the corresponding webkit (<https://bugs.webkit.org/show_bug.cgi?id=19688>) and
chromium (<http://code.google.com/p/chromium/issues/detail?id=56845>) bug
trackers.

The concern is essentially that there may be many images on the web that have
EXIF tags that don't match how those images are being used, specifically
because the sites were tested in browsers that ignore the tags. So changing
browser behavior now could suddenly break lots of sites that previously looked
fine. It sounds like nobody has come up with a good solution yet.

------
cyriacthomas
What is the case when the photos are taken from a vertically up position? What
orientation does it take? For eg: [https://fbcdn-sphotos-
f-a.akamaihd.net/hphotos-ak-ash3/54392...](https://fbcdn-sphotos-
f-a.akamaihd.net/hphotos-ak-ash3/543929_10151252345763985_905957976_n.jpg)

Just curious. I'm sure many food photographers will try that position too.

~~~
micampe
The EXIF orientation tag encodes all orientations:
<http://www.impulseadventure.com/photo/exif-orientation.html>

~~~
brasic
It only encodes orientations that result from rotation around the axis
perpendicular to the line of sight (in other words, the rotations that can be
reversed by display software). Parent was asking about the orientation with
camera above the subject pointing directly down. I don't think EXIF can encode
that -- there's no reason to, since display software has no way to reverse it.

~~~
micampe
Well, photographs are two dimensional.

------
jstanley
What the hell? Why is there an orientation tag at all? Why isn't the picture
just rotated by the device that takes it?

~~~
micampe
Because lossless rotation is fairly expensive computationally so digital
cameras have been leaving that job to a computer.

~~~
jonknee
In this case the camera is a computer though. A computer that knows its
orientation.

~~~
CountHackulus
Not to mention that it's rotating by +-90 or 180 degrees, which is a whole lot
faster than an arbitrary rotation.

------
nithinbekal
I ran into the exact same problem a few days ago. Luckily, ImageMagick, which
I'm using for processing uploaded images, has an auto-orient [1] option that
allows you to do this automatically.

Unfortunately, with JPEG this would cause some loss of quality, so we're
probably going to have to keep the original quality image as well as the auto-
orient'ed image to display on the site. Has anyone here worked on something
similar? Any ideas on a better way to handle this would be extremely helpful.

[1] [http://www.imagemagick.org/script/command-line-
options.php#a...](http://www.imagemagick.org/script/command-line-
options.php#auto-orient)

~~~
smackfu
Because of _math_ , the JPEG format does support lossless rotation, as long as
the dimensions of the image are multiples of 16 pixels (or 8 depending on the
file). But this requires working directly with the JPEG image data, so a
package like ImageMagick that reads a formatted file into a pixel buffer, then
transforms it and writes it from that buffer to a new formatted file can't
support the feature.

------
nextstep
Speaking of iPhones, this blog is pretty much unreadable on Mobile Safari. I
side scroll to see the text; the paragraph disappears behind the left sidebar.

~~~
vilgax
Showing up correctly on Mobile Safari on iPad.

------
gfosco
Had this same issue with a service that consumes pictures from
iOS/Android/BlackBerry. They all seem to handle it in different ways. I added
a similar EXIF check and a quick rotation when necessary. I should have
written a blog post about it. :)

------
ianstallings
This would be easier to fix in objective-c and a little custom camera wrapper
application. I would expect a fix in a new OS release though. But if you need
this little app let me know and I'll write it and put it on github.

~~~
5teev
If your app directly accesses the camera with AVFoundation, saving photos is a
lot less automatic than you might expect. It's easy to save the raw image data
but you have to generate and add just about any interesting metadata (EXIF,
GPS, TIFF, etc.) explicitly. It's hard to do right--as the rather many
discussions on StackOverflow suggest--and definitely a steep price to pay for
a customized camera interface.

~~~
ianstallings
It's not that hard actually, it's just tedious. The easiest way to do it is
use the CIImageProperties
([http://developer.apple.com/library/mac/#documentation/Graphi...](http://developer.apple.com/library/mac/#documentation/GraphicsImaging/Reference/CGImageProperties_Reference/Reference/reference.html))

The better way though is to use a class like this:
[https://github.com/gpambrozio/GusUtils/blob/master/GusUtils/...](https://github.com/gpambrozio/GusUtils/blob/master/GusUtils/NSMutableDictionary+ImageMetadata.m)

I see your point though - it's not trivial. I just happen to have a lot of
experience in this area. I do a lot of video/imaging on the iphone.

