$wmax) { $new_width=$wmax; $new_height = $height *( $new_width / $width); $pop_width=1024; $pop_height = $height *( $pop_width / $width); } //se troppo alta if ($new_height > $hmax ) { $new_height=$hmax; $new_width = $width * ( $new_height / $height); $pop_height=768; $pop_width = $width * ( $pop_height / $height); } // se l' immagine e gia piccola if ($width<=$max && $height<=$max) { $new_width=$width; $new_height=$height; } } function foto_casuale($cartella){ //Questa funzione carica tutti i file in un array dopo di chè mi restituisce un elemento random dell'array global $foto_dx; $dir = opendir($cartella); $n_file = 0; while ($filename = readdir($dir)){ if( eregi(".gif",$filename) OR eregi(".jpg",$filename) OR eregi(".jpeg",$filename) OR eregi(".png",$filename) OR eregi(".bmp",$filename) ){ $immagini[$n_file] = $filename; $n_file++; } } $indice=rand(0,(count($immagini)-1)); print $immagini[$indice]; $foto_dx=$immagini[$indice]; } ?>