note 60086 deleted from ref.image by tularis
| From: | tularis@php.net | Date: | Sun, 29 Jun 2008 21:03:48 +0000 |
| Subject: | note 60086 deleted from ref.image by tularis | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-140931@lists.php.net to get a copy of this message | ||
Note Submitter: razonklnbd at yahoo dot com
----
I was looking for a function to get propotional image size. After a bit of thinking I came up with
this pretty fast solution:
<?php
function getPropotionalSize($src_w, $src_h, $max_w, $max_h){
$return_val['width']=$src_w;
$return_val['height']=$src_h;
if($max_w<$src_w || $max_h<$src_h){
$return_val['width']=$max_w;
$return_val['height']=$max_h;
if($src_w>=$src_h) $return_val['height']=($max_w*$src_h)/$src_w;
else $return_val['width']=($max_h*$src_w)/$src_h;
}
return $return_val;
}
?>
Hope it saved somebody some time!