1) setcookie
.. ho trovato l'errore
setcookie("stile","bl",time()+(3600*24*30),"/",$_SERVER["HTTP_POST"],0);
al posto di $_SERVER["HTTP_POST"] avevo messo $_SERVER["REMOTE_ADDR"]; in locale è la stessa cosa ma naturalmente sono due indirizzi molto diversi
2) uso solo le minuscole
la cosa che mi fa impazzire è che la funzione getimagesize() lanciata come segue mi restituisce width/height
$src_file = "http://".$_SERVER["HTTP_HOST"]."/test/".$immagine ;
$imginfo = getimagesize($src_file);
$srcwidth = $imginfo[0];
$srcheight = $imginfo[1];
ne sono certo perché la lancio prima della funzione che crea il thumbnail e visualizzo le dimensioni nella pagina HTML
Il resto sembra non funzionare:
così lancio la funzione
echo "<img src=\"scripts/itthumb.php?src=$img&whmax=$maxdim\" border=\"0\" width=\"$dest_width\" height=\"$dest_height\">";
FUNZIONE PHP:
$it_gif = 1;
$it_jpg = 2;
$immagine=$_GET["src"];
$src_file = "http://".$_SERVER["HTTP_HOST"]."/test/".$immagine ;
$destmax = (int)$_GET["whmax"];
// inizio procedura
$imginfo = getimagesize($src_file);
$srcwidth = $imginfo[0];
$srcheight = $imginfo[1];
if ($srcheight < $srcwidth)
{
$destwidth = $destmax;
$destc = $destwidth * ($srcheight / $srcwidth);
$destheight = (int)$destc;
} else {
$destheight = $destmax;
$destc = $destheight * ($srcwidth / $srcheight);
$destwidth = (int)$destc;
}
if ($imginfo[2] == $it_jpg )
{
$src_img = imagecreatefromjpeg($src_file);
}
if ($imginfo[2] == $it_gif )
{
$src_img = imagecreatefromgif($src_file);
}
$dst_img =imagecreatetruecolor( $destwidth, $destheight);
imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $destwidth, (int)$destheight, $srcwidth, $srcheight);
if ($imginfo[2] == $it_jpg )
{
imagejpeg($dst_img);
}
if ($imginfo[2] == $it_gif )
{
imagegif($dst_img);
}
imagedestroy($src_img);
imagedestroy($dst_img);
?>

Rispondi quotando