r104399 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r104398‎ | r104399 | r104400 >
Date:06:17, 28 November 2011
Author:tstarling
Status:deferred
Tags:
Comment:
Reduce the amount of distracting movement seen in the lower right corner of Special:VipsTest comparisons by offsetting the scaling parameters by 1/8 pixels instead of 1/2 pixels. Output the scaling factors with less loss of precision.
Modified paths:
  • /trunk/extensions/VipsScaler/VipsScaler_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/VipsScaler/VipsScaler_body.php
@@ -133,11 +133,16 @@
134134
135135 wfDebug( __METHOD__ . " rotating '{$file->getName()}' by {$rotation}°\n" );
136136 if ( empty( $options['bilinear'] ) ) {
137 - # Calculate shrink factors. Offsetting by 0.5 pixels is required
 137+ # Calculate shrink factors. Offsetting by a small amount is required
138138 # because of rounding down of the target size by VIPS. See 25990#c7
139 - # No need to invert source and physical dimensions. They already got switched if needed.
140 - $rx = $params['srcWidth'] / ($params['physicalWidth'] + 0.5);
141 - $ry = $params['srcHeight'] / ($params['physicalHeight'] + 0.5);
 139+ #
 140+ # No need to invert source and physical dimensions. They already got
 141+ # switched if needed.
 142+ #
 143+ # Use sprintf() instead of plain string conversion so that we can
 144+ # control the precision
 145+ $rx = sprintf( "%.18e", $params['srcWidth'] / ($params['physicalWidth'] + 0.125) );
 146+ $ry = sprintf( "%.18e", $params['srcHeight'] / ($params['physicalHeight'] + 0.125) );
142147
143148 wfDebug( sprintf(
144149 "%s to shrink '%s'. Source: %sx%s, Physical: %sx%s. Shrink factors (rx,ry) = %sx%s.\n",

Status & tagging log