使用Google Apps脚本从上传的图片中获取地理标记? [英] Fetch geotag from uploaded images with Google Apps Script?

查看:84
本文介绍了使用Google Apps脚本从上传的图片中获取地理标记?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个想法:目前我有一个脚本,用于监视从智能手机或标签上传到特定文件夹的新图像。该脚本根据图像名称将图像移动到某个子文件夹,并将相应的数据附加到特定的电子表格。



是否可以从上传到Google云端硬盘映像中获取地理位置信息(使用智能手机)将它们放到电子表格中?通过API搜索,但看看没有原生功能。任何第三方解决方案?使用GAS完成您的任务(获取上传图像的地理数据)是可能的(可能的解决方案)

。没有GAS服务正在执行它,我几乎可以肯定,现在没有适合您的任务的第三方解决方案。这个任务的简要方案如下


  1. 遍历图像文件夹中的所有文件。

  2. 通过使用 DocsList.getFileById 方法

  3. 来打开每个文件,以检查文件数据是否需要MIME类型。我想,JPEG文件是你最想要的。他们有 image / jpeg MIME类型。 BLOB类的 getContentType 方法返回数据类型。

  4. 为过滤的文件,通过使用 BLOB.getBytes 方法,在数据中查找EXIF-matadata(请参阅下文),解析它并获取地理标记。地理信息存储为图像文件中的元数据,通常具有 EXIF 格式。有许多Javascript库能够读取JPEG文件的EXIF,例如,此一个。您可以编写自己的代码来执行此步骤,也可以修改存在的库(如果库许可证允许)。存在的库修改应该不成问题。

  5. 将检索到的地理信息发布到电子表格。


The idea: at the moment I have a script which watch for new images uploaded (from smartphone or tab) to a specific folder. The script moves image to some subfolder depending on image's name and append a row with corresponding data to specific spreadsheet.

Is it possible to fetch geo information from uploaded to Google Drive images (using smartphone) to put them to the spreadsheet? Searched over the API, but look there is no native function for that. Any 3rd-party solutions?

解决方案

It is possible to accomplish your task (to get geo-data of uploaded images) using GAS. There is no GAS service performing it and I am almost sure now there is no a 3rd-party solution for your task. A brief scheme for the task is the following

  1. to traverse all files in the image folder.
  2. to open every file by using the DocsList.getFileById method
  3. to check if the file data has required MIME-type. I assume, that JPEG files are most wanted to you. They have the image/jpeg MIME-type. The getContentType method of the BLOB class returns the data type.
  4. for filtered files, to get the data by using the BLOB.getBytes method, find in the data the EXIF-matadata (see bellow), parse it and get the geotags. The geo-info stored as metada inside of image file and usually has EXIF format. There is a number of Javascript libraries which are able to read EXIF of JPEG files, for instance, this one. You can either write your own code which will perform this step or modify the exist library (if the library license permits it). The exist library modification should not be a problem.
  5. to publish the retrieved geo-information to a spreadsheet.

这篇关于使用Google Apps脚本从上传的图片中获取地理标记?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆