Re: imagecopyresample

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On Apr 14, 2005, at 21:37, Marek Kilimajer wrote:

gareth@xxxxxxxxxxxxxxxxxx wrote:
I 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



Thanks a lot That worked a treat

------------------------------------------------------------------------ ---------------------

check out my blog to find out what im up to:
http://www.zaphodmcmillan.com/
And my new email is gareth@xxxxxxxxxxxxxxxxxx


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux