You need GIFEncoder class to do this
| Code: |
| include('GIFEncoder.class.php');
$msg = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890~!@#$%^&*()-_=+`[]{};:?/.,<>\\|"'; $length = strlen($msg); $max_x = 400; //image x size $max_y = 400; //image y size $font_file = 'cour.ttf';//font, best monospace $font_size = 10;//font site $grid = 10;//gridient of the fonts $measuer = imagettfbbox(10,0,$font_file,'1'); $space = 5;//space between letters $char_height = $measuer[1] - $measuer[7] + $space; $char_width = $measuer[2] - $measuer[0] + $space; $i = 0; $colorimage = imagecreatetruecolor(1,1); //this is the part where the colors are made //you can use other ways to create better looking color scheme while($i<$grid){ $color[] = imagecolorallocate($colorimage, 0, 255/($i+1), 0); ++$i; } //ENOUGH TEXT TO FILL THE PAGE. $width = ceil($max_x/$char_width); $height = ceil($max_y/$char_height); $x = 0; while($x < $width){ $y = 0; while($y < $height){ $text[$x][$y] = $msg[rand(0,$length)]; ++$y; } $drop[$x] = rand(0, $width); ++$x; } $i = 0; while($i<$height+$grid){ $image[] = imagecreatetruecolor($max_x, $max_y); $x = 0; while($x < $width){ $y = 0; while($y < $drop[$x]){ if($drop[$x]-$y<=$grid){ imagettftext($image[count($image)-1], $font_size, 0, $x*$char_width, ($y+1)*$char_height-$space, $color[$drop[$x]-$y], $font_file, $text[$x][$y]); } ++$y; } if($drop[$x]<$height+$grid){ ++$drop[$x]; }else{ $drop[$x] = 0; } ++$x; } ++$i; } ob_start(); $i = 0; $count = count($image); while($i<$count){ imagegif($image[$i]); $imagedata[$i] = ob_get_contents(); imagedestroy($image[$i]); ob_clean(); ++$i; } $gif = new GIFEncoder( $imagedata, 100, 0, 2, 0, 0, 0, "bin" ); Header ( 'Content-type:image/gif' ); echo $gif->GetAnimation (); |
Last edited by Mgccl on Thu Apr 26, 2007 11:07 pm; edited 1 time in total
