note 16838 added to function.imagecopyresampled

From: Date: Thu, 15 Nov 2001 13:14:13 +0000
Subject: note 16838 added to function.imagecopyresampled
Groups: php.notes 
Request: Send a blank email to php-notes+get-20872@lists.php.net to get a copy of this message
Here's a image resize script i wrote. Maybe it's usefull for someone <?php set_time_limit(0); // we don't want to timeout. if ((isset($image)) && (is_uploaded_file($image))) { // resize the image if ($HTTP_POST_FILES['image']['type'] != "image/pjpeg") die($HTTP_POST_FILES['image']['type'] . " is not a supported file type"); $inputImg = ImageCreateFromJPEG($image); $srcX = imagesx($inputImg); $srcY = imagesy($inputImg); $dstY = 72; // fixed Y for the image. always the same $maxX = 96; // max X for image, if image is smaller it will be centered $ratio = ($srcY / $dstY); $dstX = ($srcX / $ratio); $outputImg = ImageCreateTrueColor($maxX, $dstY); imagefill($outputImg, 0, 0, ImageColorAllocate($outputImg, 255, 255, 255)); imagecopyresampled($outputImg, $inputImg, (($maxX - $dstX) / 2),0,0,0, $dstX, $dstY, $srcX, $srcY); header("content-type: image/png"); imagepng($outputImg); } else // print the form { printf("<form enctype=\"multipart/form-data\" action=\"\" method=\"post\">"); printf("Resize image: <input name=\"image\" type=\"file\">"); printf("<input type=\"submit\" value=\"Submit Image\">"); printf("</form>"); } ?> -- http://www.php.net/manual/en/function.imagecopyresampled.php http://master.php.net/manage/user-notes.php?action=edit+16838 http://master.php.net/manage/user-notes.php?action=delete+16838 http://master.php.net/manage/user-notes.php?action=reject+16838

« previous php.notes (#20872) next »