Better size determination

I had some problems with the old implementation of `newSize`, so I rewrote it.
(I think the aspect ratio of images was not always respected.)