Skip to content

Instantly share code, notes, and snippets.

@pr0crustes
Created February 9, 2018 22:10
Show Gist options
  • Save pr0crustes/184c39962f71090b15562f6aef550922 to your computer and use it in GitHub Desktop.
Save pr0crustes/184c39962f71090b15562f6aef550922 to your computer and use it in GitHub Desktop.
import numpy as np
from random import randrange
from PIL import Image
if __name__ == '__main__':
square_size = 50
img = Image.open("image.png")
size1, size2 = img.size
background = Image.new('RGB', (square_size * size1, square_size * size2), (255, 255, 255))
images = []
for i in range(square_size):
temp = []
for j in range(square_size):
print("Image {}, {}".format(i, j))
rotated = img.rotate(randrange(0, 360))
temp.append(np.asarray(rotated))
images.append(temp)
mergeds_rows = []
for row in images:
merged = np.concatenate(row, axis=1)
mergeds_rows.append(merged)
merged_image = np.concatenate(mergeds_rows)
print(merged_image.shape)
image = Image.fromarray(merged_image)
background.paste(image, (0, 0))
background.save("test.png")
@pr0crustes
Copy link
Author

image

@pr0crustes
Copy link
Author

try

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment