Index: trunk/extensions/VipsScaler/VipsScaler.php |
— | — | @@ -33,16 +33,9 @@ |
34 | 34 | $wgAutoloadClasses['VipsScaler'] = "$dir/VipsScaler_body.php"; |
35 | 35 | $wgAutoloadClasses['VipsCommand'] = "$dir/VipsScaler_body.php"; |
36 | 36 | $wgAutoloadClasses['VipsConvolution'] = "$dir/VipsScaler_body.php"; |
37 | | -$wgAutoloadClasses['SpecialVipsTest'] = "$dir/SpecialVipsTest.php"; |
38 | 37 | |
39 | | - |
40 | | -$wgSpecialPages['VipsTest'] = 'SpecialVipsTest'; |
41 | | -$wgExtensionAliasesFiles['VipsTest'] = "$dir/VipsScaler.alias.php"; |
42 | 38 | $wgExtensionMessagesFiles['VipsScaler'] = "$dir/VipsScaler.i18n.php"; |
43 | 39 | |
44 | | -$wgAvailableRights[] = 'vipsscaler-test'; |
45 | | -$wgGroupPermissions['*']['vipsscaler-test'] = true; |
46 | | - |
47 | 40 | $wgHooks['BitmapHandlerTransform'][] = 'VipsScaler::onTransform'; |
48 | 41 | $wgHooks['BitmapHandlerCheckImageArea'][] = 'VipsScaler::onBitmapHandlerCheckImageArea'; |
49 | 42 | |
Index: trunk/extensions/VipsScaler/VipsTest.php |
— | — | @@ -0,0 +1,33 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * Extension registration file for Special:VipsTest. The VipsScaler extension |
| 6 | + * must be enabled. |
| 7 | + */ |
| 8 | + |
| 9 | +if ( !defined( 'MEDIAWIKI' ) ) exit( 1 ); |
| 10 | + |
| 11 | +/** |
| 12 | + * The remote URL which will do the scaling. Use this to send scaling to an |
| 13 | + * isolated set of servers. Set this to null to do the scaling locally. |
| 14 | + */ |
| 15 | +$wgVipsThumbnailerUrl = null; |
| 16 | + |
| 17 | +/** |
| 18 | + * The host to send the request to when doing the scaling remotely. |
| 19 | + */ |
| 20 | +$wgVipsThumbnailerProxy = null; |
| 21 | + |
| 22 | +/** Registration */ |
| 23 | +$wgAutoloadClasses['SpecialVipsTest'] = "$dir/SpecialVipsTest.php"; |
| 24 | +$wgExtensionAliasesFiles['VipsTest'] = "$dir/VipsScaler.alias.php"; |
| 25 | +$wgAvailableRights[] = 'vipsscaler-test'; |
| 26 | +$wgGroupPermissions['*']['vipsscaler-test'] = true; |
| 27 | +$wgSpecialPages['VipsTest'] = 'SpecialVipsTest'; |
| 28 | + |
| 29 | +/** |
| 30 | + * Disable VipsScaler for ordinary image scaling so that the test has something |
| 31 | + * to compare against. |
| 32 | + */ |
| 33 | +$wgVipsOptions = array(); |
| 34 | + |
Property changes on: trunk/extensions/VipsScaler/VipsTest.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 35 | + native |
Index: trunk/extensions/VipsScaler/SpecialVipsTest.php |
— | — | @@ -21,7 +21,7 @@ |
22 | 22 | */ |
23 | 23 | |
24 | 24 | /** |
25 | | - * A Special page intended to test the Vipscaler. |
| 25 | + * A Special page intended to test the VipsScaler. |
26 | 26 | * @author Bryan Tong Minh |
27 | 27 | */ |
28 | 28 | class SpecialVipsTest extends SpecialPage { |
— | — | @@ -73,8 +73,8 @@ |
74 | 74 | return; |
75 | 75 | } |
76 | 76 | $vipsUrlOptions = array( 'thumb' => $file->getName(), 'width' => $width ); |
77 | | - if ( $request->getInt( 'sharpen' ) ) { |
78 | | - $vipsUrlOptions['sharpen'] = $request->getVal( 'sharpen' ); |
| 77 | + if ( $request->getVal( 'sharpen' ) ) { |
| 78 | + $vipsUrlOptions['sharpen'] = floatval( $request->getVal( 'sharpen' ) ); |
79 | 79 | } |
80 | 80 | if ( $request->getCheck( 'bilinear' ) ) { |
81 | 81 | $vipsUrlOptions['bilinear'] = 1; |
— | — | @@ -173,6 +173,14 @@ |
174 | 174 | 'label-message' => 'vipsscaler-form-bilinear', |
175 | 175 | ), |
176 | 176 | ); |
| 177 | + |
| 178 | + /** |
| 179 | + * Match ImageMagick by default |
| 180 | + */ |
| 181 | + global $wgSharpenParameter; |
| 182 | + if ( preg_match( '/^[0-9.]+x([0-9.]+)$/', $wgSharpenParameter, $m ) ) { |
| 183 | + $fields['SharpenRadius']['default'] = $m[1]; |
| 184 | + } |
177 | 185 | return $fields; |
178 | 186 | } |
179 | 187 | |
— | — | @@ -227,7 +235,7 @@ |
228 | 236 | * |
229 | 237 | */ |
230 | 238 | protected function streamThumbnail() { |
231 | | - global $wgVipsThumbnailerUrl; |
| 239 | + global $wgVipsThumbnailerUrl, $wgVipsThumbnailerProxy; |
232 | 240 | |
233 | 241 | $request = $this->getRequest(); |
234 | 242 | |
— | — | @@ -259,7 +267,7 @@ |
260 | 268 | # No remote scaler, need to do it ourselves. |
261 | 269 | # Emulate the BitmapHandlerTransform hook |
262 | 270 | |
263 | | - $dstPath = VipsCommand::makeTemp( strrchr( $file->getName(), '.' ) ); |
| 271 | + $dstPath = VipsCommand::makeTemp( $file->getExtension() ); |
264 | 272 | $dstUrl = ''; |
265 | 273 | wfDebug( __METHOD__ . ": Creating vips thumbnail at $dstPath\n" ); |
266 | 274 | |
— | — | @@ -288,7 +296,7 @@ |
289 | 297 | $options['bilinear'] = true; |
290 | 298 | wfDebug( __METHOD__ . ": using bilinear scaling\n" ); |
291 | 299 | } |
292 | | - if ( $request->getInt( 'sharpen' ) && $request->getInt( 'sharpen' ) < 5 ) { |
| 300 | + if ( $request->getVal( 'sharpen' ) && $request->getVal( 'sharpen' ) < 5 ) { |
293 | 301 | # Limit sharpen sigma to 5, otherwise we have to write huge convolution matrices |
294 | 302 | $options['sharpen'] = array( 'sigma' => floatval( $request->getVal( 'sharpen' ) ) ); |
295 | 303 | wfDebug( __METHOD__ . ": sharpening with radius {$options['sharpen']}\n" ); |
— | — | @@ -305,7 +313,7 @@ |
306 | 314 | header( "Content-Type: {$scalerParams['mimeType']}" ); |
307 | 315 | readfile( $dstPath ); |
308 | 316 | } else { |
309 | | - $this->streamError( 500 ); |
| 317 | + $this->streamError( 500, $mto->getHtmlMsg() ); |
310 | 318 | } |
311 | 319 | |
312 | 320 | # Cleanup the temporary file |
— | — | @@ -315,8 +323,6 @@ |
316 | 324 | |
317 | 325 | } else { |
318 | 326 | # Request the thumbnail at a remote scaler |
319 | | - global $wgVipsThumbnailerProxy; |
320 | | - |
321 | 327 | $url = wfAppendQuery( $wgVipsThumbnailerUrl, array( |
322 | 328 | 'file' => $file->getName(), |
323 | 329 | 'thumb' => $handler->makeParamString( $params ) . '-' . $file->getName() |
— | — | @@ -350,9 +356,10 @@ |
351 | 357 | * |
352 | 358 | * @param $code Integer: HTTP error either 404 or 500 |
353 | 359 | */ |
354 | | - protected function streamError( $code ) { |
| 360 | + protected function streamError( $code, $error = '' ) { |
355 | 361 | $this->getOutput()->setStatusCode( $code ); |
356 | 362 | $this->getOutput()->setArticleBodyOnly( true ); |
| 363 | + $this->getOutput()->addHTML( $error ); |
357 | 364 | } |
358 | 365 | |
359 | 366 | } |
Index: trunk/extensions/VipsScaler/modules/ext.vipsScaler/ext.vipsScaler.css |
— | — | @@ -8,3 +8,10 @@ |
9 | 9 | top:10px; |
10 | 10 | bottom:auto; |
11 | 11 | } |
| 12 | +.uc-mask { |
| 13 | + /* Remove annoying shadow */ |
| 14 | + box-shadow: none; |
| 15 | + box-shadow: none; |
| 16 | + -webkit-box-shadow: none; |
| 17 | + -moz-box-shadow: none; |
| 18 | +} |