Page 1 of 1

why i got exception from averageImages ?

Posted: 2008-11-29T07:11:42-07:00
by tomas.pulai
my code is like this:

Code: Select all

list<Image> imageList;

	Image image01;
	image01.read("./01.gif");
	int imgWidth_ = image01.columns();
	int imgHeight_ = image01.rows();

	Geometry newSize(imgHeight_,imgWidth_);
	//image01.scale(newSize);
	
	imageList.push_back(image01);

	Image image02;
	image02.read("./02.gif");
	image02.scale(newSize);
	imageList.push_back(image02);

	Image avi;//(newSize, Color(MaxRGB, MaxRGB, MaxRGB, 0));
	
	averageImages(&avi,imageList.begin(),imageList.end());
	avi.display();

terminate called after throwing an instance of 'Magick::ErrorOption'
what(): ImageMagick: image widths or heights differ `./01.gif' @ magick/image.c/AverageImages/802
*** Process aborted ***



Why ...what is a solution?
thanks..

Re: why i got exception from averageImages ?

Posted: 2008-11-29T08:29:20-07:00
by magick
ImageMagick retains the aspect ratio of the original image. You need to set the aspect flag to force the image to an exact size. One way, for example, is image.scale("640x480!"). This creates an image at 640x480 regardless of the original aspect ratio of the image.

Re: why i got exception from averageImages ?

Posted: 2008-11-29T09:03:55-07:00
by tomas.pulai
magick wrote:ImageMagick retains the aspect ratio of the original image. You need to set the aspect flag to force the image to an exact size. One way, for example, is image.scale("640x480!"). This creates an image at 640x480 regardless of the original aspect ratio of the image.
can i set aspect ratio flag to force via scale method which have a parameter a geometry object???

Re: why i got exception from averageImages ?

Posted: 2008-11-29T10:41:45-07:00
by magick