Ridimensiona un'immagine recuperata da Google Drive utilizzando API
-
12-12-2019 - |
Domanda
Sto usando il seguente codice Python per ottenere un file da Google Drive:
theGoogleDriveFile = service.files().get(fileId=<googleDriveFileId>).execute()
.
Come vai a ridimensionare questo file se è un'immagine?Ho provato quanto segue:
resizedImage = images.resize(theGoogleDriveFile['downloadUrl'], 32, 32)
.
Ma ottengo il seguente errore:
raise NotImageError()
NotImageError
. Soluzione
Questo funziona:
theGoogleDriveFile = service.files().get(fileId=<googleDriveFileId>).execute()
result = urlfetch.fetch(theGoogleDriveFile['webContentLink'])
resizedImage = images.resize(result.content, 32, 32)
. Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow