Download utils/image_utils.py from aamsko/img: direct link, hf CLI and curl.
- Browser
- Download file 249 Bytes
-
https://huggingface.co/spaces/aamsko/img/resolve/main/utils/image_utils.py
- Command line
-
hf download hf://spaces/aamsko/img/utils/image_utils.py
-
curl -L -o image_utils.py https://huggingface.co/spaces/aamsko/img/resolve/main/utils/image_utils.py
249 Bytes
| from PIL import Image | |
| import numpy as np | |
| def resize_image(image, max_size=1024): | |
| w, h = image.size | |
| if max(w, h) > max_size: | |
| scale = max_size / max(w, h) | |
| return image.resize((int(w * scale), int(h * scale))) | |
| return image | |