need a replacment!!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
modplod
Forum Commoner
Posts: 45
Joined: Mon Feb 27, 2006 11:18 am

need a replacment!!

Post by modplod »

Hi all I'm looking for some replacement code for the following

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>";
			}
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?
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

viewtopic.php?t=39883

Onion2k has some great image snipplets in our Code Snipplet forum
modplod
Forum Commoner
Posts: 45
Joined: Mon Feb 27, 2006 11:18 am

Post by modplod »

cool I check them out, thanks for your info.
Post Reply