ImageMagick - Resize image to square

Magick++ is an object-oriented C++ interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning Magick++.
Post Reply
Carole027
Posts: 1
Joined: 2019-02-10T23:18:33-07:00
Authentication code: 1152

ImageMagick - Resize image to square

Post by Carole027 » 2019-02-10T23:24:16-07:00

I have just started doing some ImageMagick work. I am currently trying to convert an image from a file size that is almost square (1411 x 1486) or similar sizes to a square shape, like 1024x1024 unfortunately the resize function doesn't seem to do a resize of the canvas so i keep getting number like 1024x982. I am wondering if there is anyway to convert a not so square image into a square image using their c++ libraries.

The reason they are not square is because i am converting GPS positions to UTM and getting a square shape, but unfortunately because of the curve of the earth they are generally about 400m off of being square... incase you were wondering.

User avatar
fmw42
Posts: 24463
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: ImageMagick - Resize image to square

Post by fmw42 » 2019-02-10T23:36:39-07:00

The -resize function will resize to keep aspect ratio by default. If you want to force the size to be exactly what you want, it will distort the image from its normal aspect ratio. In command line you would add !, so -resize 1024x1024!. Alternates are to resize and pad or resize and crop. See

https://imagemagick.org/script/command- ... p#geometry
https://imagemagick.org/Usage/thumbnails/#pad
https://imagemagick.org/Usage/thumbnails/#cut

Sorry, I not not know any of the APIs. But you posted to the Imagick forum, which is not C++. So I will move it to the C++ forum.

Post Reply