Re: Storing images in PG? - Mailing list pgsql-general

From Joe Conway
Subject Re: Storing images in PG?
Date
Msg-id 01ac01c12670$21265f00$48d210ac@jecw2k1
Whole thread Raw
In response to Storing images in PG?  ("Dr. Evil" <drevil@sidereal.kz>)
Responses Re: Storing images in PG?  ("Dr. Evil" <drevil@sidereal.kz>)
List 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



pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: why sequential scan
Next
From: Justin Clift
Date:
Subject: Re: PostgreSQL buffer exploits