Skip to content

Instantly share code, notes, and snippets.

@MartinWeiss12
Created November 18, 2024 15:19
Show Gist options
  • Save MartinWeiss12/46da885ad13d9b33a43c075774d7d09f to your computer and use it in GitHub Desktop.
Save MartinWeiss12/46da885ad13d9b33a43c075774d7d09f to your computer and use it in GitHub Desktop.
Mini Grid
def mini_grid(path, grid_type):
grid = Image.new('RGB', (8000, 8000))
list = [f'{path}/{grid_type}-{i}.png' for i in range(1, 15)]
for i, img in enumerate(list, start=1):
if i == 1:
image = Image.open(img).resize((4000, 4000))
grid.paste(image, (2000, 2000))
if i >= 2 and i <= 4:
image = Image.open(img).resize((2000, 2000))
grid.paste(image, (-4000 + (i * 2000), 0))
if i >= 5 and i <= 8:
image = Image.open(img).resize((2000, 2000))
grid.paste(image, (6000, -10000 + (i * 2000)))
if i >= 9 and i <= 11:
image = Image.open(img).resize((2000, 2000))
grid.paste(image, (24000 - (i * 2000), 6000))
if i >= 12 and i <= 14:
image = Image.open(img).resize((2000, 2000))
grid.paste(image, (0, 30000 - (i * 2000)))
grid.save(f'{grid_type.lower()}-mini-grid.png')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment