[pygtk] Saving and reading images from database
David Ripton
dripton at ripton.net
Fri Nov 13 23:51:24 WST 2009
On 2009.11.13 15:15:22 +0100, Timo List wrote:
> My program uses the SQLite database. The database holds some information
> about persons and I want to add a picture for each person. Not the path to
> the file, but the actual image so that the image also works if the file is
> deleted on the harddisk.
>
> I can save the image in a BLOB column as:
> imgfile = open('/path/to/image.png')
> db.save_image(imgfile.read())
>
> Works fine as far as I see. (Maybe any comments on this?)
>
> Retrieving also works, but I see no possibility to show this image in a
> gtk.Image widget. I can't seem to find anything related to this on the net,
> maybe someone reading this has done this before?
Have you already tried gtk.gdk.PixbufLoader?
Of course, if all else fails, you can always write the blob out to a
tempfile and then use gtk.gdk.pixbuf_new_from_file on the tempfile.
--
David Ripton dripton at ripton.net
More information about the pygtk
mailing list