Re: include and imagejpg() weird behavior - maybe header?
| From: | Oli | Date: | Wed, 30 Jul 2003 07:33:13 +0000 |
| Subject: | Re: include and imagejpg() weird behavior - maybe header? | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-157499@lists.php.net to get a copy of this message | ||
Nobe, the image.php script starts with <? as the absolute first characters.
Also if I comment out the header function I don't get the header error but I
get the gobbledygook (the picture data I guess). Combine the code in one
script and all is fine, with or without the header function.
Oli
"Rob Adams" <rob_adams@hotmail.com> wrote in message
news:20030729184417.53333.qmail@pb1.pair.com...
> "Oli" <php@edal.us> wrote in message
> news:20030729173407.44957.qmail@pb1.pair.com...
> > I have a function that resizes images. If I put it in the same php file
> that
> > calles it it workes fine. Gives a nice thumbnail or whatever size I
choose
> > to display. If I however put it in a seperate file and include it and
call
> > it I get garbage and the following error:
> >
> > Warning: Cannot modify header information - headers already sent by
> (output
> > started at /home/edal/public_html/album/image.php
> >
> > Here is the resize function (in file image.php):
> > <?
> > function resize($filepath,$nw = 50,$string = '')
> > {
> > header("Content-type: image/jpeg");
>
> The above line is causing your error. According to the error, it's
> something in your image.php file. Is there a space or carriage return
> before your opening php tag in image.php?
>
> -- Rob
>
>
>
> > $im = imagecreatefromjpeg($filepath);
> > $w = imagesx ($im);
> > $h = imagesy ($im);
> > $nh = round($h*$nw/$w,0);
> > $newim = imagecreatetruecolor($nw,$nh);
> > $black = imagecolorallocate($newim, 0, 0, 0);
> > imagecopyresampled($newim,$im,0,0,0,0,$nw,$nh,$w,$h);
> > imagestring($newim, 2, 5, 5, $string, $black);
> > imagedestroy($im);
> > return $newim;
> > } ?>
> >
> > and the calling script:
> > <?php
> > include 'image.php';
> > $image = resize('Capri.jpg',200,'Capri');
> > imagejpeg($image);
> > imagedestroy($image);
> > ?>
> >
> > Any ideas?
> >
> > Oli
> >
> >
>
>