Download large amounts of images from Pexels via terminal.
pip install requests
pip install pexels-api
git clone https://github.com/AguilarLagunasArturo/pexels-image-downloader.git
Edit pexels_user/_init_.py file with your Pexels API as follows:
API_KEY = 'your-pexels-api-key'
You can get an API by signing up in Pexels and then Request access.
python download.py [options] [query] [photos] [path]
Argument | Description | Required |
---|---|---|
options | Specify an option | No |
query | Type a string with the topic of the search | Yes |
photos | Type the number of photos you wish to download | Yes |
path | Type the path to an existing directory in which the photos will be downloaded, current directory assumed if not given | No |
Option | Description |
---|---|
-v | Verbose mode will print information about each photo |
-d | Photos will have a description in their filename |
-i | Photos will have their pexels id in their filename |
-p | Photos will have their photographer in their filename |
-o | Photos will be organized by photographer path/query/photographer/filename with description-pexels-id as filename |
-c | Download compressed size photos, original aspect ratio |
-l | Download large size photos, maximum width of 1880px and a maximum height of 1300px, original aspect ratio |
-m | Download medium size photos, maximum height of 350px and a flexible width, original aspect ratio |
-s | Download small size photos, maximum height of 130px and a flexible width, original aspect ratio |
- By default the images will be downloaded with the original size in path/query/filename and they will be enumerated.
- You can only choose one size for the images.
- The -o option overwrites -d, -i, and -p.
Command | Description |
---|---|
python download.py koala 10 |
Download 10 koala images |
python download.py -v koala 10 |
Download 10 koala images and show information while downloading |
python download.py -p koala 10 |
Download 10 koala images with the photographer in its filename |
python download.py -c koala 10 |
Download 10 koala images with a compressed size |
python download.py -o koala 10 |
Download 10 koala images and organized them by photographer |
python download.py koala 10 ~/Pictures |
Download 10 koala images in ~/Pictures |
python download.py -v -s -o koala 50 ~/Pictures |
Download 50 koala images in ~/Pictures with a small size and organized by photographer (You can combine options) |
python download.py 'cats and dogs' 10 |
Download 10 'cat and dogs' images (if you want to make a query with spaces use double or single quotes) |