Read EXIF orientation tag from a CameraRoll loaded image on iOS8

489 Views Asked by At

I'm working on an iOS8 iPhone app with Adobe Air and I would like to read the EXIF data for the image orientation from a CameraRoll loaded image.

I'm using this AS3 EXIF library: https://github.com/bashi/exif-as3 The provided example works for images that got loaded through an URLRequest but not for CameraRoll loaded images. (trace for EXIF = null)

This is my code:

import jp.shichiseki.exif.*;

var loaderCameraRoll:ExifLoader 
var deviceCameraRoll:CameraRoll

function loadImageFromCameraRoll(e:Event=null):void {
deviceCameraRoll = new CameraRoll();
deviceCameraRoll.addEventListener(MediaEvent.SELECT, onSelectCameraRoll);
deviceCameraRoll.browseForImage();
}

function removeBrowseListeners():void {
deviceCameraRoll.removeEventListener(MediaEvent.SELECT, onSelectCameraRoll);
}

function onSelectCameraRoll(event:MediaEvent):void {
var promise:MediaPromise = event.data as MediaPromise;
loaderCameraRoll = new ExifLoader() 
loaderCameraRoll.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoadedCameraRoll);
loaderCameraRoll.loadFilePromise(promise);      
}

function onLoadedCameraRoll(event:Event):void {
trace(loaderCameraRoll.exif.ifds.primary)
}

How to get the EXIF orientation value from a CameraRoll loaded image?

2

There are 2 best solutions below

0
On

try using a Native Extenson this is a great option:

https://github.com/digicrafts/ANE-ImagePicker

if (AirImagePicker.getInstance().isCameraAvailable())
{
    AirImagePicker.getInstance().displayCamera(function(status:String, ...mediaArgs):void {
        // Do something with the Media information returned
    });
}

// Pick an image from the gallery
if (AirImagePicker.getInstance().isImagePickerAvailable())
{
    AirImagePicker.getInstance().displayImagePicker(function(status:String, ...mediaArgs):void {
        // Do something with the Media information returned
    });
}
0
On

Jay, I found a article that solved your problem perfectly, which works on both iOS and Android.

http://blogs.adobe.com/cantrell/archives/2011/10/parsing-exif-data-from-images-on-mobile-devices.html

And in the same time, I would like to ask you a question about uploading files from Air on iOS device. Did you try to upload the image file to somewhere? If you did, Which version of iOS and which version of Air SDK are you using? Did you do some configuration in the xxx-app.xml file?

I tried the solution in

www.adobe.com/devnet/air/articles/uploading-images-media-promise.html 
, but the File.upload(URLRequest) did not work on iOS8. File.upload did not even send any request to the server side. It seems that the Air SDK for iOS just failed to send the http request for some reason.

You can go to the following link to see my problem about this.

ActionScript's File.upload does not work on Air SDK for iOS devices

My sample code is uploaded to github.

github.com/bluewindjava8/actionscript_file_upload_for_ios

Will you please check it for me if you have time. And will you please send me your code if it is ok? Thank you very much.