jpg header trouble

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Hi there!

I'm trying to setup a function which could resize some jpgs 'on the
fly', I want them to be displayed into the browser.

Here is my function:

    function Get_Redim_Jpg($file_jpg){
        Header("Content-type: image/jpeg");
        $src_im = ImageCreateFromJpeg($file_jpg);
        $size = GetImageSize($image);
        $src_w = $size[0];
        $src_h = $size[1];
        $dst_w = floor($src_w / 3);
        $dst_h = floor($src_h / 3);
        $dst_im = ImageCreateTrueColor($dst_w,$dst_h);


and use it like that : '<img src="'.Get_Redim_Jpg("my_jpg").'">
So I must use header function to get it displayed as a jpg.
but I get the 'headers already sent' error..
I don't really see where I have to user header function to avoid

any idea ?

thanks a lot.

Re: jpg header trouble

"PaowZ" wrote:

Quoted text here. Click to load it
Quoted text here. Click to load it

I suggest you start by learning a bit of HTML. The "src" attribute of an IMG
tag is supposed to contain a URL telling the browser where to find the image
resource. You seem to think that PHP allows you to stuff the contents of an
image file directly into the middle of your HTML source. I'm afraid it

phil [dot] ronan @ virgin [dot] net

Re: jpg header trouble

u'r doesn't...I have not been clear enough with
myself...anyway, using Get_Redim-Jpg "as is" won't prevent me from
header errors...


Re: jpg header trouble

"PaowZ" wrote:

Quoted text here. Click to load it

You still don't seem to understand the problem. Let me try to explain again.

(a) This is valid HTML:

<IMG src="resize-image.php?srcfile=x.jpg&w=80&h=40" alt="resized image"
width="80" height="40">

(b) This is invalid crap:

<IMG src="Content-Type: image/jpeg\x0D\x0A\x0D\x0A\xFF\xD8\xFF\xE0\x10JFIF
\x00\x01 ... etc. (raw JPEG data)

What you are currently attempting to produce is invalid crap. The "headers
already sent" error is occurring because PHP has already sent a
"Content-Type: text/html" header at the beginning of the HTML file. If you
want PHP to generate an image for this HTML file, then insert a URL pointing
to a script that generates the image, like in example (a).

phil [dot] ronan @ virgin [dot] net

|OT| IMG and data URL scheme (Was Re: jpg header trouble)

Kimmo Laine wrote:
Quoted text here. Click to load it

Unless next_page.php generates PHP, the script with this include will
only get HTML.

Quoted text here. Click to load it


    if (isset($_GET['foo'])) {
      echo '<?php echo $_GET[\'foo\']; ?>';
    } else {
      echo '<?php echo \'Not available\'; ?>';

File not found: (R)esume, (R)etry, (R)erun, (R)eturn, (R)eboot

Re: jpg header trouble

Quoted text here. Click to load it

yes..this it what i did at first time, but now I realize why that
did'nt work....
I feel a bit ashamed, it was due to a path error in my

 I thank you, Phil.


Site Timeline