"Oli" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > 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 > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php