Yes, you do need to read the EXIF. There has been a nice discussion about it @Adobe forum, let me see if I can still find it... Here it is: http://forums.adobe.com/thread/875157 Read the steps in that thread you have to make to make this work on iOS!
Let me point out an important issue as the "final" implementations in that thread are not exactly bulletproof (I am not sure whether there is some new info there, I won't go through it now, too long):
Note the constructor of ExifInfo returns if the stream is not validated:
public function ExifInfo(stream:ByteArray) {
if (!validate(stream)) {
return;
}
_tiffHeader = new TIFFHeader(stream);
readIFDs(stream);
readThumbnail(stream);
}
Therefore you need to check whether there exists an ifds
object in the exif instance. If you don't do this check, you will be thrown a null pointer exception. You could use something like this:
public static function getImageOrientation(imageData:ByteArray):String {
var exif:ExifInfo = new ExifInfo(imageData);
var ifd:IFD;
var str:String = "";
if(exif.ifds) { //happens only if there is info
ifd = exif.ifds.primary;
for (var entry:String in ifd) {
if(entry.toLowerCase() == "orientation"){
str = ifd[entry];
break;
}
}
}
switch(str) {
case "1": //normal
str = ImageOrientation.NORMAL;
break;
case "3": //rotated 180 degrees (upside down)
str = ImageOrientation.UPSIDE_DOWN;
break;
case "6": //rotated 90 degrees CW
str = ImageOrientation.ROTATED_LEFT;
break;
case "8": //rotated 90 degrees CCW
str = ImageOrientation.ROTATED_RIGHT;
break;
case "9": //unknown & fall-thru
default:
str = ImageOrientation.UNKNOWN;
break;
}
return str;
}
EDIT: If you had some problems implementing it, leave a comment and I will post the complete code. But it is understandable from the thread I mentioned.