Hello! I have images stored in a MySQL Database. I can retrieve the images and display 
them without a problem, but I'd really like to be able to create thumbnails. The code 
that I've written just doesn't seem to work. Preferably, I'd like to pull the image 
from the database, and create the thumbnail for display, without ever writing an image 
to the disk. If this is not possible, I'd like to know alternate methods. I'm using 
imagemagick's convert utility to create the thumbs. Here is my code:


if($id) {
    $query = "select image,type from images where id=$id";
    $result = @MYSQL_QUERY($query);
    $data = @MYSQL_RESULT($result,0,"image");
    $type = @MYSQL_RESULT($result,0,"type");
    Header( "Content-type: $type");
    echo $data;


if ($id) {
          $src = getpic.php?id=$id;
          $thumb = passthru("convert -geometry 40% $src jpeg:-");
          print $thumb;

I know that getpic.php works.  I can use it in like this:   echo "<IMG 
SRC='getpic.php?id=$id'>"; and it will output the fullsize graphic in place. I'm 
trying to get to a point where I can use tgen.php in the same mannor. I can use the 
same convert command if I use an actual file, like pics/mypic.jpg and it works, so the 
command is good.....

any help at all would be very appreciated,

Jason Bell

Reply via email to