Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # fn_resize.py
- def resize(x, y, area, new_area):
- ratio = (new_area / area) ** 0.5
- w_new = int(x * ratio)
- h_new = int(y * ratio)
- if w_new > h_new:
- while (w_new + 1) * h_new < new_area:
- w_new += 1
- else:
- while w_new * (h_new + 1) < new_area:
- h_new += 1
- return w_new, h_new, [w_new * h_new]
- print(resize(3000, 2000, 6000000, 240000))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement