Image Resizing with Custom Property Called Length

I have a current image resizing system that is being replaced with the new CloudFlare Image Resizing. One of the current properties that we support is one called length which is defined by this: instead of using width or height , length can be specified as the size of the longest dimension of the image. The shorter side will be resized proportionally. I am trying to figure out a way to use the current cf options that would satisfy this existing property but I am not sure if it is possible.

I’m wondering if you send both W and H with your “Length” value, will Image Resize figure out which one applies, then scales appropriately (fit=contain).

I thought about that, but our current system does this automatically without the initial request needing to contain the width and the height. The goal is to make the change over without breaking any of the functionality from the user side.