ecco, questa è più semplice
Codice PHP:
function resize_first($nomeimage, $source_path, $destination_path){
list($width, $height, $type, $attr) = getimagesize($source_path.$nomeimage);
if($type==2){
if($width > $quanto){
$quanto=300;
$conv=$height/$width;
$new_width=$quanto;
$new_height=$conv*$new_width;
$new_height=number_format($new_height, 0);
}else{
$new_width = $width;
$new_height = $height;
}
$compression=100;
$destimg=imagecreatetruecolor($new_width,$new_height) or die("Problemi nelle creazioni dell'immagine");
$srcimg=ImageCreateFromJPEG($source_path.$nomeimage) or die("Problemi nell'aprire l'immagine");
ImageCopyResampled($destimg,$srcimg,0,0,0,0,$new_width,$new_height,ImageSX($srcimg),ImageSY($srcimg)) or die("Problemi nel ridimensionamento");
ImageJPEG($destimg,$destination_path.$nomeimage,$compression) or die("Problemi nel salvataggio");
}
}