I erroneously thought that the browser was rotating the image before it was uploaded, but it turns out it was jimp that was rotating the image in the backend.
This is a known issue with older versions of jimp. Upgrading from version 0.22 to 1.6.0 seems to have solved the problem.
https://github.com/jimp-dev/jimp/issues/733
https://github.com/jimp-dev/jimp/issues/920
Version 1.6.0 still rotates the image based on the exif data, but it removes the orientation flag from the image data as well. This allows it to be displayed correctly in the browser.