Problem with GD

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

    #1

    Problem with GD

    Hello,

    I'm running into a strange issue with GD. Please review
    the script attached bellow. I'm using it to generate thumbnail
    icon on a fly. I don't know why it gives different results on
    different servers. Php on my development server is 4.0.6
    and GD is 1.6.2 or higher with jpg/gif/png enabled. The
    script works fine and generates very clear icon picture on
    my server. However, on the application server, it works
    but generate blur image. Php on that server is 4.3.0 and
    GD is 2.0 with jpg/gif/png enabled. How come with higher
    version it gives poorer performance? Thanks in advance.

    Alex

    <?
    $picName = $HTTP_GET_VARS['pic'];

    $picSize = getimagesize ('../pictures/'.$picName);
    $thePic = imagecreatefrom jpeg ('../pictures/'.$picName);
    $nHeight = 50;
    $ratio = $nHeight / $picSize[1];
    $nWidth = round ($ratio * $picSize[0]);
    $thm = @imagecreate ($nWidth, $nHeight)
    or die ("Cannot Initialize new GD image stream");

    /*
    $result = imagecopyresamp led ($thm, $thePic, 0, 0, 0, 0,
    $nWidth, $nHeight, $picSize[0], $picSize[1]);
    */
    /*
    on my development server imagecopyresamp led don't work but
    imagecopyresize d works fine.
    */

    $result = imagecopyresize d ($thm, $thePic, 0, 0, 0, 0,
    $nWidth, $nHeight, $picSize[0], $picSize[1]);
    header ("Content-type: image/png");
    $result = imagepng ($thm);
    ?>


  • Joachim Mæland

    #2
    Re: Problem with GD

    On Thu, 11 Mar 2004 14:24:46 -0500, Alex Shi wrote:
    [color=blue]
    > I'm running into a strange issue with GD. Please review the script
    > attached bellow. I'm using it to generate thumbnail icon on a fly. I
    > don't know why it gives different results on different servers. Php on
    > my development server is 4.0.6 and GD is 1.6.2 or higher with
    > jpg/gif/png enabled. The script works fine and generates very clear icon
    > picture on my server. However, on the application server, it works but
    > generate blur image. Php on that server is 4.3.0 and GD is 2.0 with
    > jpg/gif/png enabled. How come with higher version it gives poorer
    > performance? Thanks in advance.[/color]
    [..][color=blue]
    > $thm = @imagecreate ($nWidth, $nHeight)
    > or die ("Cannot Initialize new GD image stream");[/color]

    How about...?

    if GD >= 2.0
    $thm = @imagecreatetru ecolor

    --
    mvh/regards
    Joachim Mæland

    If everything seems under control, you're just not going fast enough.
    -Mario Andretti

    Comment

    • Alex Shi

      #3
      Re: Problem with GD

      > > I'm running into a strange issue with GD. Please review the script[color=blue][color=green]
      > > attached bellow. I'm using it to generate thumbnail icon on a fly. I
      > > don't know why it gives different results on different servers. Php on
      > > my development server is 4.0.6 and GD is 1.6.2 or higher with
      > > jpg/gif/png enabled. The script works fine and generates very clear icon
      > > picture on my server. However, on the application server, it works but
      > > generate blur image. Php on that server is 4.3.0 and GD is 2.0 with
      > > jpg/gif/png enabled. How come with higher version it gives poorer
      > > performance? Thanks in advance.[/color]
      > [..][color=green]
      > > $thm = @imagecreate ($nWidth, $nHeight)
      > > or die ("Cannot Initialize new GD image stream");[/color]
      >
      > How about...?
      >
      > if GD >= 2.0
      > $thm = @imagecreatetru ecolor
      >[/color]

      That really works the correct way, thanks a lot!

      Alex
      [color=blue]
      > --
      > mvh/regards
      > Joachim Mæland
      >
      > If everything seems under control, you're just not going fast enough.
      > -Mario Andretti
      >[/color]

      Comment

      Working...