Fixed aspect ratio calculation for thumbnails.

This is a smaller change than #11195. This only contains the bare minimum needed to fix thumbnail generation in PhpThumb class.