react-native-exif
react-native-exif copied to clipboard
Exif.getExif() callback are not called
i get a bug on IOS , on android it work ( logs are displayed ) my problem is the getExif() don't call the callback, nothing happen.
my test code :
import ImagePicker from "react-native-image-crop-picker"; // version "^1.2.2"
import Exif from "react-native-exif"; // version "0.1.5"
testfromlib(){
ImagePicker.openPicker({
width: 300,
height: 400,
cropping: false
}).then(image => {
console.log(image); // this log me the image object :
/* log this :
data : null
exif : null
filename : "IMG_0338.JPG"
height : 3264
localIdentifier : "7388B8DC-A2B6-4ECD-B02E-7EC3432AECBC/L0/001"
mime : "image/jpeg"
path : "/private/var/mobile/Containers/Data/Application/27EA2F8F-039F-400F-B32A-836768451015/tmp/react-native-image-crop-picker/9AEA097A-6989-4D02-A775-FCF7E64D2747.jpg"
size : 8499929
sourceURL : "file:///var/mobile/Media/DCIM/100APPLE/IMG_0338.JPG"
width : 2448
*/
console.log("exif from "+ image.sourceURL);
// log this : "exif from file:///var/mobile/Media/DCIM/100APPLE/IMG_0338.JPG"
Exif.getExif(image.sourceURL)
.then(msg => {
console.log("selected image exif", msg); // NOT LOGGED !
}).catch(msg => console.log("ERROR: " + msg)); // NOT LOGGED !
});
}
from camera roll it work :
testfromcamera(){
ImagePicker.openCamera({
width: 300,
height: 400,
cropping: false
}).then(image => {
console.log("exif from "+ image.path);
//log this : exif from /private/var/mobile/Containers/Data/Application/27EA2F8F-039F-400F-B32A-836768451015/tmp/react-native-image-crop-picker/EF3F7E1D-DE76-4D48-9C5A-AB80608095E1.jpg
Exif.getExif(image.path)
.then(msg => {
console.log("selected image exif", msg); // log is displayed
}).catch(msg => console.log("ERROR: " + msg));
});
}
what i'm trying to do is
- to let user to choose between taking a new shoot with camera or loading one from gallery,
- get the exif of the image
- crop the image
did i miss something in the testfromlib function ?
i solved the problem by using only imagePicker , they add exif in last version
openCameraCropper(){
ImagePicker.openCamera({
includeExif:true,
cropping: true,
width: 300,
height: 400,
compressImageMaxWidth: 900,
compressImageMaxHeight: 900,
compressImageQuality: 0.72
}).then(image => {
this.processDataImage(image);
});
}
openPickerCropper(){
ImagePicker.openPicker({
includeExif:true,
cropping: true,
width: 300,
height: 400,
compressImageMaxWidth: 900,
compressImageMaxHeight: 900,
compressImageQuality: 0.72
}).then(image => {
this.processDataImage(image);
});
}
processDataImage(image) {
console.log("process image 1",image);
this.setState({
currentProcessedImage: {
uid: tools.generateUUID(),
uri: image.path,
exif:image.exif,
id: this.state.imagesToSend.length
},
modalOrganeVisible: true
});
}
This is still a problem with the react-native-exif library - I can't use image-picker and do want this to work on iOS, please re-open! @alainib
Seems like it's called on the simulator when I slice out the "file:///"" at the start of a path, but not on my device. Seems like if it fails for whatever reason, it doesn't return an error but is just silent. @francisco-sanchez-molina
I'm having this same issue. Also works on the simulator (and strangely my iPhone X, but not any other iPhones). No error but doesn't call the callback. I've tried with promise and async/await. Any solutions?
I fixed this issue in my branch (PR #33) with a new method getExifWithLocalIdentifier(). There was a permission issue with getting the photo using the local path. It only showed up on some phones. The new method should work for all iOS phones though. It uses the local identifier of the photo instead of the source URL/path, if you have that available (which if your using react-native-image-crop-picker or react-native-image-picker, you should).