rotate images, borrowed from php.net/manual/imagick.getimageorientation.php