RESOLVED DUPLICATE of bug 19688 50847
EXIF orientation in JPEG
https://bugs.webkit.org/show_bug.cgi?id=50847
Summary EXIF orientation in JPEG
Cosmin Truta
Reported 2010-12-10 14:55:55 PST
This is a request from a Chromium user. Most digital cameras and even camera phones store JPEG images in a predefined format (typically landscape) and then set the EXIF orientation flag. That flag should not be ignored; otherwise, the image may be displayed sideways or upside-down. http://code.google.com/p/chromium/issues/detail?id=56845 The orientation flag is found at offset 0x112 within the EXIF marker, and occupies 2 bytes, according to exiftool's documentation: http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/EXIF.html A more detailed explanation, showing all the 8 possible orientations, and accompanied by sample code, is available here: http://sylvana.net/jpegcrop/exif_orientation.html This can be implemented in WebCore/platform/image-decoders/jpeg/JPEGImageDecoder.cpp as follows: Read the EXIF marker, extract the two bytes of interest, then populate the pixel data according to the orientation flag. There are 8 possible orientations. Care must be taken when calling setSize: the width and the height stay the same for the orientation values 1,2,3,4, and they are swapped for the values 5,6,7,8. More EXIF flags can be interpreted later, if the need arises, but for the time being, a check for the EXIF marker, followed by the extraction of endianness and orientation field from the EXIF segment (and perhaps some elementary checks to ensure that it looks like a legitimate EXIF segment) should be sufficient. I see no need for a full-blown parsing of the EXIF stream.
Attachments
Alexey Proskuryakov
Comment 1 2010-12-10 21:44:00 PST
*** This bug has been marked as a duplicate of bug 19688 ***
Alexey Proskuryakov
Comment 2 2010-12-10 21:45:44 PST
This differs from bug 19688 slightly in that in addition to cross-platform changes, it discusses changes to image-decoders. But there doesn't seem to be a practical reason to track this separately at this point.
Note You need to log in before you can comment on or make changes to this bug.