PSHuman / utils /img_util.py
fffiloni's picture
Migrated from GitHub
2252f3d verified
raw
history blame contribute delete
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