Research and Development work on PHP, MYSQ,JQuery,Angular Js,React Native,Laravel,Wordpress,Magento,Joomla
Sunday, June 24, 2012
Display image at the center of content
<?php
function displayImage($intGetWidth,$intGetHeight,$intNewWidth,$intNewHeight)
{
$intWidth = $intNewWidth;
$intHeight = $intNewHeight;
if( $intGetWidth > $intNewWidth)
{
$intWidth = $intNewWidth;
$intHeight = (($intGetHeight * $intNewWidth)/$intGetWidth);
}
if($intHeight > $intNewHeight)
{
$intHeight = $intNewHeight;
$intWidth = (($intWidth * $intNewHeight)/$intHeight);
}
return array($intWidth,$intHeight);
}
$intNewWidth = 100;
$intNewHeight = 100;
$strSource = "image/Google22.jpg";
$arrDimensions = getimagesize($strSource);
$intOrigionalWidth = $arrDimensions[0];
$intOrigionalHeight = $arrDimensions[1];
$intNewDim = displayImage($intOrigionalWidth,$intOrigionalHeight,$intNewWidth,$intNewHeight);
$intWhiteWidth = (($intNewWidth - $intNewDim[0])/2);
$intWhiteHeight = (($intNewHeight - $intNewDim[1])/2);
?>
<div style="height:100px;width:100px;border:1px solid #FF0000;">
<img src="http://localhost/display_image/image/Google22.jpg" width="<?php echo $intNewDim[0];?>" height="<?php echo $intNewDim[1];?>" style="margin-top:<?php echo $intWhiteHeight;?>;margin-left:<?php echo $intWhiteWidth;?>"/>
</div>
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
Please mention your comments.......