Niv Sardi commited on
Commit
d9777e0
1 Parent(s): 5dea5bb

imtool: readability

Browse files

Signed-off-by: Niv Sardi <xaiki@evilgiggle.com>

Files changed (1) hide show
  1. 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
- if (aw < bw or ah < bh):
133
- f = 0.2*aw/bw
134
- print(f'resizing, factor {f} to fit in {aw}x{ah}\n -- {bw}x{bh} => {floor_point(bw*f, bh*f)}')
135
- r = cv2.resize(b, floor_point(bw*f, bh*f), interpolation = cv2.INTER_LINEAR)
136
- rba = cv2.resize(ba, floor_point(bw*f, bh*f), interpolation = cv2.INTER_LINEAR)
 
 
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