-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTools.py
More file actions
34 lines (27 loc) · 1.09 KB
/
Tools.py
File metadata and controls
34 lines (27 loc) · 1.09 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
from PIL import Image
import os
class Tools:
def __init__(self):
self.imageWidth=480
self.imageHeight=360
def resizeImage(self,image, wid, hei):
img = Image.open(image)
imgResized = img.resize((wid, hei), Image.ANTIALIAS)
imgResized.save(image)
def getAllImagesResized(self,strSourcePath):
for root, dirs, files in os.walk(os.path.abspath(strSourcePath)):
for f in files:
fullpath = os.path.join(root, f)
if os.path.splitext(fullpath)[1] == '.jpg':
self.resizeImage(fullpath, self.imageWidth, self.imageHeight)
def getImagePaths(self, strSourcePath):
listPaths=[]
for root, dirs, files in os.walk(os.path.abspath(strSourcePath)):
for f in files:
fullpath = os.path.join(root, f)
if os.path.splitext(fullpath)[1].lower() == '.jpg':
listPaths.append(fullpath)
return listPaths
def getClassNames(self,strSourcePath):
listClasses= (os.listdir(strSourcePath))
return listClasses