Re: include and imagejpg() weird behavior - maybe header?

From: Date: Tue, 29 Jul 2003 18:44:16 +0000
Subject: Re: include and imagejpg() weird behavior - maybe header?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-157379@lists.php.net to get a copy of this message
"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 > >

« previous php.general (#157379) next »