Recently I’ve been working a lot on iPad using Adobe AIR, which is really good to quickly create iOS applications, but of course it has it’s limitations.
One of these is that when you shoot a picture using CameraUI, and you rotate your iDevice, your image comes out rotated.
How can you find out the device orientation in order to adjust the picture rotation?
The answer resides in the EXIF metadata! Actually, EXIF data contains a whole bunch of hidden information about your file, including an “Orientation” tag that can have 5 different values:
- 1 – LANDSCAPE
- 3 – LANDSCAPE_REVERSE
- 6 – PORTRAIT
- 8 – PORTRAIT_REVERSE
- 9 – UNKNOWN
So, once you have this value, you just need to rotate your Bitmap, or BitmapData, or whatever you have, according to this value and to the current device orientation. I want to use my situation as an example:
- You have an iPad application running in Landscape mode.
- Your application launches CameraUI to take a photo.
- You rotate your iPad in LANDSCAPE mode and shoot the photo.
- Your app closes the CameraUI and goes back to Landscape mode.
In this case, the picture you have just taken will appear rotated by 90 degrees!
So, how do you get the orientation value???