Made sure image maxheight and maxwidth never made the image larger than the original measurements