fit image to maximum height and width rather than scale