Redimensionar uma imagem obtida a partir do Google Drive usando API
-
12-12-2019 - |
Pergunta
Eu estou usando o seguinte código Python para obter um arquivo do Google Drive:
theGoogleDriveFile = service.files().get(fileId=<googleDriveFileId>).execute()
Como eu poderia ir sobre como redimensionar este arquivo se ele é uma imagem?Eu tentei o seguinte:
resizedImage = images.resize(theGoogleDriveFile['downloadUrl'], 32, 32)
Mas eu recebo o seguinte erro:
raise NotImageError()
NotImageError
Solução
Isso funciona:
theGoogleDriveFile = service.files().get(fileId=<googleDriveFileId>).execute()
result = urlfetch.fetch(theGoogleDriveFile['webContentLink'])
resizedImage = images.resize(result.content, 32, 32)
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow