Forum Moderators: not2easy
<img src="thumbnails.html?file=<? echo $photo; ?>&maxw=300&maxh=300" border="0"><br>
<a class="nonThumbnail" href="#thumb"><img src="images/magnify.png" border="0"><span><img src="thumbnails.html?file=<? echo $photo; ?>&maxw=600&maxh=600"></span></a>
<?
$sImagePath = $_GET["file"];
$iThumbnailWidth = (int)$_GET['width'];
$iThumbnailHeight = (int)$_GET['height'];
$iMaxWidth = (int)$_GET["maxw"];
$iMaxHeight = (int)$_GET["maxh"];
if ($iMaxWidth && $iMaxHeight) $sType = 'scale';
else if ($iThumbnailWidth && $iThumbnailHeight) $sType = 'exact';
$img = NULL;
$sExtension = strtolower(end(explode('.', $sImagePath)));
if ($sExtension == 'jpg' || $sExtension == 'jpeg' || $sExtension == 'pjpeg') {
$img = @imagecreatefromjpeg($sImagePath)
or die("Cannot create new JPEG image");
} else if ($sExtension == 'png') {
$img = @imagecreatefrompng($sImagePath)
or die("Cannot create new PNG image");
} else if ($sExtension == 'gif') {
$img = @imagecreatefromgif($sImagePath)
or die("Cannot create new GIF image");
}
if ($img) {
$iOrigWidth = imagesx($img);
$iOrigHeight = imagesy($img);
if ($sType == 'scale') {
$fScale = min($iMaxWidth/$iOrigWidth,
$iMaxHeight/$iOrigHeight);
if ($fScale < 1) {
$iNewWidth = floor($fScale*$iOrigWidth);
$iNewHeight = floor($fScale*$iOrigHeight);
$tmpimg = imagecreatetruecolor($iNewWidth,
$iNewHeight);
imagecopyresampled($tmpimg, $img, 0, 0, 0, 0,
$iNewWidth, $iNewHeight, $iOrigWidth, $iOrigHeight);
imagedestroy($img);
$img = $tmpimg;
}
} else if ($sType == "exact") {
$fScale = max($iThumbnailWidth/$iOrigWidth,
$iThumbnailHeight/$iOrigHeight);
if ($fScale < 1) {
$iNewWidth = floor($fScale*$iOrigWidth);
$iNewHeight = floor($fScale*$iOrigHeight);
$tmpimg = imagecreatetruecolor($iNewWidth,
$iNewHeight);
$tmp2img = imagecreatetruecolor($iThumbnailWidth,
$iThumbnailHeight);
imagecopyresampled($tmpimg, $img, 0, 0, 0, 0,
$iNewWidth, $iNewHeight, $iOrigWidth, $iOrigHeight);
if ($iNewWidth == $iThumbnailWidth) {
$yAxis = ($iNewHeight/2)-
($iThumbnailHeight/2);
$xAxis = 0;
} else if ($iNewHeight == $iThumbnailHeight) {
$yAxis = 0;
$xAxis = ($iNewWidth/2)-
($iThumbnailWidth/2);
}
imagecopyresampled($tmp2img, $tmpimg, 0, 0,
$xAxis, $yAxis,
$iThumbnailWidth,
$iThumbnailHeight,
$iThumbnailWidth,
$iThumbnailHeight);
imagedestroy($img);
imagedestroy($tmpimg);
$img = $tmp2img;
}
}
header("Content-type: image/jpeg");
imagejpeg($img);
}
?>
<style type="text/css">
.iwZoomBox { float:left; position:relative; top:0; left:0;
width:300px; z-index:1; overflow:visible; }
.iwZoom { position:relative; top:0; left:0; width:300px; z-index:1; text-align:center; }
.iwZoom:hover > div { display:block; }
.iwZoom div { position:absolute; top:0; left:302px; width:600px; display:none; z-index:2; }
</style>
<div class="iwZoomBox">
<div class="iwZoom">
<img src="thumbnails.html?file=<? echo $photo; ?>&maxw=300&maxh=300" alt=""><br>
<img src="images/magnify.png" alt="">
<div><img src="thumbnails.html?file=<? echo $photo; ?>&maxw=600&maxh=600"></div>
</div><!-- end .iwZoom -->
</div><!-- end .iwZoomBox -->