4
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Flutterのimage_pickerで取得した画像の位置情報を知るには

Last updated at Posted at 2021-04-04

全体の流れ

  1. image_picker で画像のパス取得
  2. 取得したpathから exifで画像のメタデータを取得
  3. その中に位置情報が(保存されてれば)入ってるのでそっから取る

サンプル

コピペで使えます

import 'dart:io';

import 'package:image_picker/image_picker.dart';
import 'package:exif/exif.dart';

Future printImageGPS() async {
  final pickedFile = await ImagePicker().getImage(source: ImageSource.gallery);
  final tags = await readExifFromBytes(await File(pickedFile.path).readAsBytes());
  print('latitudeRef: ${tags['GPS GPSLatitudeRef']}');
  print('latitude: ${tags['GPS GPSLatitude']}');
  print('longitudeRef: ${tags['GPS GPSLongitudeRef']}');
  print('longitude: ${tags['GPS GPSLongitude']}');
}

結果

flutter: latitudeRef: N
flutter: latitude: [35, 28, 3031/100]
flutter: longitudeRef: E
flutter: longitude: [138, 40, 17/25]
4
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?