Как добавить данные exif к фото на android

Im using react-native-camera to take a picture. In the options i added the coordinates (this works) and 'ImageDescription'. But 'ImageDescription' doesn't appear when logging response. Then i'm using react-native-exif to read exif data of the file. (I think the problem is caused by api level not setting correctly, because the properties that i get are below api level 9) My code:

        const takePhoto = async () => {
    let exifData = {};

    if(geoCoordinates.lat && geoCoordinates.lng){
      exifData = { 
        GPSLatitude: geoCoordinates.lat, 
        GPSLongitude: geoCoordinates.lng ,
        GPSAltitude: geoCoordinates.altitude,
        ImageDescription: "Here is description"
      };
    }

    const options = { quality: imageQuality , writeExif: exifData};
    const data = await takePicture(options);
    
    Exif.getExif(data.uri)
    .then(msg => console.log('OK: ' + JSON.stringify(msg)))
    .catch(msg => console.log('ERROR: ' + msg));
  };

LOG:

      OK: {"ImageWidth":1280,"ImageHeight":720,"Orientation":6,"originalUri":"/data/user/0/com.appmobile/cache/Camera/a2920351-9fa0-4254-baf0-44cab3ba7231.jpg","exif":{"originalUri":"/data/user/0/com.appmobile/cache/Camera/a2920351-9fa0-4254-baf0-44cab3ba7231.jpg","WhiteBalance":"0","SubSecTimeDigitized":"0","Orientation":"6","Make":"Google","ISOSpeedRatings":"100","ImageWidth":"1280","SubSecTime":"0","GPSLongitude":"*longitud*","ImageLength":"720","GPSTimeStamp":null,"ExposureTime":"0.01","FocalLength":"5000/1000","GPSLatitudeRef":"N","GPSDateStamp":null,"GPSAltitudeRef":"0","GPSLatitude":"*latitude*","SubSecTimeOriginal":"0","GPSLongitudeRef":"W","DateTime":"2021:06:08 16:14:54","GPSAltitude":"0/10000","Flash":"0","GPSProcessingMethod":null,"Model":"sdk_gphone_x86","DateTimeDigitized":"2021:06:08 16:14:54","FNumber":"2.8"}}

Extra Information:

android/build.gradle:

  • buildToolsVersion = "29.0.2"
  • minSdkVersion = 25
  • compileSdkVersion = 29
  • targetSdkVersion = 29

package.json:

  • "react": "16.13.1",
  • "react-native": "^0.63.4",
  • "react-native-camera": "git+https://git@github.com/react-native-community/react-native-camera.git",
  • "react-native-exif": "^0.4.0",

0 ответов

Другие вопросы по тегам