Ho trovato questo script:

codice:
$nw=50; //The Width Of The Thumbnails
$nh=50; //The Height Of The Thumbnails

$ipath = "pics/"; //Path To Place Where Images Are Uploaded. No Trailing Slash
$tpath = "pics/thumbnails";//Path To Place Where Thumbnails Are Uploaded. No Trailing Slash

$img_name = $ipath."img1.jpg";

$dimensions = GetImageSize($img);

//$thname = "$tpath/$img_name";
$thname = "$img_name";

$w=$dimensions[0];
$h=$dimensions[1];

$img2 = ImageCreateFromJpeg($img);
$thumb=ImageCreateTrueColor($nw,$nh);
	
$wm = $w/$nw;
$hm = $h/$nh;
	
$h_height = $nh/2;
$w_height = $nw/2;
	
if($w > $h){
	
	$adjusted_width = $w / $hm;
	$half_width = $adjusted_width / 2;
	$int_width = $half_width - $w_height;
	
	ImageCopyResampled($thumb,$img2,-$int_width,0,0,0,$adjusted_width,$nh,$w,$h); 
	ImageJPEG($thumb,$thname,95); 
	
}elseif(($w < $h) || ($w == $h)){
	
	$adjusted_height = $h / $wm;
	$half_height = $adjusted_height / 2;
	$int_height = $half_height - $h_height;
	
	touch($thname);
	ImageCopyResampled($thumb,$img2,0,-$int_height,0,0,$nw,$adjusted_height,$w,$h); 
	ImageJPEG($thumb,$thname,95); 
	
}else{
	ImageCopyResampled($thumb,$img2,0,0,0,0,$nw,$nh,$w,$h); 	
	ImageJPEG($thumb,$thname,95); 
}

imagedestroy($img2);
?>

Utilizzando un:

echo "<img src=\"$thumb\">";

Non ottengo l'output dell'immagine. La cartella "thumbnails" sul server è vuota e, verificando la variabile $thumb, mi restituisce un "Resource id #6".


Come faccio a visualizzare l'immagine croppata?

grazie