Smarter image size calculation.