"Chung Leong" <chernyshevsky@hotmail.com> wrote in message news:<T4udnXZMr7Tlij3dRVn-gg@comcast.com>...[color=blue]
> "Andy Hassall" <andy@andyh.co.uk> wrote in message
> news:eo5o90t5ig388t9h2t7cdhbu35lq7jniif@4ax.com...[color=green]
> > On 7 May 2004 15:21:39 -0700,
soazine@erols.com (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 = imagecreatefromgif('circle_1.gif');
> > $type = 'png';
> > header("Content-type: image/$type");
> > call_user_func("image$type", $x);
> > ?>[/color]
>
> Personally I like to do this:
>
> $imagecreatefrom_func = array(
> 1 => "imagecreatefromgif",
> 3 => "imagecreatefrompng",
> 2 => "imagecreatefromjpeg");
>
> $image_func = array(
> 1 => "imagepng",
> 3 => "imagepng",
> 2 => "imagejpeg");
>
> list($width, $height, $type, $attr) = getimagesize($filename);
>
> if($f = @$imagecreatefrom_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