Re: Storing images in PG?

From: "Joe Conway" <joseph(dot)conway(at)home(dot)com>
To: "Joe Conway" <joseph(dot)conway(at)home(dot)com>, "Dr(dot) Evil" <drevil(at)sidereal(dot)kz>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: Storing images in PG?
Date: 2001-08-16 16:25:55
Message-ID: 01ac01c12670$21265f00$48d210ac@jecw2k1
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> I guess another option would be to encode the retrieved data as base64,
like
> this (works in 7.2devel *only*):
>
> SELECT encode(image, 'hex') FROM imagetable WHERE ...
>
> And then convert from hex back to bin:
>
> function hex2bin($data)
> {
> $data = trim($data);
> $len = strlen($data);
> return pack("H" . $len, $data);
> }
>

Sorry, I meant to say "to encode the retrieved data as hex, like . . ."
above. But you could also use base64:

SELECT encode(image, 'base64') FROM imagetable WHERE ...

function base64_to_bin($data)
{
$data = trim($data);
return base64_decode($data);
}

-- Joe

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Justin Clift 2001-08-16 16:33:46 Re: PostgreSQL buffer exploits
Previous Message Andrew Snow 2001-08-16 16:08:14 RE: Storing images in PG?