-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbatch_resize_imgs.py
More file actions
44 lines (33 loc) · 1.05 KB
/
batch_resize_imgs.py
File metadata and controls
44 lines (33 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env python
__author__ = 'blackvitriol'
"""
o 8
8 8
.oPYo. o o o8P 8oPYo. .oPYo. odYo.
8 8 8 8 8 8 8 8 8 8' `8
8 8 8 8 8 8 8 8 8 8 8
8YooP' `YooP8 8 8 8 `YooP' 8 8
8 ....::....8 ::..:..:::..:.....:..::..
8 :::::::ooP'.:::::::::::::::::::::::::
..:::::::...:::::::::::::::A7MD0V:::::::
::::Python Learning::::::::::::28:03:18:::
:::::::: Batch Resize Images :::::::::::::::::
Give it a folder and it will resize all JPG images in it
"""
print("Welcome to A7's Image Batch Resizing Tool...")
import cv2
import glob,os
imgs = glob.glob('*.jpg')
imgs.extend(glob.glob('*.jpeg'))
print("Images found:")
print(imgs)
width = 300
height = 300
print("Resizing all images to 300x300:")
folder = 'resized'
if not os.path.exists(folder):
os.makedirs(folder)
for img in imgs:
pic = cv2.imread(img, cv2.IMREAD_UNCHANGED)
pic = cv2.resize(pic, (width, height))
cv2.imwrite(folder + '/' + img, pic)