It's my first post.
I've searched for this and found only "-border" and "-extend" options, but they don't give you the actual control over canvas size.
May be I need to use a combination of a some basic options.
So let's say my original image is 300x200 in size. What I need is a command-line, which will resize canvas to a given size and fit original image inside it, preserving aspect ratio.
So if I specify new canvas size 900x900 the original image should become 900x600 and be center-aligned inside 900x900 canvas.
Again if I specify canvas size to 500x100, the original image should become 150x100 and be center-aligned inside 500x100 canvas.

Any help with this will be greatly appreciated!
Thank you developers for a great program!