Skip to content

Instantly share code, notes, and snippets.

@bound2
Last active June 6, 2017 15:47
Show Gist options
  • Save bound2/39cfeafa5fdbb487a074917041093fd3 to your computer and use it in GitHub Desktop.
Save bound2/39cfeafa5fdbb487a074917041093fd3 to your computer and use it in GitHub Desktop.
from PIL import Image, ImageOps
image = Image.open("test.png")
width = image.size[0]
minimum_height = int(width / 1.9)
background = Image.new('RGB', (image.size[0], minimum_height))
background.paste(image, (0, minimum_height / 2 - image.size[1] / 2), image.convert('RGBA'))
background.save("output.png")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment