[英]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}
順便說一句,它沒有要求我在拍照時允許位置(第一次),我是否必須添加任何權限?
或者,如果這適合您,我也有一個客戶選項。
使用簡單的方法,例如
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.