Guest User

My Junocam Script

a guest
Nov 3rd, 2019
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.13 KB | None | 0 0
  1. import pygame,os,time,re
  2. t = int(round(time.time() * 1000))
  3. def sorted_alphanumeric(data): #thanks stackoverflow
  4.     convert = lambda text: int(text) if text.isdigit() else text.lower()
  5.     alphanum_key = lambda key: [ convert(c) for c in re.split('([0-9]+)', key) ]
  6.     return sorted(data, key=alphanum_key)
  7. colourstate = 0
  8. w=1648
  9. h=128
  10. rgb = ['b','g','r'] # dunno why its the wrong order but it works
  11. exportersurf = pygame.Surface((w,h))
  12. image = pygame.image.load('JNCE_2016240_00C6159_V01.png')
  13. for i in range(0,int(image.get_rect().size[1]/h)):
  14.     exportersurf.blit(image,(0,0-(i*h)))
  15.     colourstate = i % 3
  16.     pygame.image.save(exportersurf,"output/"+rgb[colourstate]+"/"+str(int((i/3)))+".png")
  17. for j,c in enumerate(rgb):
  18.     imgarray = []
  19.     for f in sorted_alphanumeric(os.listdir('output/'+c)):
  20.         imgarray.append(pygame.image.load('output/'+c+"/"+f))
  21.     surf = pygame.Surface((w,image.get_rect().size[1]/3))
  22.     for i,img in enumerate(imgarray):
  23.         surf.blit(img,(0,(i*h)+(128*j)+(40*j)))
  24.     pygame.image.save(surf,'output/finals/'+c+'.png')
  25. print("done. took "+str(int(round(time.time() * 1000))-t)+"ms")
Advertisement
Add Comment
Please, Sign In to add comment