4

I want to read the Date and Time when a Photo was taken from the exif data of a picture.

I use this library https://github.com/exif-js/exif-js to access exif and $cordovaCamera to get the picture.

The $cordovaCamera options: (I let the user decide where the picture should come from (gallery or camera) so source can be 1 or 0:

var options = {
    quality: 60, 
    destinationType: Camera.DestinationType.DATA_URL,
    sourceType: source,
    allowEdit: false,
    correctOrientation: true,
    encodingType: Camera.EncodingType.JPEG,
    popoverOptions: CameraPopoverOptions,
    saveToPhotoAlbum: true
 };

Getting the picture:

$cordovaCamera.getPicture(options).then(function (imageData) {
    cameraSuccess(imageData);
});

And processing it:

function cameraSuccess(imageURI) {

    var imageR = new Image();
    imageR.onload = function() {
        EXIF.getData(imageR, function() {
            alert(JSON.stringify(this));
        });
    };
    imageR.src = "data:image/jpeg;base64,"+imageURI;

}

But this is the only exif data i get.

"exifdata":{  
  "Orientation":1,
  "ExifIFDPointer":38,
  "ColorSpace":1,
  "PixelXDimension":500,
  "PixelYDimension":375
},
"iptcdata":{  
}

I also tried Camera.DestinationType.NATIVE_URI to make sure that base64 is no problem.

I tested it on a ios-emulator (take image from gallery) with the above result and an android device (take image from camera) without any output.

3
  • I think instead of using exif external library you can use file plugin to get the details of file with date and time
    – Anil kumar
    Aug 31, 2015 at 12:04
  • Agree with @Anilkumar Aug 31, 2015 at 12:22
  • Well i need other exif information as well, and i don't think that i can get those with the file plugin.
    – Mazz
    Sep 1, 2015 at 8:04

2 Answers 2

3

With the following options I am currently able to POST to a server an image file containing the EXIF data (I am looking for date/time and GPS) from Android (5.1 Nexus 5). But not from iOS (8.4 iPhone 5).

    var options = {
        quality: 50,
        destinationType: Camera.DestinationType.FILE_URI,
        allowEdit: true,
        encodingType: Camera.EncodingType.JPEG,
        popoverOptions: CameraPopoverOptions,
        saveToPhotoAlbum: true
    };

It seems that, in the Camera plugin process, iOS is somehow stripping most of the EXIF data: the ones remaining are similar to yours. By the way even setting

<preference name="CameraUsesGeolocation" value="true"/>

in config.xml doesn't seem to help with GPS data. In your case I suspect then that exif-js is trying to extract data no longer existing.

Still trying to find a solution, if I have any update I will post it.

1
  • I forgot: using targetWidth and targetHeight in the options was causing Android to strip the metadata as well, so maybe is the same for correctOrientation Sep 13, 2015 at 11:18
1

This is a bug in Cordova camera plugin which strips some tags when picking the image.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.