How to keep the picture movie after resizing it

The MagickWand interface is a new high-level C API interface to ImageMagick core methods. We discourage the use of the core methods and encourage the use of this API instead. Post MagickWand questions, bug reports, and suggestions to this forum.
Post Reply
carol_sun
Posts: 19
Joined: 2009-11-06T00:49:59-07:00
Authentication code: 8675309

How to keep the picture movie after resizing it

Post by carol_sun »

I want to resize a GIF image file use the code as follow. After resizing it, it's still a gif imgage file indeed, but it become static.
It seems only the first frame has been decoded . Is there something wrong in my code?

Code: Select all

            
            Magick::Blob blob(in_clone, insize);    //'in_clone' is original image file data
            Magick::Image img;
            img.read(blob);

            Magick::Geometry gm(smallWidth, smallHeight);   
            
            *orgHeight = img.rows();
            *orgWidth = img.columns();

           if ( img.rows() > smallHeight ||  img.columns() > smallWidth ) {
                img.scale(gm);
                img.modifyImage();
            }

            img.write(&blob, "GIF");

            *outsize = blob.length();
            *out = malloc(*outsize);
            memcpy(*out, blob.data(), blob.length());  // 'out' is new image file data after resizing
before resizing:
Image

after resizing:
Image
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: How to keep the picture movie after resizing it

Post by anthony »

NOTE this is not normally the forum I would write in, but I know about this.

While the command line will loop though the current image sequence resizing all images. Other API's do not. You will need to loop though reach image and resize it.

WARNING: GIF animation sequences need to be coalesced (layer method) into proper images without optimization before resizing. You can optimize (also a layer method) the animation after ward for frame and transparency optimizations again afterward.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply