Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-apps-script/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google apps script 如何检查图像的分辨率_Google Apps Script_Google Drive Api - Fatal编程技术网

Google apps script 如何检查图像的分辨率

Google apps script 如何检查图像的分辨率,google-apps-script,google-drive-api,Google Apps Script,Google Drive Api,如何使用Google Apps脚本检查存储在Google Drive上的图像的分辨率 var childFile = files.next(); data = [ childFile.getName(), childFile.getDateCreated(), childFile.getUrl(), childFile.getLastUpdated(), childFile.getDescription(), childFile.getSi

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

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

在上面的代码中,我可以获得图像的大小,但如何获得图像的分辨率。

您可以使用Google Drive API获得图像大小和其他分辨率。确保已在开发人员控制台下为应用程序脚本项目启用驱动器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);
}