<?php
function fnCreatBigThumbnail($strSourcePath,$strFilename,$strDestinationPath,$intGetWidth,$intGetHeight)
{
$strSourcePath = $strSourcePath.$strFilename;
$info = pathinfo($strSourcePath);
if (strtolower($info['extension']) == 'jpg') {$img = imagecreatefromjpeg( "{$strSourcePath}");}
elseif(strtolower($info['extension']) == 'gif'){$img = imagecreatefromgif( "{$strSourcePath}");}
elseif(strtolower($info['extension']) == 'png'){$img = imagecreatefrompng( "{$strSourcePath}");}
$intNewWidth = $intOrigionalWidth = imagesx( $img );
$intNewHeight = $intOrigionalHeight = imagesy( $img );
if($intOrigionalWidth > $intGetWidth)
{
$intNewWidth = $intGetWidth;
$intNewHeight = (($intOrigionalHeight * $intGetWidth)/$intOrigionalWidth);
}
if($intNewHeight > $intGetHeight)
{
$intNewHeight = $intGetHeight;
$intNewWidth = (($intOrigionalWidth * $intGetHeight)/$intOrigionalHeight);
}
$tmp_img = imagecreatetruecolor($intGetWidth,$intGetHeight);
$strWhiteBackground = imagecolorallocate($tmp_img, 255, 255, 255);
imagefill($tmp_img, 0, 0, $strWhiteBackground);
$floatWhiteWidth = (($intGetWidth - $intNewWidth)/2);
$floatWhiteHeight = (($intGetHeight - $intNewHeight)/2);
imagecopyresized( $tmp_img, $img, $floatWhiteWidth, $floatWhiteHeight, 0, 0, $intNewWidth, $intNewHeight, $intOrigionalWidth, $intOrigionalHeight );
if(strtolower($info['extension']) == 'jpg'){imagejpeg($tmp_img,"{$strDestinationPath}{$strFilename}");}
elseif(strtolower($info['extension']) == 'gif'){imagegif( $tmp_img, "{$strDestinationPath}{$strFilename}");}
elseif(strtolower($info['extension']) == 'png'){imagepng( $tmp_img, "{$strDestinationPath}{$strFilename}");}
}
if(isset($_REQUEST["submit"]))
{
$type = strtolower($_FILES['file']['type']);
if(($type=="image/gif")||($type=="image/jpeg") ||($type=="image/png") ||($type=="image/jpeg"))
{
move_uploaded_file($_FILES['file']['tmp_name'],'upload/'.$_FILES['file']['name']);
$strSourcePath = "upload/";
$strFilename = $_FILES['file']['name'];
$strDestinationPath = "resize/";
fnCreatBigThumbnail($strSourcePath,$strFilename,$strDestinationPath,935,440);
}
else
{
echo "Invalid value";
}
}
?>
<form name="frm" action="index.php" method="post" enctype="multipart/form-data">
<input type="file" name="file" />
<input type="submit" name="submit" value="Save" />
</form>
Hay mayank nice codes, really usable. But let me know what to do for showing current city or place in google map api.
ReplyDeletehey just go to https://maps.google.com/
ReplyDeleteclick to link button beside print button you will got iframe code just copy it and implement in your site...
enjoy..