from PIL import Image
def add_margin(pil_img, top, right, bottom, left, color):
width, height = pil_img.size
new_width = width + right + left
new_height = height + top + bottom
result = Image.new(pil_img.mode, (new_width, new_height), color)
result.paste(pil_img, (left, top))
return result
im = Image.open("64746_system_monitor_icon.png")
for i in range(30):
print(f"padding {i}")
im_new = add_margin(im, i, 0, 0, 0, (255,255,255,0))
display(im_new)
for i in range(30):
print(f"paddingtopbototm {i}")
im_new = add_margin(im, i, 0, i, 0, (255,255,255,0))
display(im_new)