react-native-exif icon indicating copy to clipboard operation
react-native-exif copied to clipboard

Exif.getExif() callback are not called

Open alainib opened this issue 7 years ago • 5 comments

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

  1. to let user to choose between taking a new shoot with camera or loading one from gallery,
  2. get the exif of the image
  3. crop the image

did i miss something in the testfromlib function ?

alainib avatar Oct 03 '17 09:10 alainib

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
    });
  }

alainib avatar Oct 03 '17 10:10 alainib

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

dancherb avatar Jul 03 '18 17:07 dancherb

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

dancherb avatar Jul 04 '18 12:07 dancherb

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?

jtweaver avatar Jul 11 '18 03:07 jtweaver

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).

jtweaver avatar Jul 18 '18 17:07 jtweaver