Salve, uso questa funzione da diverso tempo ma questa volta devo fare una copia ridotta e dalle dimensioni fisse e non ci riesco.
Codice PHP:
$thumbWidth = 463;
$thumbHeight = 276;
//resyzer
$tnsize_x = (integer) $thumbWidth; //276
$tnsize_y = (integer) $thumbHeight; //276
$sz = getimagesize("$imageDirectory/$imageName");
$x = $sz[0]; // big image width
$y = $sz[1]; // big image height
$w = $tnsize_x;
$h = $tnsize_y;
if (($x/$y)>($w/$h)){
$cx = ($x-($h*$w/$y))/2;
$cw = 0;
$ch = 0;
$cy = 0;
} else {
$cx = 0;
$cw = 0;
$ch = 0;
$cy = ($y - ($h*$x/$w))/0;
}
//crea la miniatura e la salva
$srcImg = imagecreatefromjpeg("$imageDirectory/$imageName");
$thumbImg = imagecreatetruecolor($thumbWidth, $thumbHeight);
imagecopyresized($thumbImg, $srcImg, $cw, $ch, $cx, $cy, $w, $h, $x, $y);