Page 1 of 1

Problem with thumbnail images

Posted: Thu Jan 23, 2003 12:04 am
by senthil
Hi,

I tried this sample program for creating thumbnails and storing in a database. I'm able to retrieve the original image from the database and display it. But I'm not able to display the thumbnail. The temp.jpg, temporary thumbnail, has the correct thumbnail image. Also, some binary data is being stored in the database. Could anyone tell me what is the problem.

Thanks
Senthil


MYSQL_CONNECT("localhost","root","password");
mysql_select_db("binary_data");

$im = imagecreatefromjpeg($form_data);
$im_width=imageSX($im);
$im_height=imageSy($im);
$new_height=100;
$new_width=$im_width / ($im_height / $new_height);

$temp=imagecreate($new_width,$new_height);
imagecopyresized($temp,$im,0,0,0,0,$new_width,$new_height,$im_width,$im_height);
imagejpeg($temp,"temp.jpg");

$thumbnail = addslashes(fread(fopen("temp.jpg", "r"), filesize("temp.jpg")));
$data = addslashes(fread(fopen($form_data, "r"), filesize($form_data)));

$result=MYSQL_QUERY("INSERT INTO binary_data (description,bin_data,filename,filesize,filetype,thumb_nail) ".
"VALUES ('$form_description','$data','$form_data_name','$form_data_size','$form_data_type','$thumbnail')");

MYSQL_CLOSE();