PageRenderTime 182ms CodeModel.GetById 0ms RepoModel.GetById 0ms app.codeStats 0ms

/original/Image Recycling Bin.app/Contents/Resources/patchwork.py

https://github.com/aleray/datateb
Python | 75 lines | 47 code | 17 blank | 11 comment | 5 complexity | 4eccbf7648f40015482f5aaa987b1dd6 MD5 | raw file
Possible License(s): GPL-3.0
  1. #!/usr/local/bin/python
  2. # -*- coding: utf-8 -*-
  3. from AppKit import NSSound
  4. from appscript import *
  5. from mactypes import Alias
  6. import osax
  7. import time
  8. import EasyDialogs
  9. import os, sys
  10. import Image
  11. import random
  12. import glob
  13. def main():
  14. # Play a sound
  15. #snd = "paper_shredder.wav"
  16. #os.system("/Users/aleray//bin/mplayer %s < /dev/tty1 >| ~/error.log" % snd)
  17. #os.system("/Users/aleray/bin/mplayer %s >| ~/error.log" % snd)
  18. #os.system("/Applications/VLC.app/Contents/MacOS/VLC -I ncurses %s &" % snd)
  19. #sound = NSSound.alloc()
  20. #sound.initWithContentsOfFile_byReference_('/Users/aleray/Desktop/Paper Shredder.app/Contents/Resources/paper_shredder.wav', True)
  21. #sound.play()
  22. meter = EasyDialogs.ProgressBar('Recycling your pictures...',
  23. maxval=100,
  24. label='Starting',
  25. )
  26. for i in xrange(1, 101):
  27. phase = '%d %% Completed' % i
  28. print phase
  29. meter.label(phase)
  30. meter.inc()
  31. time.sleep(0.01)
  32. print 'Done with loop'
  33. time.sleep(1)
  34. del meter
  35. print 'The dialog should be gone now'
  36. imagesSrc=glob.glob('/Users/aleray/Recycled/Images Recycle Bin/*.jpg')
  37. images=[]
  38. for i in imagesSrc:
  39. im = Image.open(i)
  40. x, y = im.size
  41. bla = [im, x, y]
  42. images.append(bla)
  43. print images
  44. finalX = 600
  45. finalY = 600
  46. newIm = Image.new("RGB", (finalX,finalY), "White")
  47. for i in range(10000):
  48. for i in images:
  49. newX = random.randint(0, i[1])
  50. newY = random.randint(0, i[2])
  51. patch = i[0].crop([newX,newY,newX+20,newY+20])
  52. newX = random.randint(0, finalX)
  53. newY = random.randint(0, finalY)
  54. newIm.paste(patch, (newX,newY))
  55. newIm.show()
  56. # print EasyDialogs.Message('Your file have been succesfully destructed', ok='Continue')
  57. if __name__ == '__main__':
  58. main()