pg.ddx.io  pgsql-php@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Mihail Mihailov <Mihail.Mihailov@uta.fi>
To: pgsql-php@postgresql.org
Subject: php, postgresql and graphical images
Date: Wed, 13 Jun 2007 11:51:55 +0300
Message-ID: <20070613115155.uykzmxtvxueoo4w8@imp3.uta.fi> (raw)

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



view thread (6+ messages)  latest in thread

Message-ID: <20070613115155.uykzmxtvxueoo4w8@imp3.uta.fi>
Permalink:  ../20070613115155.uykzmxtvxueoo4w8@imp3.uta.fi/
Also on:    postgresql.org/message-id/20070613115155.uykzmxtvxueoo4w8@imp3.uta.fi

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-php@postgresql.org
  Cc: Mihail.Mihailov@uta.fi
  Subject: Re: php, postgresql and graphical images
  In-Reply-To: <20070613115155.uykzmxtvxueoo4w8@imp3.uta.fi>
  References: <20070613115155.uykzmxtvxueoo4w8@imp3.uta.fi>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox