Ciao, mi sono imbattuto in questo 3d e posto quello che ho modificato per ottenere miniature tutte uguali (quadrato 100 x 100 pixel) con all'interno le mie thumb centrate:
list($width, $height, $type, $attr) = getimagesize($path);
$old_x = $width;
$old_y = $height;
$new_w = 100;
$new_h = 100;
$ratio1=$old_x/$new_w;
$ratio2=$old_y/$new_h;
if($ratio1>$ratio2) {
$thumb_w=$new_w;
$thumb_h=$old_y/$ratio1;
$distanza_w = 0;
$distanza_h = (100 - $thumb_h) / 2;
}
else {
$thumb_h=$new_h;
$thumb_w=$old_x/$ratio2;
$distanza_w = (100 - $thumb_w) / 2;
$distanza_h = 0;
}
$nomeimage = "m_".$fnome;
$source_path = $pathf;
$dest_path = $pathfmini;
//print($thumb_w." ".$thumb_w);
$destimg = imagecreatetruecolor(100, 100);
$srcimg = ImageCreateFromJPEG($source_path.$fnome);
ImageCopyResized($destimg,$srcimg,$distanza_w,$dis tanza_h,0,0,$thumb_w,$thumb_h,ImageSX($srcimg),Ima geSY($srcimg));
ImageJPEG($destimg,$dest_path.$nomeimage,100);
Però lo sfondo dell'immagine creata dal php è nero... e se io lo volessi di un'altro colore?