I copied and pasted your code into two different files, changed the image
name (of course) and it worked just fine on the first try for me.  You must
have something being output before your header() call.  If you can't find
it, send me your two files and I'll try running them on my server.

  -- Rob



"Oli" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> 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" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> > "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

Reply via email to