The code helped me download bunch of images from google. It used to work a few days back and now all of the sudden the code breaks.
Code :
# importing google_images_download module
from google_images_download import google_images_download
# creating object
response = google_images_download.googleimagesdownload()
search_queries = ['Apple', 'Orange', 'Grapes', 'water melon']
def downloadimages(query):
# keywords is the search query
# format is the image file format
# limit is the number of images to be downloaded
# print urs is to print the image file url
# size is the image size which can
# be specified manually ("large, medium, icon")
# aspect ratio denotes the height width ratio
# of images to download. ("tall, square, wide, panoramic")
arguments = {"keywords": query,
"format": "jpg",
"limit":4,
"print_urls":True,
"size": "medium",
"aspect_ratio": "panoramic"}
try:
response.download(arguments)
# Handling File NotFound Error
except FileNotFoundError:
arguments = {"keywords": query,
"format": "jpg",
"limit":4,
"print_urls":True,
"size": "medium"}
# Providing arguments for the searched query
try:
# Downloading the photos based
# on the given arguments
response.download(arguments)
except:
pass
# Driver Code
for query in search_queries:
downloadimages(query)
print()
Output log:
Item no.: 1 --> Item name = Apple Evaluating... Starting Download...
Unfortunately all 4 could not be downloaded because some images were not downloadable. 0 is all we got for this search filter!
Errors: 0
Item no.: 1 --> Item name = Orange Evaluating... Starting Download...
Unfortunately all 4 could not be downloaded because some images were not downloadable. 0 is all we got for this search filter!
Errors: 0
Item no.: 1 --> Item name = Grapes Evaluating... Starting Download...
Unfortunately all 4 could not be downloaded because some images were not downloadable. 0 is all we got for this search filter!
Errors: 0
Item no.: 1 --> Item name = water melon Evaluating... Starting Download...
Unfortunately all 4 could not be downloaded because some images were not downloadable. 0 is all we got for this search filter!
Errors: 0
This actually create a folder but no images in it.
Saving an image in Python is just as simple. You simply call save() and pass in the name you want used to save your image. This method will save the image in the format identified by the extension on the filename you pass in.
This article is a short overview of three ways to generate images with Python: Naive Bayes, GANs, and VAEs. Each uses the MNIST handwritten digit dataset. Images can be generated using Naive Bayes; no fancy neural network is required.
google_images_download project is no longer seems compatible wrt Google APIs.
As an alternative you can try simple_image_download.
Indeed the issue has appeared not so long ago, there are already a bunch of similar Github issues:
Unfortunately, there is no official solution, for now, you could use the temporary solution that was provided in the discussions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With