Advertisement
Guest User

BaltCTF 2012 images.rar QR generator iPw

a guest
May 21st, 2012
348
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.04 KB | None | 0 0
  1. #       QR generator for images.rar by Ipw for Team Tasteless
  2. #       BaltCTF 2012
  3.  
  4. import Image, os, math
  5.  
  6. #Start by scanning the directory and getting results
  7.  
  8. fakelist = []
  9. for x in range(1, 26):
  10.     for y in range(1, 26):
  11.         if((20<x<25 and 0<y<10) or (10<x<13 and 0<y<10)): #Since the existing file names seem to regard the entire series 20-25 as collisions, we'll do that to :|
  12.             fakelist.append(str(x) + "(" + str(y) + ")" + ".gif")
  13.         elif((str(x) + str(y) + ".gif") in fakelist):
  14.             print "we fd up!!!!"
  15.             os.exit()
  16.         else:
  17.             fakelist.append(str(x) + str(y) + ".gif")
  18. print fakelist
  19.  
  20. finalimage = Image.new('RGB', (300, 300))
  21.  
  22. for imageno, imagename in enumerate(fakelist):
  23.     print str(imageno) + " and name: " + imagename + "\n"
  24.     tempimage = Image.open('images/' + imagename)
  25.     pixel = tempimage.crop((0, 0, 12, 12))
  26.     row = int((math.floor(imageno/25)))
  27.     column = int(((imageno) % 25))
  28.     print str(row) + ":" + str(column)
  29.     finalimage.paste(pixel, (column*12, row*12, (column+1)*12, (row+1)*12))
  30.     del tempimage
  31.    
  32. finalimage.save("output.jpg")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement