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

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
Bunkai
Posts: 22
Joined: 2007-01-15T07:37:59-07:00

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

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

Post by magick »

By default, ImageMagick respects the aspect ratio of the source image. Override this default behavior with a bang, !. Try
  • Geometry("1024x2000!");
Bunkai
Posts: 22
Joined: 2007-01-15T07:37:59-07:00

Post by Bunkai »

Thank you, very much.
Bunkai
Posts: 22
Joined: 2007-01-15T07:37:59-07:00

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

Post 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
Bunkai
Posts: 22
Joined: 2007-01-15T07:37:59-07:00

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

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