Page 1 of 1

How to keep the picture movie after resizing it

Posted: 2009-11-08T18:43:25-07:00
by carol_sun
I use the ImageMagick Studio web interface to resize a GIF image file, it works successfully.
But if I use Magick++ to resize it, 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 with 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

Re: How to keep the picture movie after resizing it

Posted: 2009-11-18T20:43:56-07:00
by carol_sun
anthony wrote: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.
thanks for your reply. And I tried using Magick++ STL algorithms : http://www.imagemagick.org/Magick++/STL.html
It does work for most of the GIF image files, but for some , after resizing, the GIF images don't move as before.
And for these special pictures, the command line do right: ./convert 11K34235F-7.gif -resize 70x70 -layers Optimize tmp.gif.
So I guess there's nothing wrong with the installation of ImageMagick. Did I lose some step in my code?

makefile like this:
LIB_GRAPHIC = -L/usr/local/imagemagick/lib -lMagick++ -lMagickWand -lMagickCore -pthread -lepoll -ljpeg -lpng -ltiff -lbz2 -lxml2 -lz -lm -llcms -pthread -lfreetype

Code: Select all

        list<Image> imageList; 
        readImages( &imageList, "dog.gif"); 
        Magick::Geometry gm(100, 100);    
        for_each ( imageList.begin(), imageList.end(), sampleImage(gm));         
        writeImages( imageList.begin(), imageList.end(), "output.gif"); 
picutre befor resizing:
http://www.ajrice.com/UploadFile/Image/11K34235F-7.gif

use command line to resize:
http://www.ajrice.com/UploadFile/Image/tmp.gif

use my code:(it's movie but not right)
http://www.ajrice.com/UploadFile/Image/2.gif