---
title: google-images-download tutorial for fansipan
tags: CoderSchool
---
# google-images-download tutorial for fansipan
First of all, you can find everything about google-images-download, including all contents in this notebook and more, in this link:
```
https://google-images-download.readthedocs.io/en/latest/index.html
```
Or, if google-images-download doesn't work for you, find other ways of creating your own image library in this thread:
```
https://forums.fast.ai/t/tips-for-building-large-image-datasets/26688
```
Lastly, this tutorial is written based on Windows, but other than directory formating, Linux and MacOS should work the same, so remember to modify directory paths if you should.
Now let's get started!
## How to install:
You'll need Python, because google-images-download is written in Python. You may follow this tutorial to install Python :
```
https://realpython.com/installing-python/
```
Now, let's install google-images-download
If you have pip:
```
$ pip install google_images_download
```
If you don't, type this in command prompt:
```
$ git clone https://github.com/hardikvasa/google-images-download.git
$ cd google-images-download && sudo python setup.py install
```
If you're casual:
```
https://github.com/hardikvasa/google-images-download
```
## Configure
You may configure your download by creating a configuration file, or typing into command prompt. I think configuration file is easier to learn, so I'll only introduce that. Once you're familiar with that, you can learn the other way effortlessly.
Here are the steps of creating a configuration file:
1. Go to the directory where you want your images stored. Save the path for later use. In this example I'll use "C:\\some\\directory\\path". (If you didn't install through command prompt but downloaded from repo, this directory will have to be "google-images-download-master\google_images_download" under your unzipped folder)
2. Create a txt file. Save the file name for later use. In this example I'll use "someFile.txt"
3. Paste this into someFile.txt:
```
{
"Records": [
{
"keywords": "cat",
"limit": 5,
"color": "orange",
"print_urls": true
},
{
"keywords": "saigon",
"limit": 15,
"size": "large",
"print_urls": true
}
]
}
```
As you can see, there are many aspects of downloaded images we may configure. "keywords" is the words you want to search on google image. "limit" is the number of images you want to download, and so on. (Note: downloading over 100 images with single command requires chromeDriver, we'll talk about that later) To change configuration, simply edit these input arguments accordingly. Here's a complete collection of all input arguments you may use:
```
https://google-images-download.readthedocs.io/en/latest/arguments.html
```
But for now, we'll download 5 images of cat that are mainly orange, and 15 large images of saigon.
4. Save and close someFile.txt, change its file name to "someFile.json". If you don't see the ".txt" part, follow this guide to enable file name extensions:
```
https://www.thewindowsclub.com/show-file-extensions-in-windows
```
## Usage
Now, we're ready to download images. Open your command prompt and go to directory where you saved someFile.json.
```
cd C:\some\directory\path
```
If you installed through command line, type:
```
googleimagesdownload -cf whatever.json
```
If you downloaded from repo, type:
```
$ python3 google_images_download.py -cf whatever.json
OR
$ python google_images_download.py -cf whatever.json
```
And we're done! google-images-download will create a folder under current directory called "download" and store your images there.
## Downloading 100+ images per keyword
To download 100+ images at a time, you'll need Selenium library, "chromedriver" extension, and chrome browser.
If you installed google-images-download through pip or command line, you'll already have Selenium installed. If you don't have pip, get Selenium through your own library management.
Then, download chromedriver from this link:
```
https://sites.google.com/a/chromium.org/chromedriver/downloads
```
While you edit your configuration file to ask for more image, you'll also need to add this line in your arguments:
```
"chromedriver": "C:\\complete\\path\\to\\chromedriver.exe"
```
where "C:\\\\complete\\\\path\\\\to\\\\chromedriver.exe" is the path to where you downloaded chromedriver.
That's it!