User experience
Suppose you have a large spherical equirectangular image called Pano.jpg. You embed it in a page with syntax such as
[[File:Pano.jpg|400px|thumb|photosphere]]
I am proposing the use of a "photosphere" image parameter which will force the image to be handled as a spherical panorama.
Initially, in the page view, we want to show a thumbnail of the image, similar to what it will look like after click in the pan-and-zoom interface. This requires reprojection from equirectangular to rectilinear, and cropping to a reduced field of view.
Example source image | Simple central crop, no reprojection | Reprojection with PTmender |
Parameters
The yaw, pitch, roll, field of view and aspect ratio are all free parameters which need to be chosen somehow. Pannellum extracts yaw, pitch and roll from the GPano metadata if it is available, and uses the image centre by default otherwise. That seems like a reasonable convention to follow.
Pannellum uses a default initial horizontal FOV of 100°, which is very wide by photography standards. The Wikipedia article on angle of view puts it into the "ultra-wide" category. I would welcome feedback on the choice of this parameter.
A default aspect ratio of 4:3 seems reasonable although I would welcome feedback on that also, and on whether there should be a thumbnail parameter to override it.
In the portrait orientation, Pannellum's vertical field of view ends up being so large as to cause distracting distortions. Note that rectilinear projection fails at FOV ≥180°. A bounding box of say 100°x100° is probably more reasonable than an unlimited vertical field of view.
Backend
After reviewing a few alternatives, I am suggesting that we use PTmender from the libpano13-bin package for this. It is poorly documented and the C code is scary, but it is a small binary and it does the job. As long as we control the input filenames and script contents, it probably won't overflow its stack buffers. It's not parsing EXIF, it just reads the image data, so the attack surface is not too bad.
It only supports TIFF output, so it's necessary to pass the resulting image through ImageMagick to convert it to a JPEG.
There will be an implementation in core and an implementation in Thumbor. MediaWiki will include an spc option in the image filename, short for spherical panorama crop. This will distinguish flat thumbnails from reprojected thumbnails.