Skip to content

Instantly share code, notes, and snippets.

@grampabacon
Last active September 28, 2021 14:36
Show Gist options
  • Save grampabacon/8cf8a791fec22ebe1c98b6ae4eef89e3 to your computer and use it in GitHub Desktop.
Save grampabacon/8cf8a791fec22ebe1c98b6ae4eef89e3 to your computer and use it in GitHub Desktop.
import pathlib
from PIL import Image
# Layer the transparent Paper Cat onto a random solid coloured background.
def create_cat(id):
image = Image.open("Paper_Cat_Transparent.png")
path = "cats/"
new_image = Image.new("RGB", image.size, get_background_colour())
new_image.paste(image, (0, 0), image)
pathlib.Path(path).mkdir(parents=True, exist_ok=True)
new_image.save("cats/" + str(id) + ".png", "PNG")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment