Reputation: 1879
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.
Upvotes: 4
Views: 2596
Reputation: 4926
This is a bug in Cordova camera plugin which strips some tags when picking the image.
Upvotes: 1
Reputation: 324
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.
Upvotes: 3