cloudacy / native_exif

A simple EXIF metadata reader/writer for Flutter.
MIT License
16 stars 15 forks source link

Exif detail GPS(Latitude,Longitude) not working for iOS in Flutter but it's working fine in Android. #2

Closed vishnuP-Lepton closed 2 years ago

p-kuen commented 2 years ago

Thank you for submitting this issue. Can you please provide further information about what is "not working". Please use the issue description for that. Thanks!

vishnuP-Lepton commented 2 years ago

Hi there,

Thanks for the response

I am using image_picker: ^0.8.4+3 and native_exif: ^0.1.1 when I upload the image from Camera in Android device its showing the GPS_Latitude and GPS_Longitude in exif detail but same code are not working for iPhone device

my code is

  void getExif(String imagePath) async {
    final exif = await Exif.fromPath(imagePath);
    final _attributes = await exif.getAttributes();
    repository.isIndicatorHide(true);
    await CommonUtils().getCurrentLatLng().then((currentPosition) async {
      if (currentPosition != null) {
        print(" before attribute = ${_attributes['GPSLatitude']}");
        print(" before attribute = ${_attributes['GPSLongitude']}");
        String radianLatLng =
            Run(currentPosition.latitude, currentPosition.longitude);
        List<String> lstradianLatLng = radianLatLng.split(" ");
        _attributes['GPSLatitude'] = lstradianLatLng[0];
        _attributes['GPSLongitude'] = lstradianLatLng[1];
        await exif.writeAttributes(_attributes);
        var attributes = await exif.getAttributes();
        print(" after attribute = ${attributes['GPSLatitude']}");
        print(" after attribute = ${attributes['GPSLongitude']}");
        print(attributes);
        cameraImage();
      }
    });
  }
vgribok commented 2 years ago

I ran into the same issue on iOS with physical device (not tested on Android) - added attributes not getting saved.

I cloned this repo and found that the "Update date attribute and add new attribute" does not do anything - the 'ImageUniqueID' does not get written and no error reported.

The "Create file and write exif data" seems to be working. However, after copying it verbatim to my own project, writing attribute was not working - no error but retrieving attributes results in the original set of attributes and no error indication.

vgribok commented 2 years ago

I found that user comment metadata gets written, while GPS metadata does not. Looking at another implementation (in Objective-C), it appears GPS metadata can be written with another, GPS-specific dictionary of the metadata. Since this implementation uses only metadata["{Exif}"] throughout, I bet writing GPS Exif was never tested.

d-kuen commented 2 years ago

native_exif didn't support GPS attributes on iOS devices. The referenced commit adds this feature (included in Version 0.2.0).

We also removed the ImageUniqueID example. Thanks for noting this.

Only specific EXIF and GPS attributes can be read or written on each platform. Please have a look at the updated README file for more details.

vishnuP-Lepton commented 2 years ago

@vgribok & @d-kuen Thanks for response,

        I found that in read me file that iOS also support exif & GPS which should be specific case.

https://user-images.githubusercontent.com/90191642/180699178-29804c1c-6aec-4309-a3c7-bfa2c4c674bd.png

      Let me know what are specific GPS attribute are supported in iOS.
d-kuen commented 2 years ago

You should be able to use all keys, listed at https://developer.apple.com/documentation/imageio/gps_dictionary_keys. Please make sure to use the resolved values and prefix them with GPS. The resolved values may be the same as the part after kCGImagePropertyGPS but I didn't check all of them.