Workaround for "imagegif()"?

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

    Workaround for "imagegif()"?

    re: http://us4.php.net/manual/en/function.imagegif.php

    I have one class method that resizes images, including GIF images, and
    works just fine doing so, even up to this line:

    [PHP]
    eval('image' . $extArray[$type] . '($newImage, "$tmpImageDownl oadDir/"
    .. $this->fileName);') ; // SAVE TO TEMPORARY IMAGE DIR FOR
    DOWNLOAD
    [/PHP]

    (yes even with.. EVAL!)

    However, in another class method, THIS line produces the following
    error:

    Fatal error: Call to undefined function: imagegif() in
    /www/html/mu-spin/image_catalog/include/classes.inc.php (2262) :
    eval()'d code on line 1
    The line:

    [PHP]
    eval('image' . $extArray[$type] . '($newImage,
    "$this->thumbLocationP ath/$this->fileName", $thumbDimension Int);');
    [/PHP]

    I've taken out the reference to $thumbDimension Int, to no avail. Same
    exact error every time, but ONLY for GIF images.

    But why is it the nearly-identical line in one class method resizes
    GIF images, but the near very same line in another class method
    (creates thumbnails) bombs for GIF images?

    Both work just fine for all other images (i.e., JPG, TIFF, PNG, SWF,
    BMP, etc.)

    Thanx
    Phil
  • Andy Hassall

    #2
    Re: Workaround for "imagegif( )"?

    On 7 May 2004 15:21:39 -0700, soazine@erols.c om (Phil Powell) wrote:
    [color=blue]
    >re: http://us4.php.net/manual/en/function.imagegif.php
    >
    >I have one class method that resizes images, including GIF images, and
    >works just fine doing so, even up to this line:
    >
    >[PHP]
    >eval('image' . $extArray[$type] . '($newImage, "$tmpImageDownl oadDir/"
    >. $this->fileName);') ; // SAVE TO TEMPORARY IMAGE DIR FOR
    >DOWNLOAD
    >[/PHP]
    >
    >(yes even with.. EVAL!)
    >
    >However, in another class method, THIS line produces the following
    >error:
    >
    >
    >Fatal error: Call to undefined function: imagegif() in
    >/www/html/mu-spin/image_catalog/include/classes.inc.php (2262) :
    >eval()'d code on line 1
    >
    >
    >The line:
    >
    >[PHP]
    >eval('image' . $extArray[$type] . '($newImage,
    >"$this->thumbLocationP ath/$this->fileName", $thumbDimension Int);');
    >[/PHP]
    >
    >I've taken out the reference to $thumbDimension Int, to no avail. Same
    >exact error every time, but ONLY for GIF images.
    >
    >But why is it the nearly-identical line in one class method resizes
    >GIF images, but the near very same line in another class method
    >(creates thumbnails) bombs for GIF images?
    >
    >Both work just fine for all other images (i.e., JPG, TIFF, PNG, SWF,
    >BMP, etc.)[/color]

    Hm - you're _sure_ that the first one is actually calling imagegif? Unless
    you're running a very old version of GD it shouldn't work, should give the
    error you've posted. GIF support was removed ages ago because of the patent
    restrictions surrounding the format (although read-only GIF support was patched
    back in the version of GD bundled with recent PHPs).

    Incidentally, wouldn't call_user_func be safer than eval? e.g.

    <?php
    $x = imagecreatefrom gif('circle_1.g if');
    $type = 'png';
    header("Content-type: image/$type");
    call_user_func( "image$type ", $x);
    ?>

    --
    Andy Hassall <andy@andyh.co. uk> / Space: disk usage analysis tool
    http://www.andyh.co.uk / http://www.andyhsoftware.co.uk/space

    Comment

    • Chung Leong

      #3
      Re: Workaround for &quot;imagegif( )&quot;?

      "Andy Hassall" <andy@andyh.co. uk> wrote in message
      news:eo5o90t5ig 388t9h2t7cdhbu3 5lq7jniif@4ax.c om...[color=blue]
      > On 7 May 2004 15:21:39 -0700, soazine@erols.c om (Phil Powell) wrote:
      > Hm - you're _sure_ that the first one is actually calling imagegif?[/color]
      Unless[color=blue]
      > you're running a very old version of GD it shouldn't work, should give the
      > error you've posted. GIF support was removed ages ago because of the[/color]
      patent[color=blue]
      > restrictions surrounding the format (although read-only GIF support was[/color]
      patched[color=blue]
      > back in the version of GD bundled with recent PHPs).[/color]

      The LZW patent expired last year. I wonder why they haven't yet restored GIF
      support.
      [color=blue]
      > Incidentally, wouldn't call_user_func be safer than eval? e.g.
      >
      > <?php
      > $x = imagecreatefrom gif('circle_1.g if');
      > $type = 'png';
      > header("Content-type: image/$type");
      > call_user_func( "image$type ", $x);
      > ?>[/color]

      Personally I like to do this:

      $imagecreatefro m_func = array(
      1 => "imagecreatefro mgif",
      3 => "imagecreatefro mpng",
      2 => "imagecreatefro mjpeg");

      $image_func = array(
      1 => "imagepng",
      3 => "imagepng",
      2 => "imagejpeg" );

      list($width, $height, $type, $attr) = getimagesize($f ilename);

      if($f = @$imagecreatefr om_func[$type]) {
      $g = $image_func[$type];
      $img = $f($filename);
      // do stuff with image
      $g($img);
      }

      An elegant and flexible setup, methinks.


      Comment

      • Andy Hassall

        #4
        Re: Workaround for &quot;imagegif( )&quot;?

        On Mon, 10 May 2004 19:44:41 -0400, "Chung Leong" <chernyshevsky@ hotmail.com>
        wrote:
        [color=blue]
        >The LZW patent expired last year. I wonder why they haven't yet restored GIF
        >support.[/color]

        It hasn't expired all round the world yet. That happens on July 7th 2004.

        --
        Andy Hassall <andy@andyh.co. uk> / Space: disk usage analysis tool
        http://www.andyh.co.uk / http://www.andyhsoftware.co.uk/space

        Comment

        • Phil Powell

          #5
          Re: Workaround for &quot;imagegif( )&quot;?

          "Chung Leong" <chernyshevsky@ hotmail.com> wrote in message news:<T4udnXZMr 7Tlij3dRVn-gg@comcast.com> ...[color=blue]
          > "Andy Hassall" <andy@andyh.co. uk> wrote in message
          > news:eo5o90t5ig 388t9h2t7cdhbu3 5lq7jniif@4ax.c om...[color=green]
          > > On 7 May 2004 15:21:39 -0700, soazine@erols.c om (Phil Powell) wrote:
          > > Hm - you're _sure_ that the first one is actually calling imagegif?[/color]
          > Unless[color=green]
          > > you're running a very old version of GD it shouldn't work, should give the
          > > error you've posted. GIF support was removed ages ago because of the[/color]
          > patent[color=green]
          > > restrictions surrounding the format (although read-only GIF support was[/color]
          > patched[color=green]
          > > back in the version of GD bundled with recent PHPs).[/color]
          >
          > The LZW patent expired last year. I wonder why they haven't yet restored GIF
          > support.
          >[color=green]
          > > Incidentally, wouldn't call_user_func be safer than eval? e.g.
          > >
          > > <?php
          > > $x = imagecreatefrom gif('circle_1.g if');
          > > $type = 'png';
          > > header("Content-type: image/$type");
          > > call_user_func( "image$type ", $x);
          > > ?>[/color]
          >
          > Personally I like to do this:
          >
          > $imagecreatefro m_func = array(
          > 1 => "imagecreatefro mgif",
          > 3 => "imagecreatefro mpng",
          > 2 => "imagecreatefro mjpeg");
          >
          > $image_func = array(
          > 1 => "imagepng",
          > 3 => "imagepng",
          > 2 => "imagejpeg" );
          >
          > list($width, $height, $type, $attr) = getimagesize($f ilename);
          >
          > if($f = @$imagecreatefr om_func[$type]) {
          > $g = $image_func[$type];
          > $img = $f($filename);
          > // do stuff with image
          > $g($img);
          > }
          >
          > An elegant and flexible setup, methinks.[/color]


          That's to an extent what I'm doing, however, "$g($img)" I was unaware
          would work standalone. Because of the code structure I might fare
          better with call_user_func, will give that a whirl.

          Phil

          Comment

          Working...