Google apps script 如何检查图像的分辨率
如何使用Google Apps脚本检查存储在Google Drive上的图像的分辨率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
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);
}