note 55570 added to function.imagecopyresized

From: Date: Sun, 07 Aug 2005 21:51:48 +0000
Subject: note 55570 added to function.imagecopyresized
Groups: php.notes 
Request: Send a blank email to php-notes+get-93211@lists.php.net to get a copy of this message
This code will resize your images if your image needs to fit (without stretching) into a max height / width destination image that is not a 1:1 ratio (mine was 4:3). <? // Ratios $image_ratio = $width / $height; // Actual image's ratio $destination_ratio = $max_width / $max_height; // Ratio of dest. placeholder // Taller if($image_ratio < $destination_ratio) { //Too tall: if($height > $max_height) { $height = $max_height; $width = ceil($height / $image_ratio); } } // Wider / balanced & too wide: else if ($width > $max_width) { $width = $max_width; $height = ceil($width / $image_ratio); } ?> ---- Manual Page -- http://www.php.net/manual/en/function.imagecopyresized.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+55570 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+55570&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+55570&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+55570&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+55570&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+55570&report=yes&reason=non-english Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+55570&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+55570&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#93211) next »