Resize image with mogrify without keeping aspect ratio

15.8k views Asked by At

I feel silly for having to ask such a simple question, but I have spent the past hour having absolutely no luck whatsoever finding a solution to this. Everyone seems like they need to do the exact opposite of what I need to do.

My question is simply how do I tell mogrify and/or convert to not keep the aspect ratio when resizing an image? I need the image to be an exact power of 2 for both width and height and the images do not come in a 1:1 ratio which means one side has to stretch.

The closest thing I have to an answer is the -extent flag, but that just extends the canvas. I need the original image to fill the entire thing.

2

There are 2 answers

2
ozdrgnaDiies On BEST ANSWER

After another half hour of searching I have stumbled upon the overly simple answer. The following will resize an image with the exact dimensions given:

mogrify input.png -resize 256x256! output.png

If you want to read more about it, I got the answer from this link:

https://superuser.com/questions/212752/how-to-stretch-an-image-in-one-dimension

0
chikadance On

use "!" in convert -resize, for ex:

convert "from-img"  -resize 800x480! "to-img"