$source = $_GET['src']; $filename = explode("/", $source); $thumb_height = 120; $thumb_width = 120; $folder = "thumb/"; if($_GET['type'] == 'landscape') { $thumb_width = 216; $thumb_height = 160; $folder = $_GET['type'].'/'; } if($_GET['type'] == 'landscape-big') { $thumb_width = 248; $thumb_height = 184; $folder = $_GET['type'].'/'; } if($_GET['type'] == 'globophoto') { $thumb_width = 179; $thumb_height = 179; $folder = $_GET['type'].'/'; } if($_GET['type'] == 'mapthumb') { $thumb_width = 70; $thumb_height = 70; $folder = $_GET['type'].'/'; } if(!file_exists('thumbcache/'.$folder.$filename[1])) { $size = getimagesize($source); $width = $size[0]; $height = $size[1]; if($width> $height) { $x = ceil(($width - $height) / 2 ); $width = $height; } elseif($height> $width) { $y = ceil(($height - $width) / 2); $height = $width; } $new_im = ImageCreatetruecolor($thumb_width,$thumb_height); $im = imagecreatefromjpeg($source); imagecopyresampled($new_im,$im,0,0,$x,$y,$thumb_width,$thumb_height,$width,$height); imagejpeg($new_im,'thumbcache/'.$folder.$filename[1],100); header('Content-Type: image/jpeg'); imagejpeg($new_im,null,100); } else { $im = imagecreatefromjpeg('thumbcache/'.$folder.$filename[1]); header('Content-Type: image/jpeg'); imagejpeg($im,$dest,100); }