from PIL import Image
#https://note.nkmk.me/en/python-pillow-add-margin-expand-canvas/
im = Image.open("36292_page_white_magnify_icon.png")
im
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_new = add_margin(im,
40, # top
0, # right
0, # bottom
0, #left
(56,247,66)) # color
#(255,255,255,0)) # color
im_new