Magick++ Resize Image

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
Morty
Posts: 3
Joined: 2011-02-04T18:06:12-07:00
Authentication code: 8675308

Magick++ Resize Image

Post by Morty »

Hi there,

I hope someone can help me.

I am using the Magick++ API and want to resize a 1920x1080 image to 720x480. I can do this with the command line no problem, but can't find a way to achieve this with Magick++. My images keep coming out as 720 x 405.

I have tried :

Geometry newSize = Geometry(720, 480);
background.resize(newSize);

Geometry newSize = Geometry(720, 480);
background.zoom(newSize);

Thanks for your time,

Jim
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Magick++ Resize Image

Post by magick »

The image aspect ratio is respected by default for image geometries. You can override this behavior, like this:
  • Geometry newSize = Geometry("720x480!");
Morty
Posts: 3
Joined: 2011-02-04T18:06:12-07:00
Authentication code: 8675308

Re: Magick++ Resize Image

Post by Morty »

Thanks,

It's so obvious, now. Your help is much appreciated.

All the best,

Jim
Morty
Posts: 3
Joined: 2011-02-04T18:06:12-07:00
Authentication code: 8675308

Re: Magick++ Resize Image

Post by Morty »

I found the following works as well:

Code: Select all

Geometry newSize = Geometry(720, 480);
// Resize without preserving Aspect Ratio
newSize.aspect(true);
background.resize(newSize);
Hope this helps someone else.
Post Reply