note 48387 deleted from function.imagecopyresampled by tularis

From: Date: Tue, 21 Dec 2004 18:32:43 +0000
Subject: note 48387 deleted from function.imagecopyresampled by tularis
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-82141@lists.php.net to get a copy of this message
Note Submitter: jeremy aat lordco dot com ---- This code will fit an image into an area and maintain aspect ratio. <?php $filename = "image.jpg"; // Set a maximum height and width or use numbers from another source $widthset = 600; $heightset = 400; // Get current dimensions list($width_orig, $height_orig) = getimagesize($filename); // Get dimension change ratios $width_ratio = ($widthset / $width_orig); $height_ratio = ($heightset / $height_orig); // Figure out which one is the lesser if ($width_ratio < height_ratio) { $ratio = $width_ratio; } else { $ratio = $height_ratio; } //Apply the math to the original image sizes. From here you can use height_new and width_new on your image wherever you like. $height_new = $ratio * $height_orig; $width_new = $ratio * $width_orig; ?> ---- Reason: useless example

« previous php.notes (#82141) next »