0
I created a Google Forms form where I upload a photo, and I have another field where people describe the photo. The idea is to take this description and insert it into the photo description metadata. My problem is precisely being able to select the right photo to enter the information. The result of the google form generates a link where my photo was stored, However I could not find a way to upload the photo via this link the PIL, which are precisely the python libraries that I use to change the description of the photo.
The uploaded photo is saved to a folder in google drive with the original file name before uploading" - User name'".
Below I leave the part of the code that I have already implemented and serves as a basis for when I can select the right photo to enter the corresponding description:
for x in listadefotos: #faz o looping por todos os arquivos encontrados no diretorio
foto = '/content/drive/My Drive/Pictures/Teste/' + x #cria string de acesso a foto, aqui devo selecionar a foto correta, acessando pelo nome da foto, mas eu não terei essa informação
im = ImagePil.open(foto) #PARTE DO CÒDIGO ONDE PRECISO PUXAR A FOTO DO DRIVE VIA LINK do FORMULARIO
descricao = {270:'teste de descricao'} # cria descrição, tag 270 refere-se a ImageDescription DEVE-SE IMPLEMENTAR ESTA PARTE DO CÓDIGO APRA RECEBER OS DADOS DO FORMULÁRIO
exif_dict = {"0th":descricao} # adicona a descrição no modelo exigido pela bblioteca
exif_bytes = piexif.dump(exif_dict) #cria forma de inserção dos dados que serão inseridos
novolocal = "/content/drive/My Drive/Pictures/Processados/" + x
im.save(novolocal, exif=exif_bytes) #cria novo arquivo alterado com as descrições passadas
The files stored in google drive do not have "conventional" formats. To download, you can use the
files.export
Google Drive API to download. https://developers.google.com/drive/api/v3/manage-downloads#python_1– Lucas Maraal
Even downloading I could not relate to the information line of the form. If I use directly the way inside the drive I can open the photo, the problem is that it does not fit in my logic, because I will not know what is the name of the photo. I could even put a field in Forms for the user to fill in as the original name of the photo, but I can’t guarantee that it will insert correctly.
– Lucas Benz