Re: imagecopyresample
| From: | gareth at zaphodmcmillan dot com | Date: | Thu, 14 Apr 2005 22:47:27 +0000 |
| Subject: | Re: imagecopyresample | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-213123@lists.php.net to get a copy of this message | ||
On Apr 14, 2005, at 21:37, Marek Kilimajer wrote:
gareth@zaphodmcmillan.com wrote:Thanks a lot That worked a treatI have created (adapted) the follow function: function imageresize($new_width, $new_height, $filename) { // Content type header('Content-type: image/jpeg'); // Get new dimensions list($width, $height) = getimagesize($filename); // Resample $image_p = imagecreatetruecolor($new_width, $new_height); $image = imagecreatefromjpeg($filename); imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height); // Output imagejpeg($image_p, null, 100); } The idea is it takes a image and resizes it at server end so that you dont have to download a massive image. And it works. That is as long as that function is the only think you doing. For example if I have a page with the following in it: <?php require_once('../includes/functions.php'); imageresize('100', '75', 'pages/1.jpg'); ?> I get my image resized. (functions.php is where all my fuctions are stored) However if I place anything after the imageresize it doesnt show that. Eg echo"hello'; does nothing. If anything goes before it the whole page doesnt work. Any ideas why this is happening and how I can work around it?You can display either image or html, not both. You must do: <img src="thumb.php"> thumb.php contains the code to output the thumbnail
------------------------------------------------------------------------ ---------------------check out my blog to find out what im up to: http://www.zaphodmcmillan.com/ And my new email is gareth@zaphodmcmillan.com