Monday, July 29, 2013

Why my image is rotated?

When you take a picture using iPhone, there are 4 possible orientation, namely 1, 3, 6, 8. The most common values are 1 (landscape) and 6 (portrait).

When you take a picture holding iPhone in portrait mode, the image orientation will be 6. In iOS and Mac OSX, most softwares (applications) recognize this orientation Flag and display image correctly on screen. It seems windows 7 does the same thing (not fully test).
The original image was saved in a "Rotated 90 CCW" (back to Camera View with orientation 1) , so when display this image, we need rotate 90 clockwise (reverse the CCW).

This behavior is true in preview, browsers etc. However, there is a difference in browsers, if I refer the image directly (file:///Users/jimz/Downloads/1323-bike-rotate.jpeg), it is auto-rotated clockwise 90 degree. If I refer the image using <img src="1323-bike-rotate.jpeg"> in HTML, it is not auto-rotated, so in html image, it is displayed in original format which is 90 degree rotated counter-clockwise. This is the reason why my image is rotated from UI viewpoint.


No comments:

Post a Comment