Convert your buffer to a StringIO, which has all the file object's methods needed for Image.open(). You may even use cStringIO which is faster:
from PIL import Image
import cStringIO
def ThumbFromBuffer(buf,size):
im = Image.open(cStringIO.StringIO(buf))
im.thumbnail(size, Image.ANTIALIAS)
return im