$photo_aspect) { // scale by limiting y $y = intval($_REQUEST['y']); } else { // scale by limiting x $y = intval($_REQUEST['x'] / $photo_aspect); } } else { $y = $_REQUEST['y']; } } else { if ($_REQUEST['x']) { // only x $y = round($_REQUEST['x'] / $photo_aspect); } else { // dont scale $y = $photo_y; } } if ($y != $photo_y) { if (!file_exists($bcms['sitepath'] . "/photos/" . $rrp['fname'] . '.c' . $y)) { $src_photo = imagecreatefromjpeg($bcms['sitepath'] . "/photos/" . $rrp['fname']); $x = round(($y/$photo_y) * $photo_x); $dst_photo=ImageCreateTrueColor($x,$y); imagecopyresampled($dst_photo,$src_photo,0,0,0,0,$x,$y,$photo_x,$photo_y); header("Content-type: image/jpeg"); imagejpeg($dst_photo,'',80); imagejpeg($dst_photo, $bcms['sitepath'] . "/photos/" . $rrp['fname'] . '.c' . $y ,90); // cache thumbnail } else { // from cache header("Content-type: image/jpeg"); echo file_get_contents($bcms['sitepath'] . "/photos/" . $rrp['fname'] . '.c' . $y); } } else { header("Content-type: image/jpeg"); echo file_get_contents($bcms['sitepath'] . "/photos/" . $rrp['fname']); } ?>