Ensure that the dimensions of resized image fit inside original image