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 limit or scale a thumbnail based on height. (This is not entirely correct; you can specify a vertical without a horizontal bound with eg 'x200px', though that will get translated into a horizontal scale factor and so your resulting size might not exactly match what you asked for. But it should fit within the requested bounds more or less.)

Proposals
There are four 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)

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