Created
February 9, 2018 22:10
-
-
Save pr0crustes/184c39962f71090b15562f6aef550922 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |
Author
pr0crustes
commented
Feb 9, 2018
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment