[whatwg] Add "naturalOrientation" property to <img>
Tab Atkins Jr.
jackalmage at gmail.com
Fri Aug 26 08:37:34 PDT 2011
The <img> element should expose a readonly "naturalOrientation"
property that returns the EXIF orientation of the image (an integer
1-8), or 1 if the image has no EXIF orientation metadata or it is
corrupted or the image type doesn't expose EXIF data at all.
Some cameras (sometimes automatically, sometimes through an option)
record the orientation of the camera when a picture was taken. This
data is used by many image-viewing programs to auto-rotate the image
to its "correct" orientation. For example, if you take a picture of
the Eiffel Tower by holding your camera sideways to get more vertical
distance, you'd prefer the Tower to be vertical when you view it, not
pointing to the side like the raw image data would have you believe.
(Why do cameras express this as metadata instead of just rotating the
image data directly? CCDs tend to stream the image data in row-major
format. If you need to buffer the entire image before storing it so
you can do a rotation first, this may negatively affect performance in
terms of shots/second. I dunno if this is still an issue with modern
hardware, but it apparently was with early digital cameras.)
A more thorough explanation of the EXIF orientation can be found at
Webapps that manipulate images need to have the ability to tell when
an image should be rotated before being displayed, like desktop
image-manipulation software has. The only way to do so currently is
to parse the binary data of the image and extract the EXIF metadata
yourself. We can make this reasonably common need much easier by
exposing it directly.
The Google Gears API exposed this data for webpages already
according to the team, it was useful there.
More information about the whatwg