Last active
April 19, 2017 20:00
-
-
Save nathan-sixnines/515e776e6bc71052960715f3c526e539 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
from PIL import Image | |
im = Image.open('Flag_of_Maryland.svg.png') | |
left = Image.open('flag_left.png') | |
right = Image.open('flag_right.png') | |
count = 0 | |
dimensions = im.size | |
area = 99999 | |
oldX = 0 | |
while(area > 1): | |
count = count + 1 | |
rdimensions = right.size | |
ldimensions = left.size | |
round = 1 | |
if count%3 == 0: | |
round = 0 | |
left = left.resize(((rdimensions[0]/2)+round,(rdimensions[1]/2)+round)) | |
right = right.resize(((rdimensions[0]/2)+round,(rdimensions[1]/2)+round)) | |
if (count % 2 == 1): # if odd do right side | |
y = 0 | |
x = oldX + rdimensions[0] | |
count2 = 0 | |
while (y < dimensions[1]): | |
count2 = count2 + 1 | |
box = (x, y, x+right.size[0],y+right.size[1]) | |
im.paste(right, box) | |
height = im.size[1] / (2**count) | |
# tweaking height of sections so they line up | |
if count < 4: | |
height = height + 1 | |
if count == 4: | |
if count2 % 2 != 0: | |
height = height + 1 | |
if count == 5: | |
if count2 % 4 != 0: | |
height = height + 1 | |
if count == 7: | |
if count2 % 4 != 0: | |
height = height + 1 | |
if height > 1: | |
y = y + height | |
else: | |
y = y + 1 | |
if (count % 2 == 0): # if do left if even | |
y = 0 | |
x = oldX + rdimensions[0] | |
count2 = 0 | |
while (y < dimensions[1]): | |
count2 = count2 + 1 | |
box = (x, y, x+left.size[0],y+left.size[1]) | |
im.paste(left, box) | |
height = im.size[1] / (2**count) | |
# tweaking height of sections so they line up | |
if count < 4: | |
height = height + 1 | |
if count == 4: | |
if count2 % 2 != 0: | |
height = height + 1 | |
if count == 6: | |
if count2 % 2 == 0 and count2 % 8 != 0: | |
height = height + 1 | |
if height > 1: | |
y = y + height | |
else: | |
y = y + 1 | |
oldX = x | |
area = left.size[0] * left.size[1] | |
if count > 100: | |
break | |
im.save('writeflag.png') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment