MagickWriteImages problem

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

MagickWriteImages problem

Post 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
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: MagickWriteImages problem

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

Re: MagickWriteImages problem

Post 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
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: MagickWriteImages problem

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

Re: MagickWriteImages problem

Post 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
Post Reply