php, postgresql and graphical images

From: Mihail Mihailov <Mihail(dot)Mihailov(at)uta(dot)fi>
To: pgsql-php(at)postgresql(dot)org
Subject: php, postgresql and graphical images
Date: 2007-06-13 08:51:55
Message-ID: 20070613115155.uykzmxtvxueoo4w8@imp3.uta.fi
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-php

Hi all!

Does anybody have any experience in displaying images stored in
postgresql database?
I'm trying to export image into file using pg_lo_export function and
then view it on html page. However, the pg_lo_export seem to work only
occasionaly.

The code is like this:
(php5, postgresql 8.2)
*****************
$no++; //Incerementing number of the image
pg_query("Begin");
$query = "select pic_data, accurateness_level, mime_type from image2 where
*****//condition clause";
$row = pg_fetch_row(pg_query($query));
// Get the image OID
$image = $row[0];
// Get the type of the picture
$type = $row[2];
// Export the picture into pic.type
pg_lo_export($image, "pic$no.$type");
//get image file dimensions
$dimensions = getimagesize("pic$no.$type");
$width = $dimensions[0];
$height = $dimensions[1];
// Show the picture
echo "<img src=\"pic$no.$type\" width=" . $width . " height=" .
$height . "/>";
pg_query("Commit");
*************

I understand that the script doesn't like the idea of saving files on
the server. However, why does it work at all?
Are there any other ways to export images from the database?

Any comments are welcome.

- Mike

Responses

Browse pgsql-php by date

  From Date Subject
Next Message Dave Page 2007-06-13 09:09:21 Re: php, postgresql and graphical images
Previous Message Ray Garrison 2007-06-08 17:17:05 Re: Application Design: Where to implement historical revisions of objects