angularjs - 是否可以使用 ng-file-upload 读取图像的地理位置?
问题描述
我想知道,是否可以使用 ng-file-upload 库读取附加到图像文件的 Exif 元数据以读取地理位置。
有一些选项(例如 ngf-fix-orientation)可以使用 Exif 对象的元数据。但是,选择文件后,它不再包含任何 exif 信息。
我试过了:
ngf-before-model-change="beforeChange($files)"
和:
$scope.beforeChange = function(files){ console.log('BeforeChangefiles', files); };
结果如下:
0: File name: "IMG_5277.JPG" lastModified: 1559123113000 lastModifiedDate: Wed May 29 2019 11:45:13 GMT+0200 (Mitteleuropäische Sommerzeit) {} webkitRelativePath: "" size: 3741545 type: "image/jpeg" $ngfBlobUrl: "blob:http://localhost/630d0c34-07a1-4f41-81fd-e2cf021cbf65" $ngfWidth: 4032 $ngfHeight: 3024
此时 Exif 信息似乎已经丢失。
是否有可能在 exif 信息丢失之前访问它?
如果没有,推荐哪些解决方法?
解决方案
JPEG 可能包含嵌入的 EXIF 段,其中可能包含 GPS 坐标。它们很容易提取。尽管我不推荐 exif-js,因为它已经多年无人维护,存在没有人回应的错误和堆积问题。
我会推荐exifr,它也可以很好地将 GPS 转换为简单值(以原始形式存储在 4 个单独的标签中)
// fancy async syntax
let {latitude, longitude} = await exifr.gps('./myimage.jpg')
// older promise syntax
exifr.gps(arrayBuffer).then(gps => {
console.log(gps.latitude, gps.longitude)
})
输入可以是任何东西。URL、ArrayBuffer、Blob 等...
推荐阅读
- php - 如何遍历文件夹和子文件夹并使用 Laravel 创建?
- javascript - Node.js - How to create a request which can access the url before the root path "/'
- python - 在二维列表中查找最常见的字符串
- python - 我如何在 django 中运行特定的迁移部门
- python - 如何在聊天机器人 python-flask 中返回空响应?
- android - Videoview 在三星设备中仅适用于某些视频
- react-native - react-native 透明覆盖暴露一些组件
- plsql - 返回批量收集的问题。代码出现错误
- php - 如何使复选框被选中和禁用?
- algorithm - Lua 创建的快速排序无法正常工作