Newbie: Getting Image From Disk into Buffer

David Rushby woodsplitter at rocketmail.com
Thu Jan 8 16:27:49 EST 2004


"Ashley Lloyd" <ashleylloyd at hotmail.com> wrote in message news:<mailman.180.1073487526.12720.python-list at python.org>...
> I have been trying to get an image into an interbase database (see earlier 
> post), and came across a post made on a list some time ago (I ignored it 
> earlier as we use kinterbasDB not gvib, but I thought I'd try using it in 
> kinterbasDB anyway):
> ...
> it always seems to place 
> into the database a string of either the name of the image on disk 
> ('c:/image.bmp', say), or text such as the following:
> <open file 'c:/image.bmp', mode 'rb' at 0x009F06A0>

In the 'c:/image.bmp' case, you're inserting the file's name (string);
in the "<open file 'c:/image.bmp', mode 'rb' at 0x009F06A0>" case,
you're inserting an open file object, which is repr()ed into a string
for storage.  Instead, you need to insert the *contents* of the file
as a string, e.g., the return value of the file object's read()
method.

> ... but if someone could tell me how I get the image into blob_data 
> (which I assume is a buffer), I'd be very grateful.

http://sourceforge.net/forum/forum.php?thread_id=889866&forum_id=30917



More information about the Python-list mailing list