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
.

È stato utile?

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
scroll top