note 94933 modified in function.getimagesize by danbrown
| From: | danbrown@php.net | Date: | Thu, 03 Dec 2009 14:14:57 +0000 |
| Subject: | note 94933 modified in function.getimagesize by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-163540@lists.php.net to get a copy of this message | ||
A simplest method to resize a image keeping the constraint proportions.
<?php
list($width, $height, $type, $attr)=getimagesize($imagepath);
$ht=$height;
$wd=$width;
if($width>180){
$diff = $width-180;
$percnt_reduced = (($diff/$width)*100);
$ht = $height-(($percnt_reduced*$height)/100);
$wd= $width-$diff;
}
if($height>180){
$diff = $height-180;
$percnt_reduced = (($diff/$height)*100);
$wd = $width-(($percnt_reduced*$width)/100);
$ht= $height-$diff;
}
?>
--was--
A simplest method to resize a image keeping the constraint proportions.
list($width, $height, $type, $attr)=getimagesize($imagepath);
$ht=$height;
$wd=$width;
if($width>180){
$diff = $width-180;
$percnt_reduced = (($diff/$width)*100);
$ht = $height-(($percnt_reduced*$height)/100);
$wd= $width-$diff;
}
if($height>180){
$diff = $height-180;
$percnt_reduced = (($diff/$height)*100);
$wd = $width-(($percnt_reduced*$width)/100);
$ht= $height-$diff;
}
http://php.net/manual/en/function.getimagesize.php