I think we'll need to do this in JS then, as it depends on how the slide is rendered. I think we should be able to do something (although I don't know where) along the following lines - yes, this is rubbish JavaScript as well!:

    if ($("img").width() > $(".content").innerWidth() OR $("img").height() > $(".content").innerHeight()) {
        if ($("img").width() > $("img").height()) {
            $("img").width($("content").innerWidth());
            $("img").height("100%");
        } else {
            $("img").height($("content").innerHeight());
            $("img").width("100%");
        }
    }