Advertisement
Guest User

Adele PIL Fun

a guest
Jul 8th, 2012
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.15 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2. """
  3. Created on Thu Jul 07 22:36:01 2012
  4.  
  5. @author: Marshall
  6. """
  7.  
  8. import Image
  9. from PIL import ImageFont
  10. from PIL import ImageDraw
  11.  
  12. font = ImageFont.truetype("C:\\Windows\\Fonts\\raleway_thin.otf", 60, encoding='unic')
  13.  
  14. editFile = "tranp.png"
  15.  
  16. imageFile = Image.open(editFile)
  17. handFile = Image.open("hand.png")
  18.  
  19. text = "MARSHALL"
  20. number = 19
  21.  
  22. pixel = imageFile.load()
  23.  
  24. r, g, b, alpha = imageFile.split()
  25. r2,g2,b2,a2 = handFile.split()
  26.  
  27.  
  28. newImage = Image.new(imageFile.mode, (550,550), (70,70,70))
  29. newImage.paste(imageFile,(90,0), mask=alpha)
  30. newImage = newImage.rotate(30)
  31.  
  32. pixel = newImage.load()
  33.  
  34. for x in range(550):
  35.     for y in range(550):
  36.         if pixel[x,y] == (0,0,0,0):
  37.             pixel[x,y] = (70,70,70,0)
  38.  
  39. newImage.paste(handFile,(0,155), a2)
  40.  
  41. draw = ImageDraw.Draw(newImage)
  42.  
  43. x,y = draw.textsize(text, font=font)
  44. numX, numY = draw.textsize(str(number), font=font)
  45.  
  46. draw.text((550-x-numX-20, 550-y-20), text, (180,180,180), font=font)
  47. draw.text((550-numX-20, 550-y-20), str(number), (132,143,100), font =font)
  48.  
  49. newImage = newImage.convert('L')
  50. #newImage.show()
  51.  
  52. newImage.save("result.jpg")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement