Skip to content

Instantly share code, notes, and snippets.

@chrisjd20
chrisjd20 / cut_out_opaque_parts_of_image_into_smaller_images.py
Created December 22, 2023 18:14
Crops out all parts of the image that are not transparent using python and pil. If transparency was the ocean and blobs of opaque pixels were islands, it would create a new image of each island.
from PIL import Image
def find_islands(image):
"""Find islands (cards) in the image."""
width, height = image.size
pixels = image.load()
visited = set()
islands = []
def is_transparent(x, y):