<?php
  function print_thumb($src, $desired_width = 400){
  
    if( !file_exists($src) )
      return false;

    /* read the source image */
    $source_image = imagecreatefromjpeg($src);
    $width = imagesx($source_image);
    $height = imagesy($source_image);

    /* find the "desired height" of this thumbnail, relative to the desired width  */
    $desired_height = floor($height * ($desired_width / $width));

    /* create a new, "virtual" image */
    $virtual_image = imagecreatetruecolor(720, 480);
	$width12 = $width / 4;
$width1 = $width * 1;
$height1 = $height * 1;
$desired_height1 = $desired_height * 2;
$desired_width1 = $desired_width * 2;
    /* copy source image at a resized size */
    imagecopyresampled($virtual_image, $source_image, 0, 0, 0, 0, $desired_width1, $desired_height1, $width1, $height1);


    // Set the content type header - in this case image/jpeg
    header('Content-Type: image/jpeg');

    // Output the image
    imagejpeg($virtual_image);

    return true;

  }

  if( isset( $_GET['file'] ) && !empty( $_GET['file'] ) ){

    if( !print_thumb( $_GET['file'] ) ){

      echo 'Failed to create thumb for "'.$_GET['file'].'"';

    }else{

      // The Thumb would have been returned

    }

  }else{

    echo 'No File specified';

  }
    
?>