Image Resizer
I have had the need to work with images on php sites from time to time. I have always had problems with images but found a solution. I copied and pasted so there may be some irrelevant pieces but you should get the idea.
This is the link to the page that nailed it for me:
http://blog.briandichiara.com/image-thumbnail-creator/
His refrence is: http://tech.mikelopez.info/2006/03/02/php-image-resize-script/
This is what I did with it to make it dynamic from a database. Loop through the recordset and dynamically set up the thumbnails with links to swap the larger image with one of the thumbnails.
while($row_act = mysql_fetch_array($result_select))
{
if ($row_act[’filetype’]==’Photo’)
{
if ($number == 1)
{
$setup = ‘yes’;
$image = str_replace(”../”, “”, $row_act[’filename’]);
echo(”<div class=’currentpicture mediumgreytext’>”.$_GET[”f”].” ”.$_GET[”l”].”<br>”);
echo(”<img src=’image_2.php?src=”.$image.”&thumb&h=420&w=340′ border=’0′ alt=’”.$_GET[”f”].” ”.$_GET[”l”].”‘ name=\”mainimg\” />”);
echo(”</div>”);
$number ++;
echo(”<div class=’smallpics smallgreytext’>”);
echo(”<img src=\”image_2.php?src=”.$image.”&thumb&h=110\” border=’0′ alt=’”.$_GET[”f”].” ”.$_GET[”l”].”‘ onmouseover=\”roll_over(’mainimg’, ‘image_2.php?src=”.$image.”&thumb&h=420&w=340′)\”/> ”);
}
else
{
$image = str_replace(”../”, “”, $row_act[’filename’]);
echo(”<img src=\”image_2.php?src=”.$image.”&thumb&h=110\” border=’0′ alt=’”.$_GET[”f”].” ”.$_GET[”l”].”‘ onmouseover=\”roll_over(’mainimg’, ‘image_2.php?src=”.$image.”&thumb&h=420&w=340′)\”/> ”);
}
}
}
In production when you mouse over the small thumbnail the larger picture changes. you can restrain the size of the picture so it will not throw things off balance.

Tags: php image resize