Skip to content

Instantly share code, notes, and snippets.

@grampabacon
Last active September 28, 2021 13:48
Show Gist options
  • Save grampabacon/7c73d192ad3e43b3a0bca3849af4c0d6 to your computer and use it in GitHub Desktop.
Save grampabacon/7c73d192ad3e43b3a0bca3849af4c0d6 to your computer and use it in GitHub Desktop.
import pathlib
from PIL import Image
# Layer the transparent cat onto a solid pink background image and save.
def create_cat(id):
image = Image.open("Paper_Cat_Transparent.png")
path = "cats/"
new_image = Image.new("RGB", image.size, "PINK")
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