Index: trunk/extensions/VipsScaler/VipsScaler_body.php |
— | — | @@ -133,11 +133,16 @@ |
134 | 134 | |
135 | 135 | wfDebug( __METHOD__ . " rotating '{$file->getName()}' by {$rotation}°\n" ); |
136 | 136 | 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 |
138 | 138 | # 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) ); |
142 | 147 | |
143 | 148 | wfDebug( sprintf( |
144 | 149 | "%s to shrink '%s'. Source: %sx%s, Physical: %sx%s. Shrink factors (rx,ry) = %sx%s.\n", |