Page 1 of 1

MagickWriteImages problem

Posted: 2007-07-25T10:57:34-07:00
by el_supremo
When I run the TclMagick test script it crashes when it gets to the test of MagickMorphImages. The script reads a miff file consisting of 5 frames, morphs 5 frames between each one and then writes the result to a gif file using MagickWriteImages. This causes an extraordinary amount of disk activity and really slows my system down and then it crashes. If I try it with morphs of more than 3 intermediate images it also crashes.
I wrote a C program to do the same thing and found that MagickMorphImages isn't causing the problem - it's MagickWriteImages. For morphs of up to 4 intermediate images it seems to be Ok, but with 5 it starts thrashing the disk again although it does eventually complete without crashing.
The images in sequence.miff are only 77x80 pixels, so even with the extra 25 morphed frames I wouldn't have expected writing them to load the system down.
Another side effect is that once I've done the test with 5 morphed images, my system thrashes when loading new programs and doing other tasks which are normally essentially instantaneous.

I'm using version 6.3.4 on Win XP Pro and there's 25GB of free disk space on C: - I recompiled TclMagick to use 6.3.4.
Should MagickWriteImages thrash when writing about 30 images in a sequence?

The input file is here: http://members.shaw.ca/el_supremo/sequence.miff
and my C test function is:

Code: Select all

#include <windows.h>
#include <stdio.h>
#include <string.h>
#include <wand/magick_wand.h>

void test_wand(void)
{
	MagickWand *m_wand = NULL;
	MagickWand *morph = NULL;

	MagickWandGenesis();
	m_wand = NewMagickWand();
	morph = NewMagickWand();

	MagickReadImage(m_wand,"sequence.miff");

	morph = MagickMorphImages(m_wand,5);
	if(morph == NULL) {
		MessageBox(NULL,"Morph returned NULL!","",MB_OK);
		m_wand = DestroyMagickWand(m_wand);
		morph = DestroyMagickWand(morph);
		MagickWandTerminus();
		return;
	}

	MagickWriteImages(morph,"sequence.gif",MagickTrue);

	m_wand = DestroyMagickWand(m_wand);
	morph = DestroyMagickWand(morph);
	MagickWandTerminus();
}
Pete

Re: MagickWriteImages problem

Posted: 2007-07-25T12:07:23-07:00
by magick
Your program worked fine for us. We're using ImageMagick 6.3.5-4 Beta. Until it is released, try calling MagickSetImageMatte() with MagickFalse before you call MagickWriteImages(). That may fix the problem for you.

Re: MagickWriteImages problem

Posted: 2007-07-25T12:48:45-07:00
by el_supremo
Thanks for the prompt response.
I added MagickSetImageMatte to the C code and now it takes about a minute for 5 morphs with very little disk thrashing but after that there's still a lot more disk I/O which slows down other tasks such as starting an editor. I also added it to the TCL script which now finishes 3 morphs very quickly (it crashed with 3 before) but thrashes madly and then crashes with 4 morphs. The crash is caused by an attempt to read location zero. I can't figure out why the script and C program behave differently when they both call MagickWriteImages.
Does your program take a minute or so to do 5 morphs? My system is 3.2Ghz.

Pete

Re: MagickWriteImages problem

Posted: 2007-07-25T13:16:28-07:00
by magick
Your program runs in 3.61 seconds on our 2.8ghz processor running Fedora Core 7 and ImageMagick 6.3.5-4 Beta.

Re: MagickWriteImages problem

Posted: 2007-07-31T12:42:35-07:00
by el_supremo
FYI: I've just installed Windows IM6.3.5-4 Q8 and both my program and the TCL script finish 5 morphs in a couple of seconds with no thrashing at all.

Pete