Page 1 of 1

Magick++ image::resize() - not working?

Posted: 2007-01-21T03:20:40-07:00
by Bunkai
I do aplogize if I do anything wrong. The same situation as with Magick++ Image::Extent() is with Image::Resize(). After applying Image::Resize() to my loaded document, and save it back, the image contains in original size. This is an example I did:

Magick::Image imageMyImage;
imageMyImage.read("F-16.jpg");
Magick::Geometry geometryExtend(1024, 2000, 0, 0);
imageMyImage.resize(geometryExtend);
imageMyImage.write("test.jpg");


"F-16.jpg" is a standard image being 1024x768 pixels large. After saving it back, it contained the original size 1024x768.

Version of Image Magick: ImageMagick-6.3.2.0-Windows.

Thank you,

Posted: 2007-01-21T10:47:04-07:00
by magick
By default, ImageMagick respects the aspect ratio of the source image. Override this default behavior with a bang, !. Try
  • Geometry("1024x2000!");

Posted: 2007-01-21T12:54:16-07:00
by Bunkai
Thank you, very much.

Re: Magick++ image::resize() - not working?

Posted: 2009-08-16T11:56:34-07:00
by Bunkai
Thank you for the response above. Is there any way how to override aspect ratio when using Geometry(1024, 2000); which mean when I use parameters I receive above in the application.

Using your version it makex more difficult to insert the parameters into Geometry() structure, because, I have to firstly generate text array, such as "1024x2000!", that will be later used as parameter in Geometry() structure.

Best regards,
Rene

Re: Magick++ image::resize() - not working?

Posted: 2009-08-16T12:22:12-07:00
by Bunkai
I was experimenting and found the answer: Geometry.aspect(true); forces to override the aspect ratio. exactly as in the example below(myGeometry.aspect(true);):


Image imgTest(Geometry(200,200), "transparent");
imgTest.type(TrueColorMatteType);

Image imgCompose(Geometry(20,20), "red");
imgCompose.type(TrueColorMatteType);

Geometry myGeometry(200, 400);
myGeometry.aspect(true);

imgTest.resize(myGeometry);

imgTest.composite(imgCompose, 10, 10, OverCompositeOp);
imgTest.write("test.png");

Best regards..