Index: trunk/extensions/VipsScaler/VipsScaler_body.php |
— | — | @@ -131,18 +131,22 @@ |
132 | 132 | # Do the resizing |
133 | 133 | $rotation = 360 - $handler->getRotation( $file ); |
134 | 134 | |
| 135 | + wfDebug( __METHOD__ . " rotating '{$file->getName()}' by {$rotation}°\n" ); |
135 | 136 | if ( empty( $options['bilinear'] ) ) { |
136 | 137 | # Calculate shrink factors. Offsetting by 0.5 pixels is required |
137 | 138 | # because of rounding down of the target size by VIPS. See 25990#c7 |
138 | | - if ( $rotation % 180 == 90 ) { |
139 | | - # Rotated 90 degrees, so width = height and vice versa |
140 | | - $rx = $params['srcWidth'] / ($params['physicalHeight'] + 0.5); |
141 | | - $ry = $params['srcHeight'] / ($params['physicalWidth'] + 0.5); |
142 | | - } else { |
143 | | - $rx = $params['srcWidth'] / ($params['physicalWidth'] + 0.5); |
144 | | - $ry = $params['srcHeight'] / ($params['physicalHeight'] + 0.5); |
145 | | - } |
| 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); |
146 | 142 | |
| 143 | + wfDebug( sprintf( |
| 144 | + "%s to shrink '%s'. Source: %sx%s, Physical: %sx%s. Shrink factors (rx,ry) = %sx%s.\n", |
| 145 | + __METHOD__, $file->getName(), |
| 146 | + $params['srcWidth'], $params['srcHeight'], |
| 147 | + $params['physicalWidth'], $params['physicalHeight'], |
| 148 | + $rx, $ry |
| 149 | + )); |
| 150 | + |
147 | 151 | $commands[] = new VipsCommand( $wgVipsCommand, array( 'im_shrink', $rx, $ry ) ); |
148 | 152 | } else { |
149 | 153 | if ( $rotation % 180 == 90 ) { |
— | — | @@ -152,6 +156,14 @@ |
153 | 157 | $dstWidth = $params['physicalWidth']; |
154 | 158 | $dstHeight = $params['physicalHeight']; |
155 | 159 | } |
| 160 | + wfDebug( sprintf( |
| 161 | + "%s to bilinear resize %s. Source: %sx%s, Physical: %sx%s. Destination: %sx%s\n", |
| 162 | + __METHOD__, $file->getName(), |
| 163 | + $params['srcWidth'], $params['srcHeight'], |
| 164 | + $params['physicalWidth'], $params['physicalHeight'], |
| 165 | + $dstWidth, $dstHeight |
| 166 | + )); |
| 167 | + |
156 | 168 | $commands[] = new VipsCommand( $wgVipsCommand, |
157 | 169 | array( 'im_resize_linear', $dstWidth, $dstHeight ) ); |
158 | 170 | } |