Using GD Library Functions

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Uncle_Alias

    #1

    Using GD Library Functions

    I would like use some of the GD image functions, so I ran a couple of
    short scripts to see if it worked, such as:

    <?php

    /* Create a red square */
    $image = imagecreate(200 , 200);
    $colorRed = imagecoloralloc ate($image, 255, 0, 0);
    imagefill($imag e, 0, 0, $colorRed);

    //send image
    header("Content-type: image/jpeg");
    imagejpeg($imag e);

    ?>

    but all they generates are garbage characters and no image, starting
    with:
    ÿØÿàJFIFÿþ >CREATOR: gd-jpeg v1.0 (using IJG JPEG v62), default
    quality ÿÛC ... (etc.)

    I then ran a script to see what version was installed
    (var_dump(gd_in fo());)and it generated: ["GD Version"]=> string(24)
    "bundled (2.0 compatible)"


    So why doesn't it generate a jpeg? Am I doing something incorrectly or
    is it the library itself? (This is using a hosting account at
    godaddy.com. It is not PHP or a GD library that I installed).

    Thanks,
    Eric
  • CountScubula

    #2
    Re: Using GD Library Functions

    Can you post a link to a test? I can use my server check on my site to take
    a look at whats going on.

    --
    Mike Bradley
    http://gzen.myhq.info -- free online php tools
    "Uncle_Alia s" <zephinilium@ya hoo.com> wrote in message
    news:e1eff209.0 401021505.12133 746@posting.goo gle.com...[color=blue]
    > I would like use some of the GD image functions, so I ran a couple of
    > short scripts to see if it worked, such as:
    >
    > <?php
    >
    > /* Create a red square */
    > $image = imagecreate(200 , 200);
    > $colorRed = imagecoloralloc ate($image, 255, 0, 0);
    > imagefill($imag e, 0, 0, $colorRed);
    >
    > //send image
    > header("Content-type: image/jpeg");
    > imagejpeg($imag e);
    >
    > ?>
    >
    > but all they generates are garbage characters and no image, starting
    > with:
    > ÿØÿàJFIFÿþ >CREATOR: gd-jpeg v1.0 (using IJG JPEG v62), default
    > quality ÿÛC ... (etc.)
    >
    > I then ran a script to see what version was installed
    > (var_dump(gd_in fo());)and it generated: ["GD Version"]=> string(24)
    > "bundled (2.0 compatible)"
    >
    >
    > So why doesn't it generate a jpeg? Am I doing something incorrectly or
    > is it the library itself? (This is using a hosting account at
    > godaddy.com. It is not PHP or a GD library that I installed).
    >
    > Thanks,
    > Eric[/color]


    Comment

    • SwissCheese

      #3
      Re: Using GD Library Functions

      "Uncle_Alia s" <zephinilium@ya hoo.com> wrote in message
      news:e1eff209.0 401021505.12133 746@posting.goo gle.com...[color=blue]
      > I would like use some of the GD image functions, so I ran a couple of
      > short scripts to see if it worked, such as:
      >
      > <?php
      >
      > /* Create a red square */
      > $image = imagecreate(200 , 200);
      > $colorRed = imagecoloralloc ate($image, 255, 0, 0);
      > imagefill($imag e, 0, 0, $colorRed);
      >
      > //send image
      > header("Content-type: image/jpeg");
      > imagejpeg($imag e);
      >
      > ?>
      >
      > but all they generates are garbage characters and no image, starting
      > with:
      > ÿØÿàJFIFÿþ >CREATOR: gd-jpeg v1.0 (using IJG JPEG v62), default
      > quality ÿÛC ... (etc.)
      >
      > I then ran a script to see what version was installed
      > (var_dump(gd_in fo());)and it generated: ["GD Version"]=> string(24)
      > "bundled (2.0 compatible)"
      >
      >
      > So why doesn't it generate a jpeg? Am I doing something incorrectly or
      > is it the library itself? (This is using a hosting account at
      > godaddy.com. It is not PHP or a GD library that I installed).
      >
      > Thanks,
      > Eric
      >[/color]

      Copied your script to my server and it worked just fine... you really
      don't even need the 'header...' line either...

      <?PHP
      $image = imagecreate(200 , 200);
      $colorRed = imagecoloralloc ate($image, 255, 0, 0);
      imagefill($imag e, 0, 0, $colorRed);

      //send image
      //header("Content-type: image/jpeg");
      imagejpeg($imag e);
      ?>

      here is a link: http://www.suddenimpactfans.com/getphoto3.php

      It could be a problem on your host side - although the only time I get text
      output from the GD stuff is if there is an error in one of the function
      calls...



      Comment

      • Randell D.

        #4
        Re: Using GD Library Functions


        "SwissChees e" <SwissCheese@cf l.rr.com> wrote in message
        news:F8pJb.1061 71$Dt6.3022284@ twister.tampaba y.rr.com...
        "Uncle_Alia s" <zephinilium@ya hoo.com> wrote in message
        news:e1eff209.0 401021505.12133 746@posting.goo gle.com...[color=blue]
        > I would like use some of the GD image functions, so I ran a couple of
        > short scripts to see if it worked, such as:
        >
        > <?php
        >
        > /* Create a red square */
        > $image = imagecreate(200 , 200);
        > $colorRed = imagecoloralloc ate($image, 255, 0, 0);
        > imagefill($imag e, 0, 0, $colorRed);
        >
        > //send image
        > header("Content-type: image/jpeg");
        > imagejpeg($imag e);
        >
        > ?>
        >
        > but all they generates are garbage characters and no image, starting
        > with:
        > ÿØÿàJFIFÿþ >CREATOR: gd-jpeg v1.0 (using IJG JPEG v62), default
        > quality ÿÛC ... (etc.)
        >
        > I then ran a script to see what version was installed
        > (var_dump(gd_in fo());)and it generated: ["GD Version"]=> string(24)
        > "bundled (2.0 compatible)"
        >
        >
        > So why doesn't it generate a jpeg? Am I doing something incorrectly or
        > is it the library itself? (This is using a hosting account at
        > godaddy.com. It is not PHP or a GD library that I installed).
        >
        > Thanks,
        > Eric
        >[/color]

        Copied your script to my server and it worked just fine... you really
        don't even need the 'header...' line either...

        <?PHP
        $image = imagecreate(200 , 200);
        $colorRed = imagecoloralloc ate($image, 255, 0, 0);
        imagefill($imag e, 0, 0, $colorRed);

        //send image
        //header("Content-type: image/jpeg");
        imagejpeg($imag e);
        ?>

        here is a link: http://www.suddenimpactfans.com/getphoto3.php

        It could be a problem on your host side - although the only time I get text
        output from the GD stuff is if there is an error in one of the function
        calls...



        --
        =============== =============== ======

        Eric,

        I'm just wondering if its a header problem.... Make sure you have no spaces
        before your <?PHP tag...

        If you want to see what type of GD support you have, try
        <?
        $gdinfo=gd_info ();
        foreach($gd_inf o as $key=>$element)
        {
        print("<br>$key = $element");
        }
        ?>

        laters
        Randell D.


        Comment

        • Tim Van Wassenhove

          #5
          Re: Using GD Library Functions

          On 2004-01-03, Randell D. <reply.to.news. group.only@and. share.com> wrote:[color=blue]
          >
          > "SwissChees e" <SwissCheese@cf l.rr.com> wrote in message
          > news:F8pJb.1061 71$Dt6.3022284@ twister.tampaba y.rr.com...
          > "Uncle_Alia s" <zephinilium@ya hoo.com> wrote in message
          > news:e1eff209.0 401021505.12133 746@posting.goo gle.com...[color=green]
          >> I would like use some of the GD image functions, so I ran a couple of
          >> short scripts to see if it worked, such as:
          >>
          >> <?php
          >>
          >> /* Create a red square */
          >> $image = imagecreate(200 , 200);
          >> $colorRed = imagecoloralloc ate($image, 255, 0, 0);
          >> imagefill($imag e, 0, 0, $colorRed);
          >>
          >> //send image
          >> header("Content-type: image/jpeg");
          >> imagejpeg($imag e);
          >>
          >> ?>
          >>
          >> but all they generates are garbage characters and no image, starting
          >> with:
          >> ÿØÿàJFIFÿþ >CREATOR: gd-jpeg v1.0 (using IJG JPEG v62), default
          >> quality ÿÛC ... (etc.)
          >>
          >> I then ran a script to see what version was installed
          >> (var_dump(gd_in fo());)and it generated: ["GD Version"]=> string(24)
          >> "bundled (2.0 compatible)"
          >>
          >>
          >> So why doesn't it generate a jpeg? Am I doing something incorrectly or
          >> is it the library itself? (This is using a hosting account at
          >> godaddy.com. It is not PHP or a GD library that I installed).
          >>
          >> Thanks,
          >> Eric
          >>[/color]
          >
          > Copied your script to my server and it worked just fine... you really
          > don't even need the 'header...' line either...
          >
          ><?PHP
          > $image = imagecreate(200 , 200);
          > $colorRed = imagecoloralloc ate($image, 255, 0, 0);
          > imagefill($imag e, 0, 0, $colorRed);
          >
          > //send image
          > //header("Content-type: image/jpeg");
          > imagejpeg($imag e);
          > ?>
          >
          > here is a link: http://www.suddenimpactfans.com/getphoto3.php
          >
          > It could be a problem on your host side - although the only time I get text
          > output from the GD stuff is if there is an error in one of the function
          > calls...[/color]

          When using Mozilla/1.6b/Win32 i get some scrambled text.
          When using InternetExplore r/6.1/Win32 i get a red square.


          --
          verum ipsum factum

          Comment

          • Uncle_Alias

            #6
            Re: Using GD Library Functions

            "Randell D." <reply.to.news. group.only@and. share.com> wrote in message news:<RPpJb.917 448$pl3.238882@ pd7tw3no>...
            ....
            [color=blue]
            >
            > Eric,
            >
            > I'm just wondering if its a header problem.... Make sure you have no spaces
            > before your <?PHP tag...
            >
            > If you want to see what type of GD support you have, try
            > <?
            > $gdinfo=gd_info ();
            > foreach($gd_inf o as $key=>$element)
            > {
            > print("<br>$key = $element");
            > }
            > ?>
            >
            > laters
            > Randell D.[/color]


            Aha! That was it: I moved the PHP code to before the <html> tag - I
            had it in the body. Now it works.
            So tell this newbie: why does this PHP code need to not be in the
            <body> section? Other PHP code I've run has worked fine in the body.

            Thanks,
            Eric

            BTW I couldn't get your GD support check code to work. <scratch head>

            Comment

            • CountScubula

              #7
              Re: Using GD Library Functions

              http://gzen.myhq.info -- free online php tools
              "Uncle_Alia s" <zephinilium@ya hoo.com> wrote in message
              news:e1eff209.0 401030024.514f8 15@posting.goog le.com...[color=blue]
              > "Randell D." <reply.to.news. group.only@and. share.com> wrote in message[/color]
              news:<RPpJb.917 448$pl3.238882@ pd7tw3no>...[color=blue]
              > ...
              >[color=green]
              > >
              > > Eric,
              > >
              > > I'm just wondering if its a header problem.... Make sure you have no[/color][/color]
              spaces[color=blue][color=green]
              > > before your <?PHP tag...
              > >
              > > If you want to see what type of GD support you have, try
              > > <?
              > > $gdinfo=gd_info ();
              > > foreach($gd_inf o as $key=>$element)
              > > {
              > > print("<br>$key = $element");
              > > }
              > > ?>
              > >
              > > laters
              > > Randell D.[/color]
              >
              >
              > Aha! That was it: I moved the PHP code to before the <html> tag - I
              > had it in the body. Now it works.
              > So tell this newbie: why does this PHP code need to not be in the
              > <body> section? Other PHP code I've run has worked fine in the body.
              >
              > Thanks,
              > Eric
              >
              > BTW I couldn't get your GD support check code to work. <scratch head>[/color]

              there should bo NO body section, we (i assume everyone else here) thought
              that was your complete script.

              you are to send out a <BODY> tag if you are sending out an .html page,
              becouse html pages continain, a body.

              when you are sending out image data, send out only image data.

              Think of it not as html with php in it, but rather a scripting lanugage
              thats send out plain data outside the <?php ?> tags

              so, with this line of though, php can send out any type of data. in fact
              some people (myself included) dont have any text outside the <?php ?> tags,
              and use it soley as a scripting laguage.

              now, if a script needed to send, lets say the <HTML> tag, 2 ways

              <HTML>
              <?php
              some script....
              ?>
              </HTML>

              or

              <?php
              print "<HTML>\n";
              some script...
              print "</HTML>\n";
              ?>

              so you see, anything outside the <?php ?> tags is send directly to the
              browser.



              --
              Mike Bradley



              Comment

              • tom

                #8
                Re: Using GD Library Functions

                Randell D. wrote:[color=blue]
                > "SwissChees e" <SwissCheese@cf l.rr.com> wrote in message
                > news:F8pJb.1061 71$Dt6.3022284@ twister.tampaba y.rr.com...
                > "Uncle_Alia s" <zephinilium@ya hoo.com> wrote in message
                > news:e1eff209.0 401021505.12133 746@posting.goo gle.com...[color=green]
                >> I would like use some of the GD image functions, so I ran a couple of
                >> short scripts to see if it worked, such as:
                >>
                >> <?php
                >>
                >> /* Create a red square */
                >> $image = imagecreate(200 , 200);
                >> $colorRed = imagecoloralloc ate($image, 255, 0, 0);
                >> imagefill($imag e, 0, 0, $colorRed);
                >>
                >> //send image
                >> header("Content-type: image/jpeg");
                >> imagejpeg($imag e);
                >>
                >> ?>
                >>
                >> but all they generates are garbage characters and no image, starting
                >> with:
                >> ÿØÿàJFIFÿþ >CREATOR: gd-jpeg v1.0 (using IJG JPEG v62), default
                >> quality ÿÛC ... (etc.)
                >>
                >> I then ran a script to see what version was installed
                >> (var_dump(gd_in fo());)and it generated: ["GD Version"]=> string(24)
                >> "bundled (2.0 compatible)"
                >>
                >>
                >> So why doesn't it generate a jpeg? Am I doing something incorrectly or
                >> is it the library itself? (This is using a hosting account at
                >> godaddy.com. It is not PHP or a GD library that I installed).
                >> Thanks,
                >> Eric
                >>[/color]
                >
                > Copied your script to my server and it worked just fine... you really
                > don't even need the 'header...' line either...
                >
                > <?PHP
                > $image = imagecreate(200 , 200);
                > $colorRed = imagecoloralloc ate($image, 255, 0, 0);
                > imagefill($imag e, 0, 0, $colorRed);
                >
                > //send image
                > //header("Content-type: image/jpeg");
                > imagejpeg($imag e);
                > ?>
                >
                > here is a link: http://www.suddenimpactfans.com/getphoto3.php
                >
                > It could be a problem on your host side - although the only time I get
                > text output from the GD stuff is if there is an error in one of the
                > function calls...[/color]

                help - I see loadsa junk on konqueror, and a few lines of junk with netscape
                thanks, tom

                Comment

                • SwissCheese

                  #9
                  Re: Using GD Library Functions


                  "tom" <test@nospam.co m> wrote in message
                  news:bt67p0$hir $2$8300dec7@new s.demon.co.uk.. .[color=blue]
                  > Randell D. wrote:[color=green]
                  > > "SwissChees e" <SwissCheese@cf l.rr.com> wrote in message
                  > > news:F8pJb.1061 71$Dt6.3022284@ twister.tampaba y.rr.com...
                  > > "Uncle_Alia s" <zephinilium@ya hoo.com> wrote in message
                  > > news:e1eff209.0 401021505.12133 746@posting.goo gle.com...[color=darkred]
                  > >> I would like use some of the GD image functions, so I ran a couple of
                  > >> short scripts to see if it worked, such as:
                  > >>
                  > >> <?php
                  > >>
                  > >> /* Create a red square */
                  > >> $image = imagecreate(200 , 200);
                  > >> $colorRed = imagecoloralloc ate($image, 255, 0, 0);
                  > >> imagefill($imag e, 0, 0, $colorRed);
                  > >>
                  > >> //send image
                  > >> header("Content-type: image/jpeg");
                  > >> imagejpeg($imag e);
                  > >>
                  > >> ?>
                  > >>
                  > >> but all they generates are garbage characters and no image, starting
                  > >> with:
                  > >> ÿØÿàJFIFÿþ >CREATOR: gd-jpeg v1.0 (using IJG JPEG v62), default
                  > >> quality ÿÛC ... (etc.)
                  > >>
                  > >> I then ran a script to see what version was installed
                  > >> (var_dump(gd_in fo());)and it generated: ["GD Version"]=> string(24)
                  > >> "bundled (2.0 compatible)"
                  > >>
                  > >>
                  > >> So why doesn't it generate a jpeg? Am I doing something incorrectly or
                  > >> is it the library itself? (This is using a hosting account at
                  > >> godaddy.com. It is not PHP or a GD library that I installed).
                  > >> Thanks,
                  > >> Eric
                  > >>[/color]
                  > >
                  > > Copied your script to my server and it worked just fine... you really
                  > > don't even need the 'header...' line either...
                  > >
                  > > <?PHP
                  > > $image = imagecreate(200 , 200);
                  > > $colorRed = imagecoloralloc ate($image, 255, 0, 0);
                  > > imagefill($imag e, 0, 0, $colorRed);
                  > >
                  > > //send image
                  > > //header("Content-type: image/jpeg");
                  > > imagejpeg($imag e);
                  > > ?>
                  > >
                  > > here is a link: http://www.suddenimpactfans.com/getphoto3.php
                  > >
                  > > It could be a problem on your host side - although the only time I get
                  > > text output from the GD stuff is if there is an error in one of the
                  > > function calls...[/color]
                  >
                  > help - I see loadsa junk on konqueror, and a few lines of junk with[/color]
                  netscape[color=blue]
                  > thanks, tom
                  >[/color]

                  Try it now - I enabled the header line as Opera 7+ gave junk too, but now
                  doesn't with the header line.


                  Comment

                  • Randell D.

                    #10
                    Re: Using GD Library Functions


                    "Randell D." <reply.to.news. group.only@and. share.com> wrote in message
                    news:<RPpJb.917 448$pl3.238882@ pd7tw3no>...[color=blue]
                    > If you want to see what type of GD support you have, try
                    > <?
                    > $gdinfo=gd_info ();
                    > foreach($gd_inf o as $key=>$element)
                    > {
                    > print("<br>$key = $element");
                    > }
                    > ?>
                    >
                    > laters
                    > Randell D.[/color]


                    Aha! That was it: I moved the PHP code to before the <html> tag - I
                    had it in the body. Now it works.
                    So tell this newbie: why does this PHP code need to not be in the
                    <body> section? Other PHP code I've run has worked fine in the body.

                    Thanks,
                    Eric

                    BTW I couldn't get your GD support check code to work. <scratch head>


                    --
                    =============== =============== ======
                    Hi again,
                    I don't know why you couldn't get the above code to work... take a look at
                    Retrieve information about the currently installed GD library


                    If will tell you what functionality the gdlib can give you (this can vary
                    pending what libraries you have installed). The gd_info() function should
                    work on any PHP 4 forward...

                    If that doesn't work, try phpinfo(); and examine any mention of GD in its
                    output...

                    Lastly... when outputing an image, it is handled differently by the web
                    client than when sending text... It has to do with headers... this might be
                    the reason as to why you are getting mixed results from browser to
                    browser... Some browsers might attempt to be intelligent and guess what data
                    is being sent to them, while othes will just display the binary data that
                    makes up the image (aka junk to you and I). I would suggest that you write
                    your test image to a file first, then have your HTML request the image with
                    the html <img> tag.... Once you've solved that, then I'd go one step further
                    to work on dynamic images if that's your thing...

                    Replies please... via the newsgroup, so everyone can learn... and happy new
                    year,
                    Thanks,
                    Randell D.


                    Comment

                    • Uncle_Alias

                      #11
                      Re: Using GD Library Functions

                      "CountScubu la" <me@scantek.hot mail.com> wrote in message news:<KDvJb.490 1$Ci5.2352@news svr27.news.prod igy.com>...[color=blue]
                      >
                      > there should bo NO body section, we (i assume everyone else here) thought
                      > that was your complete script.
                      >
                      > you are to send out a <BODY> tag if you are sending out an .html page,
                      > becouse html pages continain, a body.
                      >
                      > when you are sending out image data, send out only image data.
                      >
                      > Think of it not as html with php in it, but rather a scripting lanugage
                      > thats send out plain data outside the <?php ?> tags
                      >
                      > so, with this line of though, php can send out any type of data. in fact
                      > some people (myself included) dont have any text outside the <?php ?> tags,
                      > and use it soley as a scripting laguage.
                      >
                      > now, if a script needed to send, lets say the <HTML> tag, 2 ways
                      >
                      > <HTML>
                      > <?php
                      > some script....
                      > ?>
                      > </HTML>
                      >
                      > or
                      >
                      > <?php
                      > print "<HTML>\n";
                      > some script...
                      > print "</HTML>\n";
                      > ?>
                      >
                      > so you see, anything outside the <?php ?> tags is send directly to the
                      > browser.[/color]

                      Interesting. OK, and I find out from the php.net site that for the
                      imagejpeg() function that "The filename argument is optional, and if
                      left off, the raw image stream will be output directly."
                      (http://www.php.net/manual/en/function.imagejpeg.php)

                      So that's why one gets either text garbage or an image and nothing
                      else - it's just an image that's output DIRECTLY to the browser.

                      So... if I wanted to create the image and have my cake and eat it too,
                      I could (supposedly) save it and then display it with an HTML image
                      tag, like:

                      <html>
                      <head>
                      <title>Listin g 12-2a</title>
                      </head>

                      <body>
                      <?php
                      /* Create a red square */
                      $image = imagecreate(200 , 200);
                      $colorRed = imagecoloralloc ate($image, 255, 0, 0);
                      imagefill($imag e, 0, 0, $colorRed);

                      //save image then use later
                      imagejpeg($imag e, "pic.jpg");
                      imagedestroy($i mage);
                      ?>

                      <img src="pic.jpg" border=0>
                      <br>Here is some text.
                      </body>
                      </html>


                      Well, I tried this but it can't find (doesn't display) the image.
                      Where'd it go? I looked in my hosting account directories but couldn't
                      find it anywhere. I assumed it would appear in the directory where the
                      PHP script was run.

                      Comment

                      • Tim Van Wassenhove

                        #12
                        Re: Using GD Library Functions

                        On 2004-01-04, Uncle_Alias <zephinilium@ya hoo.com> wrote:
                        [color=blue]
                        ><?php
                        > /* Create a red square */
                        > $image = imagecreate(200 , 200);
                        > $colorRed = imagecoloralloc ate($image, 255, 0, 0);
                        > imagefill($imag e, 0, 0, $colorRed);
                        >
                        > //save image then use later
                        > imagejpeg($imag e, "pic.jpg");
                        > imagedestroy($i mage);
                        > ?>
                        >
                        ><img src="pic.jpg" border=0>
                        ><br>Here is some text.
                        ></body>
                        ></html>
                        >
                        >
                        > Well, I tried this but it can't find (doesn't display) the image.
                        > Where'd it go? I looked in my hosting account directories but couldn't
                        > find it anywhere. I assumed it would appear in the directory where the
                        > PHP script was run.[/color]

                        This way, you need to make sure that the user which is running
                        apache/php (usually nobody or www-data) has the rights to write such a
                        file at that place.


                        --
                        verum ipsum factum

                        Comment

                        • Agelmar

                          #13
                          Re: Using GD Library Functions

                          Tim Van Wassenhove wrote:[color=blue]
                          > On 2004-01-04, Uncle_Alias <zephinilium@ya hoo.com> wrote:
                          >[color=green]
                          >> <?php
                          >> /* Create a red square */
                          >> $image = imagecreate(200 , 200);
                          >> $colorRed = imagecoloralloc ate($image, 255, 0, 0);
                          >> imagefill($imag e, 0, 0, $colorRed);
                          >>
                          >> //save image then use later
                          >> imagejpeg($imag e, "pic.jpg");
                          >> imagedestroy($i mage);[color=darkred]
                          >>>[/color]
                          >>
                          >> <img src="pic.jpg" border=0>
                          >> <br>Here is some text.
                          >> </body>
                          >> </html>
                          >>
                          >>
                          >> Well, I tried this but it can't find (doesn't display) the image.
                          >> Where'd it go? I looked in my hosting account directories but
                          >> couldn't find it anywhere. I assumed it would appear in the
                          >> directory where the PHP script was run.[/color]
                          >
                          > This way, you need to make sure that the user which is running
                          > apache/php (usually nobody or www-data) has the rights to write such a
                          > file at that place.[/color]

                          What tim said.

                          Also, note that if you have a page that's something like:
                          <?php
                          // this file is somepage.php
                          header(stuff for jpeg); // too lazy to remember syntax
                          ....
                          imagejpeg($img) ;
                          ?>

                          you can do
                          <img src="somepage.p hp">


                          Comment

                          • tom

                            #14
                            Re: Using GD Library Functions

                            SwissCheese wrote:
                            [color=blue]
                            >
                            > "tom" <test@nospam.co m> wrote in message
                            > news:bt67p0$hir $2$8300dec7@new s.demon.co.uk.. .[color=green]
                            >> Randell D. wrote:[color=darkred]
                            >> > "SwissChees e" <SwissCheese@cf l.rr.com> wrote in message
                            >> > news:F8pJb.1061 71$Dt6.3022284@ twister.tampaba y.rr.com...
                            >> > "Uncle_Alia s" <zephinilium@ya hoo.com> wrote in message
                            >> > news:e1eff209.0 401021505.12133 746@posting.goo gle.com...
                            >> >> I would like use some of the GD image functions, so I ran a couple of
                            >> >> short scripts to see if it worked, such as:
                            >> >>
                            >> >> <?php
                            >> >>
                            >> >> /* Create a red square */
                            >> >> $image = imagecreate(200 , 200);
                            >> >> $colorRed = imagecoloralloc ate($image, 255, 0, 0);
                            >> >> imagefill($imag e, 0, 0, $colorRed);
                            >> >>
                            >> >> //send image
                            >> >> header("Content-type: image/jpeg");
                            >> >> imagejpeg($imag e);
                            >> >>
                            >> >> ?>
                            >> >>
                            >> >> but all they generates are garbage characters and no image, starting
                            >> >> with:
                            >> >> ÿØÿàJFIFÿþ >CREATOR: gd-jpeg v1.0 (using IJG JPEG v62), default
                            >> >> quality ÿÛC ... (etc.)
                            >> >>
                            >> >> I then ran a script to see what version was installed
                            >> >> (var_dump(gd_in fo());)and it generated: ["GD Version"]=> string(24)
                            >> >> "bundled (2.0 compatible)"
                            >> >>
                            >> >>
                            >> >> So why doesn't it generate a jpeg? Am I doing something incorrectly or
                            >> >> is it the library itself? (This is using a hosting account at
                            >> >> godaddy.com. It is not PHP or a GD library that I installed).
                            >> >> Thanks,
                            >> >> Eric
                            >> >>
                            >> >
                            >> > Copied your script to my server and it worked just fine... you
                            >> > really
                            >> > don't even need the 'header...' line either...
                            >> >
                            >> > <?PHP
                            >> > $image = imagecreate(200 , 200);
                            >> > $colorRed = imagecoloralloc ate($image, 255, 0, 0);
                            >> > imagefill($imag e, 0, 0, $colorRed);
                            >> >
                            >> > //send image
                            >> > //header("Content-type: image/jpeg");
                            >> > imagejpeg($imag e);
                            >> > ?>
                            >> >
                            >> > here is a link: http://www.suddenimpactfans.com/getphoto3.php
                            >> >
                            >> > It could be a problem on your host side - although the only time I get
                            >> > text output from the GD stuff is if there is an error in one of the
                            >> > function calls...[/color]
                            >>
                            >> help - I see loadsa junk on konqueror, and a few lines of junk with[/color]
                            > netscape[color=green]
                            >> thanks, tom
                            >>[/color]
                            >
                            > Try it now - I enabled the header line as Opera 7+ gave junk too, but now
                            > doesn't with the header line.[/color]
                            worked - thanks (I still get this on my server though - and need to keep at
                            it), tom

                            Comment

                            • Uncle_Alias

                              #15
                              Re: Using GD Library Functions

                              "Agelmar" <ifetteNOSPAM@c omcast.net> wrote in message news:<bt87nl$4b nnn$1@ID-30799.news.uni-berlin.de>...[color=blue]
                              > Tim Van Wassenhove wrote:[color=green]
                              > > On 2004-01-04, Uncle_Alias <zephinilium@ya hoo.com> wrote:
                              > >[color=darkred]
                              > >> <?php
                              > >> /* Create a red square */
                              > >> $image = imagecreate(200 , 200);
                              > >> $colorRed = imagecoloralloc ate($image, 255, 0, 0);
                              > >> imagefill($imag e, 0, 0, $colorRed);
                              > >>
                              > >> //save image then use later
                              > >> imagejpeg($imag e, "pic.jpg");
                              > >> imagedestroy($i mage);
                              > >>>
                              > >>
                              > >> <img src="pic.jpg" border=0>
                              > >> <br>Here is some text.
                              > >> </body>
                              > >> </html>
                              > >>
                              > >>
                              > >> Well, I tried this but it can't find (doesn't display) the image.
                              > >> Where'd it go? I looked in my hosting account directories but
                              > >> couldn't find it anywhere. I assumed it would appear in the
                              > >> directory where the PHP script was run.[/color]
                              > >
                              > > This way, you need to make sure that the user which is running
                              > > apache/php (usually nobody or www-data) has the rights to write such a
                              > > file at that place.[/color]
                              >
                              > What tim said.
                              >
                              > Also, note that if you have a page that's something like:
                              > <?php
                              > // this file is somepage.php
                              > header(stuff for jpeg); // too lazy to remember syntax
                              > ...
                              > imagejpeg($img) ;
                              > ?>
                              >
                              > you can do
                              > <img src="somepage.p hp">[/color]


                              Yeah, that works. Cool. Raises all kinds of possibilities.. .

                              Comment

                              Working...