ivpusic / react-native-image-crop-picker

iOS/Android image picker with support for camera, video, configurable compression, multiple images and cropping
MIT License
6.13k stars 1.56k forks source link

No Exif Geolocation (Latitude/Longitude) Data on iOS #751

Open dancherb opened 6 years ago

dancherb commented 6 years ago

RN 0.55.3 react-native-image-crop-picker 0.20.3

On Android I receive an exif data object that includes the following:

GPSLatitudeRef: 'N',
GPSLatitude: '38/1,54/1,3540/100',
GPSLongitude: '1/1,26/1,1920/100',
GPSLongitudeRef: 'E'

On iOS, when trying the same images and freshly taken ones (that work with another module, react-native-image-picker), no geolocation data is returned.

dancherb commented 6 years ago

@ivpusic @nico1510

drewandre commented 6 years ago

I'm also having this problem -- I see GPS data when uploading from the camera roll (with exif option enabled), but no GPS data when uploading right from the ImagePicker camera. @dancherb is this similar to the issue you are having?

BigPun86 commented 6 years ago

same here, any progress?

haifahrul commented 5 years ago

@BigPun86 @drewandre @dancherb I also found this issue, any idea to handle this?

drewandre commented 5 years ago

@haifahrul I didn't find a solution, no.

lighthx commented 5 years ago

met too

sam17896 commented 5 years ago

Any progress on this ?

gino8080 commented 4 years ago

any news? would be very usefull

dcoellarb commented 4 years ago

any updates on this?

ravisojitra commented 4 years ago

@sam17896 @gino8080 @dcoellarb @lighthx @drewandre This is how i converted it to latitude and longitude.

const convertDMSToDD = function (degrees, minutes, seconds, direction) {
    var dd = degrees + minutes / 60 + seconds / 3600;
    if (direction == "S" || direction == "W") {
        dd = dd * -1;
    }
    return dd;
};

if (item.exif) {
let latitude =
    item.exif.GPSLatitude ||
    (item.exif["{GPS}"] && item.exif["{GPS}"].Latitude);
let longitude =
    item.exif.GPSLongitude ||
    (item.exif["{GPS}"] && item.exif["{GPS}"].Longitude);

if (latitude && longitude) {
    if (
    latitude.toString().includes("/") ||
    latitude.toString().includes(",")
    ) {
    let splittedLatitude = latitude.split(",").map((d) => eval(d));
    let splittedLongitude = longitude.split(",").map((d) => eval(d));

    if (
        splittedLatitude &&
        splittedLatitude.length &&
        splittedLongitude &&
        splittedLongitude.length
    ) {
        let finalLatitude = convertDMSToDD(
        ...splittedLatitude,
        item.exif.GPSLatitudeRef
        );
        let finalLongitude = convertDMSToDD(
        ...splittedLongitude,
        item.exif.GPSLongitudeRef
        );
        if (finalLatitude && finalLongitude) {
        let selectedLocation = {
            lat: finalLatitude,
            lng: finalLongitude,
        };
        console.log(selectedLocation);
        }
    }
    }
}
}`
jvence commented 3 years ago

We're not getting any GPS info on iO using "react-native-image-crop-picker": "^0.36.0" and "react-native": "0.63.4"

I think iOS has a new method to pick a photo using PHPicker. See this blog: https://www.felixlarsen.com/blog/photo-metadata-phpickerview and assuming that location permission is on then we should be able to get the EXIF metadata

Any ideas how to get this working on IOS

jvence commented 3 years ago

I think I've solved this. If you disable cropping, you will get the GPS info. After looking at the code, I've realized that cropping creates a new image which does not include the GPS info.

alexg-93 commented 2 years ago

even when cropping is off on v0.37.3 and rn v0.67.4 the gps location is missing on IOS any solution?

chuchuva commented 1 year ago

The Geolocation data is there on iOS, it just sits under a different property:

{
  "creationDate": "1670047414",
  ...
  "exif": {
    ...
    "{Exif}": {
      ...
    },
    "{GPS}": {
      "Altitude": 2.3358781324002402,
      ...
      "Latitude": 37.87813833333333,
      "LatitudeRef": "S",
      "Longitude": 144.81051666666667,
      "LongitudeRef": "E",
      "Speed": 0.6834079021992564,
      "SpeedRef": "K",
      "TimeStamp": "00:00:00"
    },
    ...
  },
  "filename": "IMG_0007.JPG",
  ...
}

Geolocation data for the same image on Android:

{
  "exif": {
    "DateTime": "2022:12:03 17:03:33",
    ...
    "GPSAltitude": "66089/28293",
    "GPSAltitudeRef": "0",
    "GPSDateStamp": "2.2.0.0.",
    "GPSLatitude": "37/1,52/1,413/10",
    "GPSLatitudeRef": "S",
    "GPSLongitude": "144/1,48/1,1893/50",
    "GPSLongitudeRef": "E",
    "GPSProcessingMethod": null,
    "GPSTimeStamp": "00:00:00",
    ...
    "Latitude": -37.87813949584961,
    "Longitude": 144.81051635742188,
    ...
  },
  "path": "file:///data/user/0/com.trailnavigator.android/cache/react-native-image-crop-picker/IMG_5511.jpg",
  ...
}
chuchuva commented 1 year ago

This pull request should fix it: https://github.com/ivpusic/react-native-image-crop-picker/pull/1882