Reputation: 1219
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.
Upvotes: 19
Views: 25355
Reputation: 12749
Using 1024x1024!
will not pad the thumbnail.
Here is a link to what you want http://www.imagemagick.org/Usage/thumbnails/#pad
The command line from the link (to prevent the link-rot):
convert -define jpeg:size=200x200 hatching_orig.jpg -thumbnail '100x100>' \
-background skyblue -gravity center -extent 100x100 pad_extent.gif
Upvotes: 22
Reputation: 7209
i did as Joshua said. it worked for one image. (thanks Joshua)
i also wanted to add a solution for batch resize because
convert -resize 1024x1024! *.png
did not worked
so here there is an example command for working sample.
mkdir scaled
for %%x in (*.png) do convert -resize 1024x1024! %%x .\scaled\%%x
Upvotes: 0
Reputation: 6621
You can add a ! to your geometry like "1024x1024!" on the resize or create an explicit geometry for the resize method. You may also need to set the aspect flag though the ! is supposed to do that (I've read some people have needed to do this, don't have an explanation for you on that, though).
Upvotes: 10