Thumbnails?
| From: | Lauri Vain | Date: | Thu, 21 Dec 2000 06:12:08 +0000 |
| Subject: | Thumbnails? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-31368@lists.php.net to get a copy of this message | ||
Hello everybody,
My code is the following... It draws JPEG body data from a DB... It should show
thumbnails (GD 1.8 should be correctly installed) but it seems to have a
problem. It's important I complete it before tomorrow.
(sorry for the whole code!)
<?
mysql_connect($mysqlhost, $mysqluser, $mysqlpassword) or die
($mysql_db_connect_error);
$pilt_q = mysql_db_query($mysqluser,"SELECT pilt,tyyp FROM saku_ehitus_pildid
WHERE idep='59'");
$pilt_k = mysql_fetch_array($pilt_q);
$pilt = $pilt_k["pilt"];
Header("Content-type: image/jpeg");
/******* TEST ******/
if($thumb=="1")
{
$src_img = imagecreatefromjpeg($pilt);
$new_w = imagesx($src_img)/4;
$new_h = imagesy($src_img)/4;
$dst_img = imagecreate($new_w,$new_h);
imagecopyresized($dst_img,$src_img,0,
0,0,0,$new_w,$new_h,imagesx($src_img),imagesy($src_img));
imagejpeg($dst_img,'',70);
print($dst_img);
ImageDestroy($dst_img);
ImageDestroy($src_img);
}
/******* TEST ******/
if($thumb=="2")
{
$src_img = imagecreatefromjpeg($pilt);
$dst_img = imagecreate(100,75);
imagecopyresized($dst_img,$src_img,0,
0,0,0,100,75,imagesx($src_img),imagesy($src_img));
imagejpeg($dst_img,'',70);
print($dst_img);
ImageDestroy($dst_img);
ImageDestroy($src_img);
}
/******* TEST ******/
if($thumb=="3")
{
$src_img = $pilt;
$dst_img = imagecreate(100,75);
imagecopyresized($dst_img,$src_img,0,
0,0,0,100,75,imagesx($src_img),imagesy($src_img));
imagejpeg($dst_img,'',70);
print($dst_img);
ImageDestroy($dst_img);
ImageDestroy($src_img);
}
if($thumb=="4")
{
print($pilt);
}
else
{
?>
<html>
<head><title>Pildid</title></head>
<body>
<table width="100%">
<tr>
<td>nr. 1</td>
<td><img src="pilt_minu.php3?thumb=1"></td>
</tr>
<tr>
<td>nr. 2</td>
<td><img src="pilt_minu.php3?thumb=2"></td>
</tr>
<tr>
<td>nr. 3</td>
<td><img src="pilt_minu.php3?thumb=3"></td>
</tr>
<tr>
<td>nr. 4</td>
<td><img src="pilt_minu.php3?thumb=4"></td>
</tr>
</table>
</body>
</html>
<?}?>
Yours,
Lauri