note 94933 deleted from function.getimagesize by cmb
| From: | cmb@php.net | Date: | Sun, 18 Dec 2016 09:32:39 +0000 |
| Subject: | note 94933 deleted from function.getimagesize by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-208618@lists.php.net to get a copy of this message | ||
Note Submitter: swapnil dot nkene at gmail dot com
----
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;
}
?>