<?php
 
  //  this code fails on my system.  It returns "<html><body></body></html>" 
  //  see http://sarahandjeremy.net/~jbf/eg/php/jpegDemo?thumbnail=1 

  $sourceImage= "waterfall.jpg";

	if ( $_GET['thumbnail']=='1' ) {
    $width=64;
    $height= 64;
    $source= $sourceImage;

		if(!($sourceImage = @imagecreatefromjpg($source))) {
      print "read of image failed";
      exit();
		} 

		$destinationImage = imagecreatetruecolor($width, $height);

		imagecopyresampled($destinationImage, $sourceImage,
			0, 0, 0, 0, $width, $height,
		imagesx($sourceImage), imagesy($sourceImage));

    header("Content-type: image/jpg" );

    imagejpg($destinationImage,'',90);
    exit();
		
	} else {

?>

  <html> 
  <body>


<p>Original</p>
<img src="waterfall.jpg" borer="0">
<p>Thumbnail</p>
<img src="jpegDemo.thumb.php?thumbnail=1" border="0"> 

  </body>


</html>

<?
   }
?>
