I have a image resize script for creating thumbnails on the fly, but I need to pass the filename to the script. Just can't figure it out.
Resize Script: resize.php
Rendering Script: index.php
I have tried using:
<img src="Gallery/resize.php?filename=$filename">
and
<img src="<?php include("Gallery/resize.php");?>">
index.php
<?php
$sql = mysql_query("SELECT * FROM gallery WHERE catID = $catID ORDER BY id DESC") or die (mysql_error());
while ($row = mysql_fetch_array($sql)) {
$filename = $c["catName"]."/".$row["filename"];
?>
<tr>
<td valign="top">
<table border="0" cellspacing="0" cellpadding="1">
<tr>
<td align="center"><img src="Gallery/resize.php"></td>
</tr>
</table>
</td>
</tr>
<?php
}
?>
resize.php
<?php
$imgfile = "Gallery/".$filename;
Header("Content-type: image/jpeg");
list($width, $height) = getimagesize($imgfile);
$newheight = 80;
$newwidth = (int) (($width*$newheight)/$height);
$thumb = imagecreatetruecolor($newwidth,$newheight);
$source = imagecreatefromjpeg($imgfile);
imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
$imgout = imagejpeg($thumb);
echo $imgout;
?>
Please help me.
Thanks