Python Imaging: load jpeg from memory
PIL's Image.open object accepts any file-like object. That means you can wrap your Image data on a StringIO object, and pass it to Image.Open
from io import BytesIO
file_jpgdata = BytesIO(jpgdata)
dt = Image.open(file_jpgdata)
Or, try just passing self.rfile
as an argument to Image.open - it might work just as well. (That is for Python 3 - for Python 2 use from cStringIO import StringIO as BytesIO
)