Examples

If you are calling this library from another Python file, the following is the sample code from Google:

_images_download import google_images_download 

#importing the library

response = google_images_download.googleimagesdownload()

#class instantiation

arguments = {"keywords":"apple, beach, cat","limit":30,"print_urls":True} #creating list of arguments
paths = response.download(arguments) #passing the arguments to the function
print(paths)

#printing absolute paths of the downloaded images

If you are passing arguments from a config file, simply pass the config_file argument with the name of your JSON file:

$ googleimagesdownload -cf example.json

The following is a simple example of using keywords and limit arguments:

$ googleimagesdownload --keywords "apple, beach, cat" --limit 20

Using suffix keywords allows you to specify words after the main keyword. For example, if the keyword is car and the suffix keywords are red and blue, then it will first search for a red car and then a blue car:

$ googleimagesdownload --k "car" -sk 'yellow,blue,green' -l 10

To use the short-hand command, use the following code:

$ googleimagesdownload -k "apple, beach, cat" -l 20

To download images with specific image extension, or formats, use the following code:

$ googleimagesdownload --keywords "logo" --format svg

To use color filters for the images, use the following code:

$ googleimagesdownload -k "playground" -l 20 -co red

To use non-English keywords for image searches, use the following code:

$ googleimagesdownload -k "" -l 5

To download images from the Google Images link, use the following code:

$ googleimagesdownload -k "sample" -u <google images page URL>

To save images in a specific main directory (instead of in Downloads), use the following code:

$ googleimagesdownload -k "boat" -o "boat_new"

To download one single image within the image URL, use the following code:

$ googleimagesdownload --keywords "baloons" --single_image <URL of the images>

To download images with size and type constraints, use the following code:

$ googleimagesdownload --keywords "baloons" --size medium --type animated

To download images with specific usage rights, use the following code:

$ googleimagesdownload --keywords "universe" --usage_rights labeled-for-reuse

To download images with specific color types, use the following code:

$ googleimagesdownload --keywords "flowers" --color_type black-and-white

To download images with specific aspect ratios, use the following code:

$ googleimagesdownload --keywords "universe" --aspect_ratio panoramic

To download images that are similar to the image in the image URL that you provided (known as a reverse image search), use the following code:

$ googleimagesdownload -si <image url> -l 10

To download images from a specific website or domain name for a given keyword, use the following code:

$ googleimagesdownload --keywords "universe" --specific_site google.com

The images will be downloaded to their own sub-directories inside the main directory (either the one you provided or in Downloads) in the same folder you are in.

Now, we need to start preparing our dataset.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.135.183.138