calculate the new size of the image