Re: [GD-DEVEL] resize anim gif

[email protected] ("Pierre Joye") Fri, 28 Mar 2008 12:27:07 +0100
Newsgroups php.gd.devel
Message-ID <[email protected]>
Hi,

On Fri, Mar 28, 2008 at 12:11 PM, [email protected] <[email protected]> wrote:
> i'd like to resize gif containing multiple frames.
>  if i try this it only saves first frame :(
>
>        FILE *fp=0;
>        gdImagePtr im, im2;
>        int width,height,error=0;
>        fp = fopen("1.gif", "rb");
>        if (!fp) return -1;
>        im  = gdImageCreateFromGif(fp);
>        fclose(fp);
>        fp = fopen("2.gif", "wb");
>        gdImageGif(im,fp);
>        fclose(fp);
>        gdImageDestroy(im);
>
>  someone possibly has that obviously terribly complex code that reads,
>  resizes and saves all frames ?

GD can't read animated GIF in its current stable version (2.0.x). It
is on our todo for gd 2.1 and a patch is available here:

http://bugs.libgd.org/?do=details&task_id=57&pagenum=2

>  i did find one solution with imagemagick convert, but it is surprisingly
>  slow, way slower than imagemagick mogrify - which does not work correctly,
>  would gd version work ok, faster ?

It really depends on a couple of things:

- how many frames (obviously)
- how large are each frame (GIF frames can have different sizes)
- the interpolation you use (bicubic, nearest, etc.)

I'm working on the new resize and affine transformation today and
should hit CVS tonight. It should then not be very hard to find the
faster way to do this task. However, the bottleneck is certainly to
read the GIF anim (for small images).

Cheers,
-- 
Pierre
http://blog.thepimp.net | http://www.libgd.org