Download utils/img_util.py from Daankular/PSHuman: direct link, hf CLI and curl.
- Browser
- Download file 246 Bytes
-
https://huggingface.co/spaces/Daankular/PSHuman/resolve/main/utils/img_util.py
- Command line
-
hf download hf://spaces/Daankular/PSHuman/utils/img_util.py
-
curl -L -o img_util.py https://huggingface.co/spaces/Daankular/PSHuman/resolve/main/utils/img_util.py
246 Bytes
| from PIL import Image | |
| def add_margin(pil_img, color=0, size=256): | |
| width, height = pil_img.size | |
| result = Image.new(pil_img.mode, (size, size), color) | |
| result.paste(pil_img, ((size - width) // 2, (size - height) // 2)) | |
| return result |