-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresize.py
34 lines (27 loc) · 1.02 KB
/
resize.py
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
# Copyright 2017 The Impetuors Authors. All Rights Reserved.
# Authors:
# Preetham Paul Sunkari, Praphul Singh, Harshit Saini, Aadrish Sharma
# Limited under the License.
##########################################################################################
import PIL
from PIL import Image
import os, sys
def resizeImage(infile, output_dir="", size=(200,200)):
outfile = os.path.splitext(infile)[0]+"_resized"
extension = os.path.splitext(infile)[1]
#if (cmp(extension, ".jpg")):
# return
if infile != outfile:
try :
im = Image.open(infile)
im.resize(size, Image.ANTIALIAS)
im.save(output_dir+outfile+extension,"jpg")
except IOError:
print("cannot reduce image for ", infile)
if __name__=="__main__":
output_dir = "Paul"
dir = "/home/praphulr/DeepLogo-master/Images/Images"
if not os.path.exists(os.path.join(dir,output_dir)):
os.mkdir(output_dir)
for file in os.listdir(dir):
resizeImage(file,output_dir)