Re: medical image on postgreSQL? - Mailing list pgsql-general

From scott.marlowe
Subject Re: medical image on postgreSQL?
Date
Msg-id Pine.LNX.4.33.0304111411110.3509-100000@css120.ihs.com
Whole thread Raw
In response to medical image on postgreSQL?  (jp_santosa@yahoo.com (Santosa Budi))
List pgsql-general
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.


pgsql-general by date:

Previous
From: "Ed L."
Date:
Subject: Re: Batch replication ordering (was Re: [GENERAL] 32/64-bit
Next
From: Tom Lane
Date:
Subject: Re: How can I get a column INT4 to be UNSIGNED ?