convert, provided by the ImageMagick package, has good behaviour in the resizing of images. If you were to write, for example:

[brose@allmybase-demo]$ convert -resize ‘1024×768’ in.jpg out.jpg

your image would be resized such that neither dimension exceeded the bounds, but unless the aspect ratio is dead on (convert honours and preserves aspect ratios), your image will not be the exact size you specified.

But, there is a simple fix. Append an exclamation point to the end of the size, like this:

[brose@allmybase-demo]$ convert -resize ‘1024×768!’ in.jpg out.jpg

and convert will do exactly what you ask, even if it means distorting the image by destroying the aspect ratio. This could be pretty handy to someone, so I decided to blog it. Heck, it’ll probably be useful to me again soon when I say, “hmmm… how did I do that again?”. Enjoy.