0
Hey, guys, all right?
I need to get some pictures of a specific FLICKR user and with a specific description for a college job. I’m still learning how to program, so I don’t really know how to do it, I tried to read the API guidelines, but I didn’t get it right. The most I could download were some photos with a specific "keyword", but the content doesn’t exactly match what I need. I tried to put several Keywords or try to add the photographer’s name, but I could not download any photo. I believe it would solve the problem if I pulled only the photos of a specific user with the description I need, it is possible to do this with the flickrapi or other api?
#id of the marcozeroconteudo: 152991702@N05
Here send an example photo I need to download. And the descriptions of the text are these:
Marco Zero Content Suape,16 August 2018. Atlantico Shipyard South. Credit: Keila Castro/MZ Content
Her tags are: Suape, Estaleiro, Atlantico Sul
import flickrapi
import urllib
import urllib.request
from PIL import Image
from tqdm import tqdm
from keras.preprocessing.image import ImageDataGenerator
# image.load_img()
#id da marcozeroconteudo: 152991702@N05
# Flickr api access key
flickr=flickrapi.FlickrAPI('MINHA_API_KEY', 'MINHA_API_SECRET', cache=True)
N_MAX = 500
keyword = 'Estaleiro Altantico Sul'
PHOTOs = flickr.walk(text=keyword,
tag_mode='all',
tags=keyword,
extras='url_c',
per_page=108, # may be you can try different numbers..
sort='relevance')
urls = []
for N, PHOTO in tqdm(enumerate(PHOTOs)):
url = PHOTO.get('url_c')
urls.append(url)
# get 50 urls
if N > N_MAX:
break
print (urls)
# Download image from the url and save it to '00001.jpg'
#urllib.request.urlretrieve(urls[0], '00001.jpg')
RESIZE_OPTION = Image.ANTIALIAS #Image.NEAREST, Image.BICUBIC
for i in range(N_MAX):
fname = f'img_{keyword}{i}.jpg'
urllib.request.urlretrieve(urls[i], f'img{keyword}_{i}.jpg')
# Resize the image and overwrite it
image = image.open(fname)
image = image.resize((256, 256), RESIZE_OPTION)
image.save(fname)
Thanks in advance for the help,