[Image-SIG] PIL and converting an image to and from a string value
Chris Hare
Chare at labr.net
Fri Apr 27 13:28:11 CEST 2012
Here is what I am trying to:
the application user chooses an image file. I want to store the image data in a field in a sqlite database. My understanding from the reading I have done is that I have to convert the image data into a string , which I can then store in the database. Additionally, I need to be able to take the stored image data and convert it back to an image so I can display it in a canvas widget. I am using the python imaging library
I think I have the following parts correct:
image = Image.open("cover.jpg")
image = image.resize((150,150),Image.ANTIALIAS)
png = image.tostring("PNG")
I am taking the image data from the file, resizing the image, and then using the PNG coder to force it into a PNG format image and converting it to a string.
I am stuck however, in figuring out how to take the string data and converting it back to an image that I can put into the canvas widget. Either I am not finding a good explanation of how to do this or I am just not understanding what I am finding:-)
Any ideas are appreciated!
Thanks,
Chris
More information about the Image-SIG
mailing list