I am trying to convert, what I think is a bytearray pulled from a database to an image using python PIL.
I have access to the imagetype(jpg, png,..), the image height/width, and the bytearray. The bytearray is of the format
0xffd8ffe000104a46494600010101006000600000ffe111164578.....
I have tried many of the PIL options such as .fromstring and .frombuffer. I've also tried converting the bytearray into other forms (Base64,etc..) and then converting it to an image from there. None of these have worked and the image file is always corrupted.
If i follow the advice from this question:
image = Image.open(io.BytesIO(imagestring))
image.save(imageToSave.jpg)
I get this error: IOError: cannot identify image file
type(imagestring) returns type 'bytearray'
Thanks for reading and for any answers, let me know if I should edit this post with more info.