note 48624 deleted from function.imagecopyresampled by cmb

From: Date: Wed, 12 Oct 2016 15:51:31 +0000
Subject: note 48624 deleted from function.imagecopyresampled by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-206862@lists.php.net to get a copy of this message
Note Submitter: afrowuk at tiscali dot co dot uk ---- This simple function resizes a JPG image file giving just a maximum width, and resizes keeping the aspect ratio. This is useful if you have to resize a JPG image that must fit the width of i.e. a div element, but doesn't have to have a maximum height. <? function resizeJPG($jpgFile, $width) { // Get new dimensions list($width_orig, $height_orig) = getimagesize($jpgFile); $height = (int) (($width / $width_orig) * $height_orig); // Resample $image_p = imagecreatetruecolor($width, $height); $image = imagecreatefromjpeg($jpgFile); imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig); // Output imagejpeg($image_p, $jpgFile, 100); } ?> -Stu

« previous php.notes (#206862) next »