Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 8th, 2012  |  syntax: None  |  size: 0.43 KB  |  hits: 10  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. How to get string data from a python PIL image object?
  2. from PIL import ImageGrab
  3.     import cStringIO
  4.     fakie = cStringIO.StringIO()
  5.     ImageGrab.grab().save(fakie, 'GIF')
  6.     data = fakie.getvalue()
  7.     fakie.close()
  8.     # This last bit of code is to see if the var data stored the right info in a str bc i need to send it through a socket
  9.     with open('C:somethingsomethingDesktopimage.gif', 'w') as f:
  10.         f.write(data)