Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions image_downloader/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Image Downloader
A simple python script to download images by providing link to the images.

## Modules Used

- requests
- pillow
- io
- os

## Requirements

- Run the following in the directory containing the script files.

```bash
pip install requests pillow
```

- Then run the below command

```bash
python image_downloader.py
```
21 changes: 21 additions & 0 deletions image_downloader/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import requests
from PIL import Image
from io import BytesIO
import os

download_path = os.path.dirname(os.path.abspath(__file__))
count = 1
while True:
url = input("Enter Image URL: ")
try:
res = requests.get(url)
except Exception:
print("Invalid URL / Can't Access The URL")
continue

img = Image.open(BytesIO(res.content))
format = img.format
imgLoc = os.path.join(download_path, f"{count}.{format.lower()}")
img = img.save(imgLoc, format=format.upper())
print(f"Image Downloaded: {imgLoc}")
count += 1
2 changes: 2 additions & 0 deletions image_downloader/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pillow
requests