(image, scale_factor)
| 211 | |
| 212 | |
| 213 | def downscale(image, scale_factor): |
| 214 | new_width = int(round(image.width * scale_factor)) |
| 215 | new_height = int(round(image.height * scale_factor)) |
| 216 | new_width = max(1, new_width) |
| 217 | new_height = max(1, new_height) |
| 218 | return image.resize((new_width, new_height), resample=Image.BICUBIC) |
| 219 | |
| 220 | |
| 221 | def crop(image, crop_factors): |