The DriveApp service of Google Apps Script doesn't provide access to the details you're looking for, but the Advance Drive Service does.
Code.gs
You will need to enable the Advanced Drive service, following instructions here.
// Demo use of getPhotoExif()
// Logs all files in a folder named "Photos".
function listPhotos() {
var files = DriveApp.getFoldersByName("Photos").next().getFiles();
var fileInfo = [];
while (files.hasNext()) {
var file = files.next();
Logger.log("File: %s, Date taken: %s",
file.getName(),
getPhotoExif(file.getId()).date || 'unknown');
}
}
/**
* Retrieve imageMediaMetadata for given file. See Files resource
* representation for details.
* (https://developers.google.com/drive/v2/reference/files)
*
* @param {String} fileId File ID to look up
*
* @returns {object} imageMediaMetadata object
*/
function getPhotoExif( fileId ) {
var file = Drive.Files.get(fileId);
var metaData = file.imageMediaMetadata;
// If metaData is 'undefined', return an empty object
return metaData ? metaData : {};
}
In the Google Drive API, the resource representation for a File includes properties for the EXIF data:
"imageMediaMetadata": {
"width": integer,
"height": integer,
"rotation": integer,
"location": {
"latitude": double,
"longitude": double,
"altitude": double
},
"date": string,
"cameraMake": string,
"cameraModel": string,
"exposureTime": float,
"aperture": float,
"flashUsed": boolean,
"focalLength": float,
"isoSpeed": integer,
"meteringMode": string,
"sensor": string,
"exposureMode": string,
"colorSpace": string,
"whiteBalance": string,
"exposureBias": float,
"maxApertureValue": float,
"subjectDistance": integer,
"lens": string
},
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…