Re: medical image on postgreSQL?

From: "scott(dot)marlowe" <scott(dot)marlowe(at)ihs(dot)com>
To: Santosa Budi <jp_santosa(at)yahoo(dot)com>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: medical image on postgreSQL?
Date: 2003-04-11 20:15:04
Message-ID: Pine.LNX.4.33.0304111411110.3509-100000@css120.ihs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

On 9 Apr 2003, Santosa Budi wrote:

> Dear Friends,
>
> Apologize.. this posting may not relevance enough to this group.
> I am very much a newbie to posgreSQL database programming and would like
> assistance. I am finding an example how to use the database (postgreSQL)
> to store MRI/CT image data using C language interface. I heard something
> pronounced like: Content-Based Image Retrieval.. but I still do not have
> any idea for a HowTo do on postgreSQL database.
>
> If possible, could someone describe the skeleton for such database pro-
> gramming.. nor if there are examples or some references/tutorial/books
> concering this kind database programming, could someone give me pointers
> to both the site online or book store.
>
> Sorry if this is the incorrect place for this post, but I do need helps
> and figured to start with. Thank you for your helps.

Good of a place as any :-)

If you want to store a binary file in postgresql, you can either use the
semi-non-standard large object interface (I'd recommend against it
personally) or you can encode your data and store it in the database.
while there is a bytea type that works ok, but my preferred method is more
transportable: base-64 encode the data, then store that in a text field.
Since postgresql compresses text fields automagically, you don't have to
worry about base-64 being too bloaty, since the only bloat will be when
you're actually moving the file into / out of the database.

pseudo code:

$file = "/somedir/somefile.gif";
$fp = fopen($file,"r");
$img=fread($fp,filesize($file));
$b64 = base64encode($img);
$b64=pg_escape($b64);
$query = "insert into table (bigfield) values ('$b64');

Just reverse the process to get it back.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Bruno Wolff III 2003-04-11 20:15:41 Re: Case sensitive order by
Previous Message scott.marlowe 2003-04-11 20:11:02 Re: Questions regarding PostgreSQL

Browse pgsql-hackers by date

  From Date Subject
Next Message Sean Chittenden 2003-04-11 20:36:03 Re: [GENERAL] medical image on postgreSQL?
Previous Message scott.marlowe 2003-04-11 19:31:06 Re: Anyone working on better transaction locking?