T.Masuda commited on
Commit
514da49
1 Parent(s): cb36b0b

update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -14
app.py CHANGED
@@ -6,21 +6,23 @@ def process_image(foreImg, flip, backImg, left, top, method, hscale, vscale, wid
6
  if foreImg is None:
7
  return None
8
 
9
- bgwidth, bgheight = backImg.size
10
  imwidth, imheight = foreImg.size
11
- if method == 'horizontal scale factor':
12
- scale = bgwidth * hscale / imwidth
13
- imwidth = int(imwidth * scale)
14
- imheight = int(imheight * scale)
15
- elif method == 'vertical scale factor':
16
- scale = bgheight * vscale / imheight
17
- imwidth = int(imwidth * scale)
18
- imheight = int(imheight * scale)
19
- else:
20
- if width > 0:
21
- imwidth = width
22
- if height > 0:
23
- imheight = height
 
 
 
24
 
25
  if isLoc:
26
  if backImg is None:
 
6
  if foreImg is None:
7
  return None
8
 
 
9
  imwidth, imheight = foreImg.size
10
+ if not backImg is None:
11
+ if method == 'horizontal scale factor':
12
+ bgwidth, _ = backImg.size
13
+ scale = bgwidth * hscale / imwidth
14
+ imwidth = int(imwidth * scale)
15
+ imheight = int(imheight * scale)
16
+ elif method == 'vertical scale factor':
17
+ _, bgheight = backImg.size
18
+ scale = bgheight * vscale / imheight
19
+ imwidth = int(imwidth * scale)
20
+ imheight = int(imheight * scale)
21
+ else:
22
+ if width > 0:
23
+ imwidth = width
24
+ if height > 0:
25
+ imheight = height
26
 
27
  if isLoc:
28
  if backImg is None: