Redimensionnez une image extraite de Google Drive à l'aide de API
-
12-12-2019 - |
Question
J'utilise le code Python suivant pour obtenir un fichier de Google Drive:
theGoogleDriveFile = service.files().get(fileId=<googleDriveFileId>).execute()
Comment irai-ierais redimensionner ce fichier s'il s'agit d'une image?J'ai essayé ce qui suit:
resizedImage = images.resize(theGoogleDriveFile['downloadUrl'], 32, 32)
Mais je reçois l'erreur suivante:
raise NotImageError()
NotImageError
La solution
Ceci fonctionne:
theGoogleDriveFile = service.files().get(fileId=<googleDriveFileId>).execute()
result = urlfetch.fetch(theGoogleDriveFile['webContentLink'])
resizedImage = images.resize(result.content, 32, 32)
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow