Skip to content

Instantly share code, notes, and snippets.

@Vadbeg
Created February 29, 2020 17:53
Show Gist options
  • Save Vadbeg/2b8532cc7eff7068369009bd7be4bbfa to your computer and use it in GitHub Desktop.
Save Vadbeg/2b8532cc7eff7068369009bd7be4bbfa to your computer and use it in GitHub Desktop.
def add_backgound(image):
"""
Adds background to given image using PIL
"""
image_shape = image.shape
image_height = image_shape[0]
image_width = image_shape[1]
backgound = create_blank_image(image_height,
image_width,
rgb_color=(0, 0, 255))
background = Image.fromarray(backgound)
image = Image.fromarray(image)
background.paste(image,
(0, 0),
image)
return background
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment