Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
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

pgsql-php by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group