簡體   English   中英

如何將 gps 數據添加到圖像,flutter image_picker Android

[英]how to add gps data to image, flutter image_picker Android

沒有 gps 數據添加到 flutter image_picker 圖片

final pickedFile = await imagePicker.getImage(source: ImageSource.camera);
final bytes = await pickedFile.readAsBytes();
final tags = await readExifFromBytes(bytes);
print("Tags : $tags ");

標簽:(無Gps數據)

{Image ImageWidth: 4624, Image Model: Redmi Note 8 Pro, Image ImageLength: 3472, Image Orientation: Rotated 90 CW, Image DateTime: 2020:11:15 18:15:14, Image ExifOffset: 142, Image Make: Xiaomi, EXIF FNumber: 189/100, EXIF FocalLength: 543/100, EXIF ExposureTime: 50003/1000000, EXIF Flash: Flash did not fire, EXIF ISOSpeedRatings: 3750, EXIF ExifImageLength: 3472, EXIF ExifImageWidth: 4624, EXIF ApertureValue: 46/25, EXIF ShutterSpeedValue: -431/100, EXIF SubSecTime: 530}

順便說一句,它沒有要求我在拍照時允許位置(第一次),我是否必須添加任何權限?

  1. 如果您需要圖像位置庫和相機,請參閱此鏈接。

是否可以從圖像中獲取圖像 GPS 的位置坐標?

或者,如果這適合您,我也有一個客戶選項。

  1. 如果只需要在您的應用程序打開的相機圖片圖像時的位置,

使用簡單的方法,例如

File _image; 
final picker = ImagePicker();

 Future getImage() async { 
final pickedFile = await picker.getImage(source: ImageSource.camera);

 setState(() {
 if (pickedFile != null) {

// your will take user location  at this time
 _image = File(pickedFile.path); 
    }
 else { 
    print('No image selected.');
    }
 }); 

這是我們用來添加 GPS 信息的內容:

      final picker = ImagePicker();

      picker.getImage(source: ImageSource.camera).then((pickedFile) async {
        var myImagePath = coreNotifier.myCurrentPath.absolute.path;

        final exif =
            dd.FlutterExif.fromBytes(await pickedFile!.readAsBytes());

        Position position = await _determinePosition();

        await exif.setLatLong(position.latitude, position.longitude);
        await exif.saveAttributes();

        final modifiedImage = await exif.imageData;
        var imageName = "imgName..";
        File imageFile = new File("$myImagePath/$imageName.jpg");
        imageFile.writeAsBytes(
          List.from(modifiedImage!),
        );
        coreNotifier.reload();
      });

也使用這個包:

import 'package:geolocator/geolocator.dart';
import 'package:flutter_exif_plugin/flutter_exif_plugin.dart' as dd;

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM