need a replacment!!
Posted: Thu Mar 02, 2006 11:50 am
Hi all I'm looking for some replacement code for the following
The above code creates a table of thumbnails from a given directory. My problem is that the resizing of the iages takes place client side. and if the dir has a lot of large images, this can take a very long time to download and display all the images.
I'm looking for a method of resizing the images (jpg/jpeg/gif/png/bmp) server side, before they are send to the client, and if at all possible without copying/resizing the origanl image on the server or using gd. Just create the thumbs dynamicaly when the script is called, then remove them when the script ends.
any ideas?
Code: Select all
$fileList = $this->getFileList();
$imageMaxRatio = $this->imageMaxWidth / $this->imageMaxHeight;
$numFiles = sizeof ($fileList);
echo ("<table width=100%>");
for ($i=0; $i<$numFiles;)
{
echo "<tr>";
for ($cols=1; $cols<=$this->maxcols; $cols++)
{
$out =" <td align=center>";
$imageFileName = $fileList[++$i];
if (strlen($imageFileName)>0)
{
$imagePath = $this->pathToGallery."/".$imageFileName;
$imageSize = GetImageSize ($imagePath);
if ($imageSize)
{
$imageWidth = $imageSize[0];
$imageHeight = $imageSize[1];
$imageRatio = $imageWidth / $imageHeight;
if ($imageRatio > $imageMaxRatio)
{
$imageOutputWidth = $this->imageMaxWidth;
$imageOutputHeight = ceil ($this->imageMaxWidth/$imageWidth*$imageHeight);
}
else if ($imageRatio < $imageMaxRatio)
{
$imageOutputHeight = $this->imageMaxHeight;
$imageOutputWidth = ceil ($this->imageMaxHeight/$imageHeight*$imageWidth);
} else
{
$imageOutputWidth = $this->imageMaxWidth;
$imageOutputHeight = $this->imageMaxHeight;
}
$out .= "<a href=\"".$imagePath."\"";
// check to see if link to open in a window or not
if ($this->window ==1){ $out .= "target=\"_blank\">";}
$out .= "<img src=\"".$imagePath;
$out .= "\" width=\"".$imageOutputWidth;
$out .= "\" height=\"".$imageOutputHeight;
$out .= "\" border=\"0\"><br>";
$out .= $fileList[$i]."</a>";
echo $out;
}
echo "</td>";
}
}
echo "</tr>";
}I'm looking for a method of resizing the images (jpg/jpeg/gif/png/bmp) server side, before they are send to the client, and if at all possible without copying/resizing the origanl image on the server or using gd. Just create the thumbs dynamicaly when the script is called, then remove them when the script ends.
any ideas?