codice:
list ($width, $height) = getimagesize("images/42-15195172.jpg");
//l'immagine di partenza è 640 X 430
$maxwidth = 20;
$maxheight = 80;
$orig_img = imagecreatefromjpeg("images/42-15195172.jpg");
if ($width < $height) {
$width1 = ceil (($maxheight / $height) * $width);
$height1 = $maxheight;
} else {
$height1 = ceil (($maxwidth / $width) * $height);
$width1 = $maxwidth;
}
$im_out = imagecreatetruecolor($maxwidth,$maxheight);
imagecopyresampled($im_out, $orig_img, 0, 20, 0, 0, $width1, $height1, $width, $height);
imagepng($im_out, "images/31333.png",'120');
Cosa succede? L'immagine si adatta ai 20px in larghezza, ma mantiene le proporzioni sul verticale!! Io desidero che lui prenda solo la porzione d'immagine (naturalmente ridimensionata) coprendo però tutta l'area dell'immagine new.