cloudacy / native_exif

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

GPS coords not decoded when on mobile network #8

Open capriele opened 1 year ago

capriele commented 1 year ago

Good evening to everyone, I'm using the following code to get an image from a remote address but a strange behaviour happens: If the code is executed when the device is connected to a wireless network all it is working fine; otherwise if I use the normal 4g/5g network it simply doesn't work.

Could you give me some suggestion? I'm using the latest version of this plugin (native_exif: ^0.4.0).

From my side I can say that:

P.S. url = "http://65.108.239.148/verdeco/allegati/commesse/4107/223005/9_4107.jpg"

import 'package:http/http.dart' as http;
import 'package:path_provider/path_provider.dart' as path_provider;
import 'package:path/path.dart' as path_instance;

Future<ExifLatLong?> getImageCoords(String url) async 
{
    // Get image from url
    final response = await http.get(Uri.parse(url));

    // Get the image name
    final imageName = path_instance.basename(url);

    // Get the document directory path
    //final appDir = await path_provider.getApplicationDocumentsDirectory();
    final appDir = await path_provider.getApplicationSupportDirectory();

    // This is the saved image path
    // You can use it to display the saved image later
    final localPath = path_instance.join(appDir.path, imageName);

    // Downloading
    final imageFile = File(localPath);
    await imageFile.writeAsBytes(response.bodyBytes);

    // Extract exif
    var exif = await Exif.fromPath(localPath);
    var coords = await exif.getLatLong();
    await exif.close();
    await imageFile.delete();
    return coords;
  }
d-kuen commented 1 year ago

Hi,

what platform do you use? android or iOS?

getLatLong uses 4 GPS attributes. Did you compare the getAttributes output? GPSLatitude, GPSLatitudeRef, GPSLongitude and GPSLongitudeRef must be available.

mohyM commented 1 year ago

i am using Samsung device to capture the image I can't find the lat/long on meta data of the image @d-kuen