libvips does best-fit by default. For example, using vips CLI
$ vips text out.png "This text is resized to best fill the space given." --width 320 --height 140 --rgba
I think you just have to map width and height options to Image lib.
Image