Problem/Motivation
PHP bugfix https://github.com/php/php-src/commit/22c487616f132ee7ebfa838bce9d14c924... has changed the logic to calculate image dimensions for rotated images, causing Drupal's critical #2918570: Drupal\KernelTests\Core\Image\ToolkitGdTest fails on PHP 7.1.x-dev and 7.0.x-dev following a PHP bugfix.
See also:
libgd fix - https://github.com/libgd/libgd/issues/225
Proposed resolution
Fix the Rectangle class to adapt the same calculation logic as GD in libgd 2.2.2 and above. This way images rotated in Drupal will always take the same dimensions, regardless of the libgd library actually linked to the PHP instance in use.
Remaining tasks
User interface changes
None
API changes
None
Data model changes
None