Hello list,

I've been stumped on this for a while, I have a large project where I am
storing image data in a MySQL db for reasons I will not get into.  The
images are displayed as thumbnails in a table which are hyperlinks to a
large file.  The larger file is stored in the db as a BLOB type in GIF
format.  I have a nice freeware program for creating thumbnails called
gifsicle.  I thought the following code would work:

// connect to db, set up SQL, etc. etc. etc.
$image = $row["image_data"]; // this is the binary GIF image data

Header ("Content-type: image/gif");
if ($view_type == "thumbnail") {
   passthru ("/usr/bin/gifsicle --resize 320x240 < " . $image);
}
echo $image;
flush();

This script works if called to view an image in full size, but if
$view_type is set to "thumbnail" and the passthru command is executed,
nothing is displayed.  gifsicle generally works like
this: /usr/bin/gifsicle --resize NNNxNNN < src_image > out_image.  I have
tried using system and exec as well, nothing seems to work except the
following:

$fp = fopen("/tmp/tmp.gif","w");
fwrite($fp, $image);
fclose($fp);
passthru("/usr/bin/gifsicle --resize 320x240 < /tmp/tmp.gif");

This adds a LOT of file system I/O though as it has to write each full
sized image stored in the db /tmp and slows things down quite a bit.  Does
anyone have any other suggestions?  My goal is to store only one version of
each image file and create smaller versions on the fly.

PHP is 4.1.2 on a SuSE Linux 7.3 box, latest Apache server, MySQL 3.23.44.

Thanks for your help!

Josh Trutwin








-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to