PHP - Prevent automated registrations

Im trying to prevent automated registrations. I found a script on the internet that will show an image with distorted text. I already tried it, everything would work but the image wont show. Can someone please point out what am I doing wrong?


<?php 
session_start();

if (isset($_POST['word']))
{
  if (strtolower($_SESSION['crc']) == strtolower($_POST['word']))
  {
    echo("Matched!");
  }
  else
  {
    echo("Didn't match.");
  }
}
else
{
  $self = $_SERVER['PHP_SELF'];
  if ($_GET['im'] == TRUE)
  {
    $mycrc = $_SESSION['crc'];
    header("Content-type: image/png");
    $size = imagettfbbox(30, 3, "../Fonts/georgia.ttf", $mycrc);
    $im = imagecreatetruecolor(abs($size[4]-$size[0]), (abs($size[5])+$size[1]));
    $white = imagecolorallocate($im, 255, 255, 255);
    imagefill($im, 0, 0, $white);
    $black = imagecolorallocate($im, 0, 0, 0);
    for ($x=0;$x<15;$x++)
	{
      for ($y=0;$y<7;$y++)
	  {
        $color = imagecolorclosest($im, rand(100,255), rand(100,255), rand(100,255));
        $points = array(
          rand(-5,5)+rand(5*$x,10*$x), rand(-5,5)+rand(5*$y,10*$y),
          rand(-5,5)+rand(5*$x,10*$x), rand(-5,5)+rand(5*$y,10*$y),
          rand(-5,5)+rand(5*$x,10*$x), rand(-5,5)+rand(5*$y,10*$y),
          rand(-5,5)+rand(5*$x,10*$x), rand(-5,5)+rand(5*$y,10*$y)
        );
        imagefilledpolygon($im, $points, 3, $color);
      }
    }
    imagettftext($im, 27, 4, 5, 33, $black, "../Fonts/georgia.ttf", $mycrc);
    imagepng($im);
    exit();
  }
  $_SESSION["crc"] = chr(rand(0,25)+97) . chr(rand(0,25)+97) . chr(rand(0,25)+97) . rand(0,9) . rand(0,9) . rand(0,9);
?>
	<img src="<?php echo $_SERVER['PHP_SELF']; ?>" alt="Please type this word."><br />
	<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
	Please type the above word:<br />
	<input type="text" name="word" value=""><br />
	<input type="submit" name="submit" value="Submit Query">
	</form>
<?php
	echo '<p>'.$_SESSION["crc"].'</p>';
}
?>