Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
you can do that now by computing the Width and Height to satisfy your aspect ratio and then using just crop WxH+0+0 +repage.
The issue you must consider which contributes to the coding is which dimension to use to compute the aspect ratio so that you can crop and not need to pad. Thus you may need to compute the aspect ratio of the input image and compare it to the desired aspect ratio.
for unix see my scripts, aspect and aspectpad, thought they do not do exactly what you want.
I would have though that only works for square input images...
In IMv7 you can use %[fx:...] expressions directly in -crop, or better still -extent (which can crop or pad an image to fit the calculated size).
In IMv6 you can fudge it using a distort viewport...
For example see IM Examples, Centered Square Crop http://www.imagemagick.org/Usage/distor ... red_square
This is for the largest 1:1 crop you can get from an image. But should be able to calculate a largest 4:3 ratio crop with minimal changes.
Anyone like to give it a go... Results can be added to the above area of IM examples with your name.
I was going to create this example, but after some thought it doesn't seem too useful. First, the OP sets gravity, which -distort doesn't use. Your square example assumes a gravity of center. Second, the solution is less well defined when not a square. If the input image is 90x100 and 4:3 is requested, what is the output dimensions desired? 90x68 is a 4:3.02 ratio and 90x67 is a 4:2.98 ratio. Or is a 88x66 output better? Maybe the user didn't intend to impose an orientation, so 75x100 is best?
Your square example shows the concept. A user could easily adapt that to their well-defined need.
I have a bash unix script, aspectpad, that pads to the desired aspect ratio. I also have a script, aspect, that will either crop or pad, but it includes a resize. So you would need to specify the aspect widthxheight so as not to resize. See the link below. Neither do exactly what you want, but may be close enough for your needs.