Requests for comment/Square bounding boxes

The current mediawiki syntax for image thumbnails and resizing works poorly for images which are taller than they are wide. The  option attempts to remedy this, but properly scaling an thumbnail to fit a square bounding box requires the user to manually compute the aspect ratio of the image. There is no way to directly obtain a thumbnail whose height is limited by the user's thumb size preference.

Proposals
There are several proposals for remedying this situation:
 * 1) Change mediawiki to use square bounding boxes by default (opt-out).
 * 2) * Alternatively, only change the default bounding box used by  to be square.
 * 3) Add a new image option to request a square bounding box (opt-in).
 * 4) Add a new "upright=auto" option (minimalist, opt-in)
 * 5) Add a new "scale=N" option (adds new functionality, opt-in)

In an RFC review meeting on 2014-04-02 the following alternative was agreed upon:
 * Use square bounding boxes for thumbnails without an explicit size specification. (bug 63903)
 * Use square bounding boxes for thumbnails scaled using "upright" (bug 63904) pending investigation on the number of pages that would be affected.

Consensus proposal
Assuming a 220px default thumbnail size: 200px             (unchanged, uses width-based scaling) thumb             (scales to 220 x 220 bounding box) thumb|upright     (scales to 220 x 220 bounding box?) thumb|upright=0.5 (scales to 110 x 110 bounding box?) Currently the default 'upright' scale factor is 0.75. Assuming that the 'upright' option with the default scale is usually applied to 3:4 portrait-aspect-ratio images, it is possible that changing the default scale factor to 1.00 at the same time upright is changed to use a square bounding box will result in fewer images changing size. We are currently gathering statistics on this point.

Square bounding boxes by default
In this version of the proposal, the existing width-only restrictions on image size would be the exception, not the rule. Assuming a 220px default thumbnail size: 200px             (scales to 200 x 200 bounding box) thumb             (scales to 220 x 220 bounding box) thumb|upright=0.5 (scales to 110 x 110 bounding box) x200px            legacy syntax, restricts height only 150x200px         legacy syntax, uses specified non-square bounding box 200xpx            new syntax, restricts width only? no way to have a thumbnail scaled by default width only

New "square" option
In this version of the proposal, a new "square" image option opts-in to square bounding boxes. Again assuming a 220px default thumbnail size: (resizes to 200x200px) (resizes to 200x200px) (resizes to 200x200px, using max dimension) (resizes to 220x220px) (resizes to 110x110px)

upright=auto
In this version of the proposal, we narrowly solve the specific "thumbnail with a square bounding box of the default size" issue by adding a new "auto" value to the existing "upright" image option. Assuming a 220px default thumbnail size: (resizes to 220x220px) The user must use the existing syntax for square bounding boxes of an explicit size: There is no support for combining the 'auto' option with other uses of upright. That is, there is no way to get a square thumbnail of "half the default size", which would involve combining "upright=0.5" and "upright=auto".

scale=N
In this version of the proposal, we add a new "scale" option, which is a better replacement for "upright" and uses a square bounding box by default. Assuming a 220px default thumbnail size: (resizes to 220x220px) (resizes to 110x110px) (resizes to half of Foobar.jpg's "natural size") The "scale" option allows scaling thumbnails like "upright" does, but it also allows scaling images based on the image's natural size. Using "thumb" and "scale" together has the side effect of upgrading the default thumbnail size specification to a square bounding box.

Discussion
Another hacky way to get a square bounding box for a thumbnail with current wikitext is: thumb|upright=XXX where the  is the computed current aspect ratio of. This will give unintended results if a new version of  is uploaded with a different aspect ratio. However, this is what Parsoid will likely implement as the default serialization in the short term. —The preceding unsigned comment was added by Cscott (talk • contribs) 16:11, 27 March 2014 (UTC)

Option 1 would be a torches-and-pitchforks change, as it breaks changes in an incompatible and likely unappealing manner any existing usages of "portrait"-oriented images. -2 from me on this. Anomie (talk) 17:09, 27 March 2014 (UTC)

As for option 2, we already have a syntax for specifying a square bounding box with explicit pixel dimensions, that being "200x200px". So just like 'upright', IMO this should only have an effect if pixel dimensions are not given. "|upright=0.5|square" probably also deserves more thought, as I doubt that the user really intends to bound it to 110x110px rather than something like 110x220px. Anomie (talk) 17:09, 27 March 2014 (UTC)

Implementation

 * The "square" image option is implemented by https://gerrit.wikimedia.org/r/120856
 * The first part of the consensus proposal, which uses square bounding boxes for thumbnails without explicit size specifications, is implemented in https://gerrit.wikimedia.org/r/123683
 * Changing "upright" to use square bounding boxes and a default aspect ratio of 1.0 is not yet implemented.