"/global/portfolio_objects/large/", "pfc"=>"/global/portfolio_objects/cat_pic/"); $path = array("cli"=>"/global/portfolio_objects/client/", "cat"=>"/global/portfolio_objects/category/", "pro"=>"/global/portfolio_objects/product/"); $img_name = (isset($_GET['im_na'])? trim($_GET['im_na']): ""); $pa_name = (isset($_GET['pa_na'])? trim($_GET['pa_na']): ""); $pa_name = (array_key_exists($pa_name, $path)? $path[$pa_name]: ""); define("IMAGE_BASE", $_SERVER['DOCUMENT_ROOT']); define("MAX_WIDTH", 130); define("MAX_HEIGHT", 160); $image_path = IMAGE_BASE ."$pa_name" . $img_name; //echo("$image_path") ; exit(); $img = NULL; $ext = strtolower(end(explode('.', $image_path))); if ($ext == 'jpg' || $ext == 'jpeg') { $img = @imagecreatefromjpeg($image_path); } else if ($ext == 'png') { $img = @imagecreatefrompng($image_path); # Only if your version of GD includes GIF support } else if ($ext == 'gif') { $img = @imagecreatefromgif($image_path); } # If an image was successfully loaded, test the image for size if (!$img) { $img = imagecreate(MAX_WIDTH, MAX_HEIGHT); imagecolorallocate($img,100,100,100); $c = imagecolorallocate($img,0,0,0); imageline($img,0,0,MAX_WIDTH,MAX_HEIGHT,$c); imageline($img,MAX_WIDTH,0,0,MAX_HEIGHT,$c); } else{ # Get image size and scale ratio $width = imagesx($img); $height = imagesy($img); $scale = min(MAX_WIDTH/$width, MAX_HEIGHT/$height); # If the image is larger than the max shrink it if ($scale < 1) { $new_width = floor($scale*$width); $new_height = floor($scale*$height); # Create a new temporary image $tmp_img = imagecreatetruecolor($new_width, $new_height); # Copy and resize old image into new image imagecopyresized($tmp_img, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height); imagedestroy($img); $img = $tmp_img; } } /*if ($ext == 'jpg' || $ext == 'jpeg'){*/ header("Content-type: image/jpeg"); imagejpeg($img, '', 72); /*} elseif ($ext == 'png'){ header("Content-type: image/png"); imagepng($img, '', 72); } elseif ($ext == 'gif'){ header("Content-type: image/gif"); imagegif($img, '', 72); }*/ ?>