Subject Re: Show a Jpg stored as Binary blob in a firebird table with PHP
Author prom_prometheus
thank you Didier for you long answer ...

i) -> to handle blobs in Firebird (or Interbase) is for me no
problem, also not in Backup/Restore, i do it with, whole
Programms (for automatical updates) and so on ... since many years
-> so i will use this wonderfull database also for my php-apps.
Till now i used MySql for php-apps, but my whole software system is
based on firebird delphi client/Server applications (db size: 1.7GB,
60 high updating concurent users, etc.), so its clear to go with
firebird on php-apps too !!

ii) i tried now many things to show JPGs (blobs from db) with php,
but i had no success, my last trying:

class ibase_blob {
var $blobid;
var $length;
var $numseg;
var $maxseg;
var $stream;
var $isnull;
var $data;

function ibase_blob($blobid) {
$this->blobid = $blobid;

function retrieve_all() {

function retrieve_info() {

function retrieve_data($size='1024') {
if ($bl) {
while($buf = ibase_blob_get($bl, $size)) {
$this->data .= $buf;

$res = ibase_query($sst, $f);
if(empty($res)) echo SQL_error($f,$sst)."<BR>";
$rowx = ibase_fetch_row($res);

$bl = new ibase_blob($rowx[0]);

//here is the problem: till this step it seems to work ....
$foto = imagecreatefromstring($bl->data);
//---following comes: Warning: Data is not in a recognized format.
imagejpeg($foto, "foto.jpg");
print "<img border='0' src='foto.jpg' width='512' height='384'>";

uff, where is a way?
best regards

--- In, "Didier Gasser-Morlay"
<Didiergm@n...> wrote:
> --- In, "prom_prometheus"
> <prometheus@a...> wrote:
> > Hello,
> > can someone help me?
> Can try ;) but this is more a PHP question than anything else.
> > I try to make a webpage (PHP4, Firebird 1.5 b3, Apace WEbserver)
> > and have the following problem:
> > show pictures that was stored in a table as binary blob
> > ...,
> > GID integer not null,
> > ...
> > echo row->grund_foto didn't work, smile ...
> 1°) have a look at -> REALLY good &
> db wrapper. John Lim is a clever guy ! there is some support for
> 2°) the answer mainly depends on your circumstances : hosting,
> standard or secure (HTTPS), your level of access to the host, what
> really intend to do (ie show the image as such, on it's own, or as
> part of a more complex layout (e.g. say it's a shot of a product
on a
> product page)
> In the long run, I believe that the simplest/more reliable would
be to
> 1- write the blob to disk as a file (xxx.jpg is it's a jpeg) and
> 2- send a HREF link to it as part of an IMG tag. this way your turn
> around a really difficult long standing IE bug when you try to PUSH
> some data to your user's browser.
> 3°) now, that being said ... you should also consider whether or
> is is worthwhile having the images INSIDE the db, and not simply
> a link to those, stored on disk. Again this depends on many factors
> but remember that blobs tend to ... bloat a db pretty swiftly,
> a backup & restore process that much more difficult (look at the
> current thread on gbak on firebird-support)
> > thanks
> You'll thank me if I made sense at all! :)
> Didier
> > -Gerhard