MagickWand and Animation

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.
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

MagickWand and Animation

Post by el_supremo »

I've written a simple C program which uses MagickWand to convert 11 successive GIF images into a single animated GIF file. This is the code for the function which does that:

Code: Select all

#include <windows.h>
#include <wand/MagickWand.h>
#include "animate.h"

char *flist[] = {
// The list must end with a NULL pointer

MagickWand *mw,*rw;

void do_animation(void)
	char **ptr;
	//char temp[128];

	mw = NewMagickWand();

	for(ptr = flist;*ptr;ptr++) {
		rw = NewMagickWand();

	mw = DestroyMagickWand(mw);
This works fine when it outputs to animate.gif but I also tried an MPG file with "animate.mpg" and, although it called the mpeg2enc.exe program and produced its output in a Command Prompt window, the resulting output file is zero length. Although there are 11 frames, the command prompt window output from mpeg2enc goes up to something like 32 or 33 frames.
And since the GIF animation had worked, I also tried to convert it to an MPG with the command line:
convert animate.gif animate.mpg
and it produces the same results as my program, a zero length file.

Am I missing any MagickWand Incantations required to get an MPG?

[edit] I forgot to mention that each gif input image is 580x480 pixels.