$x) { $riduzione = $width / $x; $new_height = $height / $riduzione; $new_width = $x; } } } else if($_REQUEST['o']==2) { if ($width>$height) { // formato landscape $new_width=$x; if (($height*$new_width/$width)>$y) { $new_height=$y; $new_width=$width*$new_height/$height; } else { $new_width=$x; $new_height=$height*$new_width/$width; } } else if ($width<$height) { // formato portrait $new_height=$y; $new_width=$width*$new_height/$height; } else if ($width==$height) { // formato quadrato $limite=$x>$y?$y:$x; $new_width=$limite; $new_height=$height*$new_width/$width; } } else if($_REQUEST['o']==3) { // formato forzato $new_width=$x; $new_height=$y; } else if($_REQUEST['o']==4) { //$thumb_image_name, $image, $width, $height, $start_width, $start_height, $scale list($source_width, $source_height) = getimagesize($fname); if (($source_width / $source_height) == ($x / $y)) { $source_x = 0; $source_y = 0; } if (($source_width / $source_height) > ($x / $y)) { $source_y = 0; $temp_width = $source_height * $x / $y; $source_x = ($source_width - $temp_width) / 2; $source_width = $temp_width; } if (($source_width / $source_height) < ($x / $y)) { $source_x = 0; $temp_height = $source_width * $y / $x; $source_y = ($source_height - $temp_height) / 2; $source_height = $temp_height; } header("Content-type: image/$ext"); header('Last-Modified: ' . gmdate('D, d M Y H:i:s', filemtime($fname)) . ' GMT'); $image_p = imagecreatetruecolor($x, $y); imagecopyresampled($image_p,$image,0,0,$source_x,$source_y,$x,$y,$source_width,$source_height); imagejpeg($image_p,'',100); imageDestroy($image); imageDestroy($image_p); exit; } else { if ($height > $width) { $riduzione = $width / $x; $new_height = $height / $riduzione; $new_width = $x; } else { $riduzione = $width / $x; $new_height = $height / $riduzione; $new_width = $x; if($new_height>$y) { $riduzione = $height / $y; $new_width = $width / $riduzione; $new_height = $y; } } } } $image_p = imagecreatetruecolor($new_width, $new_height); /* if($riga['tipo']=="gif") { $colore = imagecolorallocate($image_p, 0x53, 0x82, 0xC6); imagefill($image_p, 0, 0, $colore); imagefilledrectangle($image_p, 0, 0, $new_width, $new_height, 0x5382C6); } */ imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height); header("Content-type: image/$ext"); header('Last-Modified: ' . gmdate('D, d M Y H:i:s', filemtime($fname)) . ' GMT'); switch($riga['tipo']) { case 'jpg': $ext = "jpeg"; imagejpeg($image_p, '', 100); break; case 'gif': $ext = "gif"; imagegif($image_p); break; } imageDestroy($image); imageDestroy($image_p); ?>