why i got exception from averageImages ?

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
tomas.pulai

why i got exception from averageImages ?

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

Re: why i got exception from averageImages ?

Post 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.
tomas.pulai

Re: why i got exception from averageImages ?

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

Re: why i got exception from averageImages ?

Post by magick »

Post Reply