Advertisement
here2share

# blendtransparency.py

Apr 17th, 2019
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.61 KB | None | 0 0
  1. # blendtransparency.py >>> also img.show() workaround
  2.  
  3. import webbrowser, tempfile, re
  4.  
  5. tf=tempfile.mktemp(".jpg", "py_x")
  6. tf=re.sub(r'(appdata).+?(temp)','pictures',tf)
  7.  
  8. print tf
  9.  
  10. from PIL import Image, ImageDraw
  11.  
  12. img=Image.new('RGB', (400, 400))
  13. cv=ImageDraw.Draw(img, 'RGBA')
  14. cv.rectangle([(0, 0), (400, 400)], (255, 255, 255, 255)) # white
  15. cv.rectangle([(100, 100), (400, 400)], (255, 255, 0, 255)) # yellow
  16. cv.rectangle([(0, 0), (300, 300)], (0, 0, 255, 125)) # blue
  17.  
  18. img.save(tf)
  19. # img.show() ??? did not work on my computer so...
  20. webbrowser.open(tf) # opened via Windows (10) Viewer instead of Browser
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement