...magari ha l'esigenza di farlo da php?Originariamente inviato da adamsrolando
gd, imagemagic ...... o altri mille tools e poi fare l'upload???![]()
cmq io usavo questa funzione:
lavora bene ma solo sui jpg.. cmq è un attimo fargli prendere anche i gif...Codice PHP://'par' può essere W per larghezza, h per altezza, 'quanto' è il valore di 'par'
function resize($nomeimage, $source_path, $destination_path, $par, $quanto){
list($width, $height, $type, $attr) = getimagesize($source_path.$nomeimage);
if($type==2){
if($par=="w"){
if($width > $quanto){
$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;
}
}else if($par=="h"){
if($height > $quanto){
$conv=$width/$height;
$new_height=$quanto;
$new_width=$conv*$new_height;
$new_width=number_format($new_width, 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");
}
}

Rispondi quotando