Skip to content Skip to sidebar Skip to footer

Adobe AIR CameraUI Photo Orientation

Im having some issues some Android devices when trying to take a photo using CameraUI class. My AIR app is portrait only autoOrients = false, but for some reason, when taking a pho

Solution 1:

While this is annoying, it is actually intended functionality. I used the ExifReader class described here to determine the orientation and then rotate it the correct direction before saving the file to disk.


Solution 2:

Androids camera images has built in information like GPS location, Orientation and more information named Exchangeable Image File (Exif). When you capture an image, it will save with those information in the jpg file but the image may save in an unexpected orientation on drive.

So, this the solution:

1- Add an Exif encoder library to your project like this one: https://github.com/cantrell/ExifExample 2- Use something like this function to control the Image orientation after loading the image bytes:

       /**1: normal<br>
        3 rotated 180 degrees (upside down)<br>
        6: rotated 90 degrees CW<br>
        8: rotated 90 degrees CCW<br>
        9: unknown<br>
        */
    public static function getOrientation(ImageBytes:ByteArray):uint
    {
        var exif:ExifInfo = new ExifInfo(ImageBytes);
        if(exif.ifds != null)
        {
            var ifd:IFD = exif.ifds.primary ;
            var str:String = "";
            for (var entry:String in ifd) {
                if(entry == "Orientation"){
                    str = ifd[entry];
                    break;
                }
            }
            return uint(str);
        }
        else
        {
            return 9 ;
        }
    }

Post a Comment for "Adobe AIR CameraUI Photo Orientation"