I have got an app which includes image_picker to allow the user to choose an image from their gallery or take a photo directly within the app. I need the photo to contain location data so I need the GPS GPSLatitude tag to be inside of the metadata of the image. When taking a photo just before inputting it through the gallery, the location data is saved to the metadata - whereas taking a photo in app does not contain location despite the setting save location being enabled on my devices camera settings.
Essentially, the code I am using is very simple; using the exif library to get metadata along with image_picker. Code is below:
var image = await picker.pickImage(source: ImageSource.camera);
var metadata = await readExifFromBytes(File(image.path).readAsBytesSync());
// check for gps tag
if (metadata.containsKey('GPS GPSLatitude')) {
print("location enabled");
else{
print("location disabled");
};
It will always print location disabled when using camera to get image, but when using gallery with a recent image - it will print location enabled The device I am using is a Xiaomi Redmi Note 8T running on android version 10.