Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pygame,os,time,re
- t = int(round(time.time() * 1000))
- def sorted_alphanumeric(data): #thanks stackoverflow
- convert = lambda text: int(text) if text.isdigit() else text.lower()
- alphanum_key = lambda key: [ convert(c) for c in re.split('([0-9]+)', key) ]
- return sorted(data, key=alphanum_key)
- colourstate = 0
- w=1648
- h=128
- rgb = ['b','g','r'] # dunno why its the wrong order but it works
- exportersurf = pygame.Surface((w,h))
- image = pygame.image.load('JNCE_2016240_00C6159_V01.png')
- for i in range(0,int(image.get_rect().size[1]/h)):
- exportersurf.blit(image,(0,0-(i*h)))
- colourstate = i % 3
- pygame.image.save(exportersurf,"output/"+rgb[colourstate]+"/"+str(int((i/3)))+".png")
- for j,c in enumerate(rgb):
- imgarray = []
- for f in sorted_alphanumeric(os.listdir('output/'+c)):
- imgarray.append(pygame.image.load('output/'+c+"/"+f))
- surf = pygame.Surface((w,image.get_rect().size[1]/3))
- for i,img in enumerate(imgarray):
- surf.blit(img,(0,(i*h)+(128*j)+(40*j)))
- pygame.image.save(surf,'output/finals/'+c+'.png')
- print("done. took "+str(int(round(time.time() * 1000))-t)+"ms")
Advertisement
Add Comment
Please, Sign In to add comment