【问题标题】:How to check the resolution of the image如何检查图像的分辨率
【发布时间】:2016-09-29 06:51:11
【问题描述】:

如何使用 Google Apps 脚本检查存储在 Google Drive 上的图像的分辨率。

 var childFile = files.next();
  data = [ 
    childFile.getName(),
    childFile.getDateCreated(),
    childFile.getUrl(),
    childFile.getLastUpdated(),
    childFile.getDescription(),
    childFile.getSize()
  ];

在上面的代码中,我可以得到图像的大小,但我怎样才能得到图像的分辨率。

【问题讨论】:

    标签: google-apps-script google-drive-api


    【解决方案1】:

    您可以使用 Google Drive API 来获取图像大小和其他EXIF data。确保您已在开发者控制台下为 Apps 脚本项目启用 Drive API。

    function getImageSize(fileID) {
    
      var api = "https://www.googleapis.com/drive/v2/files/" + fileID;
    
      var meta = JSON.parse(UrlFetchApp.fetch(api, {
        headers: {
          "Authorization": "Bearer " + ScriptApp.getOAuthToken()
        }
      }).getContentText());
    
      Logger.log(meta.imageMediaMetadata.height);
      Logger.log(meta.imageMediaMetadata.width);
    }
    

    【讨论】:

      猜你喜欢
      • 2019-05-09
      • 2012-11-13
      • 2016-03-15
      • 1970-01-01
      • 1970-01-01
      • 2014-11-20
      • 1970-01-01
      • 1970-01-01
      • 2013-04-16
      相关资源
      最近更新 更多