<?php

  $sourceImage= "waterfall.png";

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

		if(!($sourceImage = @imagecreatefrompng($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/png");

    imagepng($destinationImage);
    exit();
		
	} else {

?>

  <html> 
  <body>


<p>Original</p>
<img src="waterfall.png" borer="0">
<p>Thumbnail</p>
<img src="pngDemo?thumbnail=1" border="0">

  </body>


</html>

<?
   }
?>
