使用API​​调整从Google云端硬盘检索到的图片大小

时间:2012-07-27 03:30:29

标签: python google-app-engine google-drive-api

我使用以下Python代码从Google云端硬盘获取文件:

theGoogleDriveFile = service.files().get(fileId=<googleDriveFileId>).execute()

如果图像是图像,我该如何调整此文件的大小?我尝试过以下方法:

resizedImage = images.resize(theGoogleDriveFile['downloadUrl'], 32, 32)

但是我收到以下错误:

raise NotImageError()
NotImageError

1 个答案:

答案 0 :(得分:0)

这有效:

theGoogleDriveFile = service.files().get(fileId=<googleDriveFileId>).execute()
result = urlfetch.fetch(theGoogleDriveFile['webContentLink'])                
resizedImage = images.resize(result.content, 32, 32)