File tree 3 files changed +46
-0
lines changed
3 files changed +46
-0
lines changed Original file line number Diff line number Diff line change
1
+ # Image Downloader
2
+ A simple python script to download images by providing link to the images.
3
+
4
+ ## Modules Used
5
+
6
+ - requests
7
+ - pillow
8
+ - io
9
+ - os
10
+
11
+ ## Requirements
12
+
13
+ - Run the following in the directory containing the script files.
14
+
15
+ ``` bash
16
+ pip install requests pillow
17
+ ```
18
+
19
+ - Then run the below command
20
+
21
+ ``` bash
22
+ python image_downloader.py
23
+ ```
Original file line number Diff line number Diff line change
1
+ import requests
2
+ from PIL import Image
3
+ from io import BytesIO
4
+ import os
5
+
6
+ download_path = os .path .dirname (os .path .abspath (__file__ ))
7
+ count = 1
8
+ while True :
9
+ url = input ("Enter Image URL: " )
10
+ try :
11
+ res = requests .get (url )
12
+ except Exception :
13
+ print ("Invalid URL / Can't Access The URL" )
14
+ continue
15
+
16
+ img = Image .open (BytesIO (res .content ))
17
+ format = img .format
18
+ imgLoc = os .path .join (download_path , f"{ count } .{ format .lower ()} " )
19
+ img = img .save (imgLoc , format = format .upper ())
20
+ print (f"Image Downloaded: { imgLoc } " )
21
+ count += 1
Original file line number Diff line number Diff line change
1
+ pillow
2
+ requests
You can’t perform that action at this time.
0 commit comments