File tree Expand file tree Collapse file tree
projects/Terminal Progress Bar with Images Resizing Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -32,9 +32,9 @@ Sr no | Project Name | Author
323210 | [ Split Folders into Subfolders] ( https://github.com/chavarera/python-mini-projects/tree/master/projects/split%20folder%20into%20subfolders ) | [ Ravi Chavare] ( https://github.com/chavarera )
333311 | [ Download bulk images] ( https://github.com/chavarera/python-mini-projects/tree/master/projects/download%20images%20from%20website ) | [ Mitesh] ( https://github.com/Mitesh2499 )
343412 | [ Ranom word from file] ( https://github.com/chavarera/python-mini-projects/tree/master/projects/Random_word_from_list ) |
35- 13 | [ Battery notification] ( https://github.com/chavarera/python-mini-projects/tree/master/projects/battery%20notification ) |
35+ 13 | [ Battery notification] ( https://github.com/chavarera/python-mini-projects/tree/master/projects/battery%20notification ) | [ Mitesh ] ( https://github.com/Mitesh2499 )
363614 | [ Calculate age] ( https://github.com/chavarera/python-mini-projects/tree/master/projects/Calculate%20age ) | [ Gaodong] ( https://github.com/xlgd )
373715 | [ Text file analysis] ( https://github.com/chavarera/python-mini-projects/tree/master/projects/Textfile%20analysis ) | [ m044de] ( https://github.com/m044de/ )
383816 | [ Generate image snipets] ( https://github.com/chavarera/python-mini-projects/tree/master/projects/py-carbon-clips ) | [ ravi chavare] ( https://github.com/chavarera/ )
39- 17 | [ Organize file system] ( https://github.com/chavarera/python-mini-projects/tree/master/projects/organized%20download%20folder%20with%20different%20categories ) |
39+ 17 | [ Organize file system] ( https://github.com/chavarera/python-mini-projects/tree/master/projects/organized%20download%20folder%20with%20different%20categories ) | [ Mitesh ] ( https://github.com/Mitesh2499 )
404018 | [ Send emails] ( https://github.com/chavarera/python-mini-projects/tree/master/projects/send%20email%20from%20CSV ) | [ Mitesh] ( https://github.com/Mitesh2499 )
Original file line number Diff line number Diff line change 1+ # Terminal Progress bar with image Resizing
2+
3+ Here I just take example of image resizing for displaying progress bar.
4+ when we convert lots of images at time we can use progress bar to show how many images are resized.
5+
6+ ### For this purpose I am using tqdm librabry
7+ ` pip install tqdm `
8+
9+ This Library is for showing progress bar
10+
11+ ### For Resizing images
12+ ` pip install Pillow `
Original file line number Diff line number Diff line change 1+ from tqdm import tqdm
2+ from PIL import Image
3+ import os
4+ from time import sleep
5+
6+
7+ def Resize_image (size , image ):
8+ if os .path .isfile (image ):
9+ try :
10+ im = Image .open (image )
11+ im .thumbnail (size , Image .ANTIALIAS )
12+ im .save ("resize/" + str (image ) + ".jpg" )
13+ except Exception as ex :
14+ print (f"Error: { str (ex )} to { image } " )
15+
16+
17+ path = input ("Enter Path to images : " )
18+ size = input ("Size Height , Width : " )
19+ size = tuple (map (int , size .split ("," )))
20+
21+ os .chdir (path )
22+
23+ list_images = os .listdir (path )
24+ if "resize" not in list_images :
25+ os .mkdir ("resize" )
26+
27+ for image in tqdm (list_images , desc = "Resizing Images" ):
28+ Resize_image (size , image )
29+ sleep (0.1 )
30+ print ("Resizing Completed!" )
You can’t perform that action at this time.
0 commit comments