Spaces:
Runtime error
Runtime error
Niv Sardi
commited on
Commit
·
d9777e0
1
Parent(s):
5dea5bb
imtool: readability
Browse filesSigned-off-by: Niv Sardi <[email protected]>
- python/imtool.py +7 -5
python/imtool.py
CHANGED
@@ -129,11 +129,13 @@ def mix_alpha(a, b, ba, fx, fy):
|
|
129 |
(ah, aw, ac) = a.shape
|
130 |
(bh, bw, bc) = b.shape
|
131 |
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
|
|
|
|
137 |
|
138 |
return mix_alpha(a, r, rba, fx, fy)
|
139 |
|
|
|
129 |
(ah, aw, ac) = a.shape
|
130 |
(bh, bw, bc) = b.shape
|
131 |
|
132 |
+
p = 0.2
|
133 |
+
if (aw*p < bw or ah*p < bh):
|
134 |
+
f = min(p*aw/bw, p*ah/bh)
|
135 |
+
nw, nh = floor_point(bw*f, bh*f)
|
136 |
+
print(f'resizing, factor {f} to fit in {aw}x{ah}\n -- {bw}x{bh} => {nw}x{nh}')
|
137 |
+
r = cv2.resize(b, (nw, nh), interpolation = cv2.INTER_LINEAR)
|
138 |
+
rba = cv2.resize(ba, (nw, nh), interpolation = cv2.INTER_LINEAR)
|
139 |
|
140 |
return mix_alpha(a, r, rba, fx, fy)
|
141 |
|