A
Anonymous
Guest
Hi, i have tried this "thumbnail on the fly" script, but doesn't work; it seems that i must copy the mysql image to a temp file in order to use the "ImageCreateFromJPEG" function correctly. Does anybody know how to do this preliminar operation?
here is my script:
<?php
mysql_connect("localhost", "root", "password");
mysql_select_db("yourDB");
$query = "select bin_data,filetype from youTABLE where fid=$id";
$result = mysql_query($query);
$data = mysql_result($result,0,"bin_data");
$type = mysql_result($result,0,"filetype");
Header("Content-type: $type");
$src = imagecreatefromjpeg($data);
// HERE IS THE PROBLEM:
// instead of using $data, i should use a filename
// HELP!
$twidth = imagesx($src)/3;
$theight = imagesy($src)/3;
$img = imagecreate($twidth,$theight);
imagecopyresized($img,$src,0,0,0,0,$twidth,$theight,imagesx($src),imagesy($src));
imagejpeg($img);
imagedestroy($img);
?>
here is my script:
<?php
mysql_connect("localhost", "root", "password");
mysql_select_db("yourDB");
$query = "select bin_data,filetype from youTABLE where fid=$id";
$result = mysql_query($query);
$data = mysql_result($result,0,"bin_data");
$type = mysql_result($result,0,"filetype");
Header("Content-type: $type");
$src = imagecreatefromjpeg($data);
// HERE IS THE PROBLEM:
// instead of using $data, i should use a filename
// HELP!
$twidth = imagesx($src)/3;
$theight = imagesy($src)/3;
$img = imagecreate($twidth,$theight);
imagecopyresized($img,$src,0,0,0,0,$twidth,$theight,imagesx($src),imagesy($src));
imagejpeg($img);
imagedestroy($img);
?>