Example. The API returns whatever urlwidth parameter is passed as the thumbnail width (as long as it's not smaller than the original width).
The size logic in TransformationalImageHandler::doTransform seems completely wrong: File::transform will pass in blindly whatever size it was instructed to target, then clientWidth is set to that size, while physicalWidth is correctly set to the file width by normaliseParams, but clientWidth is what eventually gets passed to the ThumbnailImage object. (I suppose this is for the client-side scaling option that nobody ever uses?)
The API then tries to fix this by checking if the thumb URL is equal to the original URL and ignore the size claimed by ThumbnailImage in that case (cf rMWb744fdba237f: * (bug 23834) Invalid "thumbwidth" and "thumbheight" in "imageinfo" query when…) which is a poor workaround that fails for EXIF rotations and will probably fail for more in the future.