(height: float, width: float, ratios: dict)
| 437 | |
| 438 | |
| 439 | def get_closest_ratio(height: float, width: float, ratios: dict): |
| 440 | aspect_ratio = height / width |
| 441 | closest_ratio = min( |
| 442 | ratios.keys(), key=lambda ratio: abs(float(ratio) - aspect_ratio)) |
| 443 | return closest_ratio |
| 444 | |
| 445 | |
| 446 | ASPECT_RATIOS = { |