$rapporto_ottimale ){ // è una foto verticale $y = 93; $x = floor(($y*$orig_x)/$orig_y); } else { // è una foto orizzontale $x = 125; $y = floor(($x*$orig_y)/$orig_x); } $img = imagecreatetruecolor($x, $y); imagecopyresampled($img, $orig, 0, 0, 0, 0, $x, $y, $orig_x, $orig_y); switch($tipo) { case 'video': if($new) $wm = imagecreatefrompng("../images/thumb_play_new.png"); else $wm = imagecreatefrompng("../images/thumb_play.png"); imageAlphaBlending($wm, true); imageSaveAlpha($wm, true); addWM($img,$wm); break; case 'foto': if($new) { $wm = imagecreatefrompng("../images/thumb_new.png"); imageAlphaBlending($wm, true); imageSaveAlpha($wm, true); addWM($img,$wm); } break; default: break; } $cache = "../cache/".$nomecache; header("Content-type: image/JPG"); imageJPEG($img, '', 100); imageJPEG($img, $cache, 100); imagedestroy($img); } if ( isset($_GET['n']) && isset($_GET['cache']) ){ resize_image($_GET['n'], $_GET['cache']); } // ./comuni/thumb_photo.php?n=../photo/121020113041.jpg&cache=foto_other_2_0.jpg function addWM(&$imgres, &$imgWM){ imagecopy($imgres, $imgWM, 0, 0, 0, 0, imageSX($imgWM), imageSY($imgWM)); } ?>