Skip to content

Commit 5a4d0a1

Browse files
authored
Merge pull request Python-World#47 from Mitesh2499/master
progress bar in terminal
2 parents 3c2303b + 3f96810 commit 5a4d0a1

3 files changed

Lines changed: 44 additions & 2 deletions

File tree

‎README.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ Sr no | Project Name | Author
3232
10 | [Split Folders into Subfolders](https://github.com/chavarera/python-mini-projects/tree/master/projects/split%20folder%20into%20subfolders) | [Ravi Chavare](https://github.com/chavarera)
3333
11 | [Download bulk images](https://github.com/chavarera/python-mini-projects/tree/master/projects/download%20images%20from%20website) | [Mitesh](https://github.com/Mitesh2499)
3434
12 | [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)
3636
14 | [Calculate age](https://github.com/chavarera/python-mini-projects/tree/master/projects/Calculate%20age) | [Gaodong](https://github.com/xlgd)
3737
15 | [Text file analysis](https://github.com/chavarera/python-mini-projects/tree/master/projects/Textfile%20analysis) | [m044de](https://github.com/m044de/)
3838
16 | [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)
4040
18 | [Send emails](https://github.com/chavarera/python-mini-projects/tree/master/projects/send%20email%20from%20CSV) | [Mitesh](https://github.com/Mitesh2499)
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
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 `
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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!")

0 commit comments

Comments
 (0)