apache / apache/cordova-plugin-camera

Cordova plugin camera get picture. metadata not found in cordova ios

Open
#884 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
Objective-C
Stars
976
Forks
1.6k
PR merge metrics
No merged PRs in 30d

Description

# Bug Report

## Problem
Cordova plugin camera get picture. metadata not found in cordova ios

### What is expected to happen?
Get metadata data when taking photos on iOS

### What does actually happen?

When I upload a photo using Android, the photo has metadata information, but when I upload a photo using iOS, there is no metadata information.
I used the exifjs library (https://cdn.jsdelivr.net/npm/exif-js) to test and the results are as follows:
android:
![image](https://github.com/apache/cordova-plugin-camera/assets/156770772/8c57d423-161f-4dfe-b043-b0221c649f73)

ios:
![image](https://github.com/apache/cordova-plugin-camera/assets/156770772/d2758c7e-a238-40b0-836c-19cb3db43aaa)

## Information
I see @erisu has committed on this issue!
I see that cordova plugin camere version 7.0.0 mentions preserving metadata on ios.
![image](https://github.com/apache/cordova-plugin-camera/assets/156770772/20783e5f-41e4-4ff6-8c1b-bf3a14c1b0d7)

### Command or Code

`

base64ToArrayBuffer: function(base64) {
base64 = base64.replace(/^data\:([^\;]+)\;base64,/gmi, "");
var binary = atob(base64);
var len = binary.length;
var buffer = new ArrayBuffer(len);
var view = new Uint8Array(buffer);
for (var i = 0; i < len; i++) {
view[i] = binary.charCodeAt(i);
}
return buffer;
},
snapPicture: function(callBack) {
navigator.camera.getPicture(successCamera, failCamera, {
destinationType: Camera.DestinationType.DATA_URL,
correctOrientation: true
});

function successCamera(base64) {
let arrayBuffer = base64ToArrayBuffer(base64Image);
let dataExif = EXIF.readFromBinaryFile(arrayBuffer);
if (dataExif && dataExif.DateTime) {
alert("Exif Date: " + dataExif.DateTime);
} else {
alert("Exif Date not found!");
}
}
function failCamera(message) {
app.preloader.hide();
}
},

`

### Environment, Platform, Device
Platform : ios: 17.4.1, ios: 16.2
Device: iphone 12, ipad gen 10

### Version information
- cordova-ios: 7.0.1
- cordova-android: 12.0.1
- cordova-plugin-camera :7.0.0
- exifjs: 2.3.0 (https://github.com/exif-js/exif-js)
## Checklist

- [x ] I searched for existing GitHub issues
- [x ] I updated all Cordova tooling to most recent version
- [x ] I included all the necessary information above

Contributor guide

Open the contributing guide

Research direction

Start at the navigator.camera.getPicture call using DATA_URL and compare how iOS and Android return photo metadata before EXIF.readFromBinaryFile processes it. Reproduce the missing DateTime result on the listed iOS versions, then verify that captured iOS photos preserve the expected EXIF metadata.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, objective-c
Domain
mobile-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.