-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresizeImg.py
35 lines (30 loc) · 973 Bytes
/
resizeImg.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
35
# -*- coding: utf-8 -*-
"""
Created on Wed Apr 25 10:32:22 2018
@author: USER
"""
import PIL
from PIL import Image
#ubah berdasarkan width
def ubahWidth():
basewidth = 20
img = Image.open('bahan/1.jpg')
#wpercent = (basewidth / float(img.size[0]))
#hsize = int((float(img.size[1]) * float(wpercent)))
hsize = 40
img = img.resize((basewidth, hsize), PIL.Image.ANTIALIAS)
txtHeight = str(hsize)
txtWidth = str(basewidth)
img.save('resized_image'+txtHeight+'x'+txtWidth+'.jpg')
#ubah berdasarkan height
def ubahHeight():
baseheight = 40
img = Image.open('D://KULIAH/SEMESTER VI/COMPUTER VISION/ViolaJones/negatif/10.jpg')
#hpercent = (baseheight / float(img.size[1]))
#wsize = int((float(img.size[0]) * float(hpercent)))
wsize = 20
imgUbah = img.resize((wsize, baseheight), PIL.Image.ANTIALIAS)
#txtHeight = str(baseheight)
#txtWidth = str(wsize)
imgUbah.save('bahan/negatif/br10.jpg')
ubahHeight();