Newbie: Getting Image From Disk into Buffer

Ashley Lloyd ashleylloyd at hotmail.com
Fri Jan 9 06:01:12 EST 2004


Thanks very much for your reply.

I ended up getting this working by using:

f=open(fileName','rb',-1)
buf=f.read()

I'd swear I tried this before with no success, but I can't have (or more 
than likely did it in the wrong way, somehow) - so sorry to everyone whose 
time I've wasted by asking such a stupid question!

Anyway, thanks very much once again for your reply.

Cheers

Ashley

>From: woodsplitter at rocketmail.com (David Rushby)
>To: python-list at python.org
>Subject: Re: Newbie: Getting Image From Disk into Buffer
>Date: 8 Jan 2004 13:27:49 -0800
>
>"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
>--
>http://mail.python.org/mailman/listinfo/python-list

_________________________________________________________________
It's fast, it's easy and it's free. Get MSN Messenger today! 
http://www.msn.co.uk/messenger





More information about the Python-list mailing list