<?php
/*
This file will resize the image by same factor as original
*/
echo $image_source . "Is the file source<br>";// = "../file_upload/download.jpg";
echo $image_size . "Is the file size <br>";// = 110 . "<br>";
resizePic($image_source, $image_size);
//resizePic('download.jpg', 150);
function resizePic($inputFile, $new_size)
{
	echo "$inputFile.... $new_size<br>";
	$imagedata = getimagesize($inputFile);
	$w = $imagedata[0];
	$h = $imagedata[1];
	echo "$w". W ;
	echo "$h". H;
	//echo "Existing dimention " . $w . "  <> " . $h;
	if($h>$w)
	{
		$new_w = ($new_size/$h) * $w;
		$new_h = $new_size;
	} else
	{
		$new_h = ($new_size/$w)*$h;
		$new_w = $new_size;
	}
	$newimage = imagecreatetruecolor($new_w, $new_h);
	$image = imagecreatefromjpeg($inputFile);
	imagecopyresampled($newimage, $image, 0, 0, 0, 0, $new_w, $new_h, $imagedata[0], $imagedata[1]);
	imagejpeg($newimage, $inputFile, 100);
}
?>