Spaces:
Running
Running
T.Masuda
commited on
Commit
•
514da49
1
Parent(s):
cb36b0b
update app.py
Browse files
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
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
|
|
|
|
|
|
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:
|