note 82798 deleted from function.getimagesize by cmb

From: Date: Sun, 18 Dec 2016 09:51:12 +0000
Subject: note 82798 deleted from function.getimagesize by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-208646@lists.php.net to get a copy of this message
Note Submitter: mike ---- Great script shmohel, a bit more minified... <?php function scale_image($p,$mw='',$mh='') { // path max_width max_height if(list($w,$h) = @getimagesize($p)) { foreach(array('w','h') as $v) { $m = "m{$v}"; if(${$v} > ${$m} && ${$m}) { $o = ($v == 'w') ? 'h' : 'w'; $r = ${$m} / ${$v}; ${$v} = ${$m}; ${$o} = ceil(${$o} * $r); } } return("<img src='{$p}' alt='image' width='{$w}' height='{$h}' />"); } } ?>

« previous php.notes (#208646) next »