Converting jpeg string to PIL image object

前端 未结 3 1528
一生所求
一生所求 2021-01-04 10:32

I\'ve been handed a list of files from the backend of an application that are supposed to be jpeg files. However for the life of me I haven\'t been able to convert them into

3条回答
  •  南方客
    南方客 (楼主)
    2021-01-04 11:17

    You should be able to pass a StringIO object to PIL and open it that way.

    ie:

    from PIL import Image
    import StringIO
    tempBuff = StringIO.StringIO()
    tempBuff.write(curimg)
    tempBuff.seek(0) #need to jump back to the beginning before handing it off to PIL
    Image.open(tempBuff)
    

提交回复
热议问题