python - Converting jpeg string to PIL image object -


i've been handed list of files backend of application supposed jpeg files. life of me haven't been able convert them pil image objects. when call

str(curimg) 

i back:

<type 'str'> 

. have tried using open(), .read, io.bytesio(img.read() , doing nothing it, keeps seeing string. when print string, unrecognizable characters. know how tell python how intepret string jpeg , convert pill image can call .size , np.array on?

you should able pass stringio object pil , open way.

ie:

from pil import image import stringio tempbuff = stringio.stringio() tempbuff.write(curimg) tempbuff.seek(0) #need jump beginning before handing off pil image.open(tempbuff) 

Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -