Salve a tutti!
io utilizzo questa funzione per ridimensionare le mie immagine durante l'upload sul server:
Codice PHP:
function resize($source_file, $output_file, $size, $quality)
{
//jpeg resizer
$success = false;
list($width, $height) = getimagesize($source_file);
$new_width = intval(($width * $size) / max($width, $height));
$new_height = intval(($height * $size) / max($width, $height));
if ( $image_in = imagecreatefromjpeg($source_file) )
{
if ( $image_out = imagecreatetruecolor($new_width, $new_height) )
{ imagecopyresampled($image_out, $image_in, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
if ( imagejpeg($image_out, $output_file, $quality) )
{
$success = true;
}
imagedestroy($image_out);
}
imagedestroy($image_in);
}
return $success;
}
Però in questo caso mi ridimensiona il lato pià lungo e lo porta lla dimensione che decido io.
Invece vorrei che il lato che voglio ridimensionare sia sempre l'altezza e che la lunghezza si proporzioni di conseguenza.
come posso fare?
Grazie in anticipo a tutti