Properly calculate width and height of uploaded images.