Reply to Re: [PHP] imagecopyresample

Your name:

Reply:


Posted by Marek Kilimajer on 10/20/21 11:13

gareth@zaphodmcmillan.com 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

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация