r75703 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r75702‎ | r75703 | r75704 >
Date:19:11, 30 October 2010
Author:btongminh
Status:deferred
Tags:
Comment:
Follow-up r75702: stylize
Modified paths:
  • /trunk/phase3/includes/media/Bitmap.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/media/Bitmap.php
@@ -30,7 +30,7 @@
3131 $params['physicalWidth'] = $srcWidth;
3232 $params['physicalHeight'] = $srcHeight;
3333 # Skip scaling limit checks if no scaling is required
34 - if( !$image->mustRender() )
 34+ if ( !$image->mustRender() )
3535 return true;
3636 }
3737
@@ -46,8 +46,8 @@
4747
4848 return true;
4949 }
50 -
51 -
 50+
 51+
5252 // Function that returns the number of pixels to be thumbnailed.
5353 // Intended for animated GIFs to multiply by the number of frames.
5454 function getImageArea( $image, $width, $height ) {
@@ -71,7 +71,7 @@
7272 'clientWidth' => $params['width'],
7373 'clientHeight' => $params['height'],
7474 # Comment as will be added to the EXIF of the thumbnail
75 - 'comment' => isset( $params['descriptionUrl'] ) ?
 75+ 'comment' => isset( $params['descriptionUrl'] ) ?
7676 "File source: {$params['descriptionUrl']}" : '',
7777 # Properties of the original image
7878 'srcWidth' => $image->getWidth(),
@@ -83,10 +83,10 @@
8484
8585 wfDebug( __METHOD__ . ": creating {$scalerParams['physicalSize']} thumbnail at $dstPath\n" );
8686
87 - if ( !$image->mustRender() &&
 87+ if ( !$image->mustRender() &&
8888 $scalerParams['physicalWidth'] == $scalerParams['srcWidth']
8989 && $scalerParams['physicalHeight'] == $scalerParams['srcHeight'] ) {
90 -
 90+
9191 # normaliseParams (or the user) wants us to return the unscaled image
9292 wfDebug( __METHOD__ . ": returning unscaled image\n" );
9393 return $this->getClientScalingThumbnailImage( $image, $scalerParams );
@@ -96,7 +96,7 @@
9797 if ( !$dstPath ) {
9898 # No output path available, client side scaling only
9999 $scaler = 'client';
100 - } elseif( !$wgUseImageResize ) {
 100+ } elseif ( !$wgUseImageResize ) {
101101 $scaler = 'client';
102102 } elseif ( $wgUseImageMagick ) {
103103 $scaler = 'im';
@@ -117,13 +117,13 @@
118118
119119 if ( $flags & self::TRANSFORM_LATER ) {
120120 wfDebug( __METHOD__ . ": Transforming later per flags.\n" );
121 - return new ThumbnailImage( $image, $dstUrl, $scalerParams['clientWidth'],
 121+ return new ThumbnailImage( $image, $dstUrl, $scalerParams['clientWidth'],
122122 $scalerParams['clientHeight'], $dstPath );
123123 }
124124
125125 # Try to make a target path for the thumbnail
126126 if ( !wfMkdirParents( dirname( $dstPath ) ) ) {
127 - wfDebug( __METHOD__.": Unable to create thumbnail destination directory, falling back to client scaling\n" );
 127+ wfDebug( __METHOD__ . ": Unable to create thumbnail destination directory, falling back to client scaling\n" );
128128 return $this->getClientScalingThumbnailImage( $image, $scalerParams );
129129 }
130130
@@ -139,7 +139,7 @@
140140 $err = $this->transformGd( $image, $scalerParams );
141141 break;
142142 }
143 -
 143+
144144 # Remove the file if a zero-byte thumbnail was created, or if there was an error
145145 $removed = $this->removeBadFile( $dstPath, (bool)$err );
146146 if ( $err ) {
@@ -147,152 +147,152 @@
148148 return $err;
149149 } elseif ( $removed ) {
150150 # Thumbnail was zero-byte and had to be removed
151 - return new MediaTransformError( 'thumbnail_error',
 151+ return new MediaTransformError( 'thumbnail_error',
152152 $scalerParams['clientWidth'], $scalerParams['clientHeight'] );
153153 } else {
154 - return new ThumbnailImage( $image, $dstUrl, $scalerParams['clientWidth'],
 154+ return new ThumbnailImage( $image, $dstUrl, $scalerParams['clientWidth'],
155155 $scalerParams['clientHeight'], $dstPath );
156156 }
157157 }
158 -
 158+
159159 /**
160160 * Get a ThumbnailImage that respresents an image that will be scaled
161161 * client side
162 - *
 162+ *
163163 * @param $image File File associated with this thumbnail
164164 * @param $params array Array with scaler params
165165 * @return ThumbnailImage
166166 */
167167 protected function getClientScalingThumbnailImage( $image, $params ) {
168 - return new ThumbnailImage( $image, $image->getURL(),
 168+ return new ThumbnailImage( $image, $image->getURL(),
169169 $params['clientWidth'], $params['clientHeight'], $params['srcPath'] );
170170 }
171171
172172 /**
173173 * Transform an image using ImageMagick
174 - *
 174+ *
175175 * @param $image File File associated with this thumbnail
176176 * @param $params array Array with scaler params
177 - *
 177+ *
178178 * @return MediaTransformError Error object if error occured, false (=no error) otherwise
179179 */
180180 protected function transformImageMagick( $image, $params ) {
181 - # use ImageMagick
182 - global $wgSharpenReductionThreshold, $wgSharpenParameter,
183 - $wgMaxAnimatedGifArea,
184 - $wgImageMagickTempDir, $wgImageMagickConvertCommand;
 181+ # use ImageMagick
 182+ global $wgSharpenReductionThreshold, $wgSharpenParameter,
 183+ $wgMaxAnimatedGifArea,
 184+ $wgImageMagickTempDir, $wgImageMagickConvertCommand;
185185
186 - $quality = '';
187 - $sharpen = '';
188 - $scene = false;
189 - $animation_pre = '';
190 - $animation_post = '';
191 - $decoderHint = '';
192 - if ( $params['mimeType'] == 'image/jpeg' ) {
193 - $quality = "-quality 80"; // 80%
194 - # Sharpening, see bug 6193
195 - if ( ( $params['physicalWidth'] + $params['physicalHeight'] )
196 - / ( $params['srcWidth'] + $params['srcHeight'] )
197 - < $wgSharpenReductionThreshold ) {
198 - $sharpen = "-sharpen " . wfEscapeShellArg( $wgSharpenParameter );
199 - }
200 - // JPEG decoder hint to reduce memory, available since IM 6.5.6-2
201 - $decoderHint = "-define jpeg:size={$params['physicalSize']}";
202 -
203 - } elseif ( $params['mimeType'] == 'image/png' ) {
204 - $quality = "-quality 95"; // zlib 9, adaptive filtering
205 -
206 - } elseif ( $params['mimeType'] == 'image/gif' ) {
207 - if ( $this->getImageArea( $image, $params['srcWidth'],
208 - $params['srcHeight'] ) > $wgMaxAnimatedGifArea ) {
209 - // Extract initial frame only; we're so big it'll
210 - // be a total drag. :P
211 - $scene = 0;
212 -
213 - } elseif( $this->isAnimatedImage( $image ) ) {
214 - // Coalesce is needed to scale animated GIFs properly (bug 1017).
215 - $animation_pre = '-coalesce';
216 - // We optimize the output, but -optimize is broken,
217 - // use optimizeTransparency instead (bug 11822)
218 - if( version_compare( $this->getMagickVersion(), "6.3.5" ) >= 0 ) {
219 - $animation_post = '-fuzz 5% -layers optimizeTransparency +map';
220 - }
221 - }
 186+ $quality = '';
 187+ $sharpen = '';
 188+ $scene = false;
 189+ $animation_pre = '';
 190+ $animation_post = '';
 191+ $decoderHint = '';
 192+ if ( $params['mimeType'] == 'image/jpeg' ) {
 193+ $quality = "-quality 80"; // 80%
 194+ # Sharpening, see bug 6193
 195+ if ( ( $params['physicalWidth'] + $params['physicalHeight'] )
 196+ / ( $params['srcWidth'] + $params['srcHeight'] )
 197+ < $wgSharpenReductionThreshold ) {
 198+ $sharpen = "-sharpen " . wfEscapeShellArg( $wgSharpenParameter );
222199 }
 200+ // JPEG decoder hint to reduce memory, available since IM 6.5.6-2
 201+ $decoderHint = "-define jpeg:size={$params['physicalSize']}";
223202
224 - // Use one thread only, to avoid deadlock bugs on OOM
225 - $env = array( 'OMP_NUM_THREADS' => 1 );
226 - if ( strval( $wgImageMagickTempDir ) !== '' ) {
227 - $env['MAGICK_TMPDIR'] = $wgImageMagickTempDir;
 203+ } elseif ( $params['mimeType'] == 'image/png' ) {
 204+ $quality = "-quality 95"; // zlib 9, adaptive filtering
 205+
 206+ } elseif ( $params['mimeType'] == 'image/gif' ) {
 207+ if ( $this->getImageArea( $image, $params['srcWidth'],
 208+ $params['srcHeight'] ) > $wgMaxAnimatedGifArea ) {
 209+ // Extract initial frame only; we're so big it'll
 210+ // be a total drag. :P
 211+ $scene = 0;
 212+
 213+ } elseif ( $this->isAnimatedImage( $image ) ) {
 214+ // Coalesce is needed to scale animated GIFs properly (bug 1017).
 215+ $animation_pre = '-coalesce';
 216+ // We optimize the output, but -optimize is broken,
 217+ // use optimizeTransparency instead (bug 11822)
 218+ if ( version_compare( $this->getMagickVersion(), "6.3.5" ) >= 0 ) {
 219+ $animation_post = '-fuzz 5% -layers optimizeTransparency +map';
 220+ }
228221 }
 222+ }
229223
230 - $cmd =
231 - wfEscapeShellArg( $wgImageMagickConvertCommand ) .
232 - // Specify white background color, will be used for transparent images
233 - // in Internet Explorer/Windows instead of default black.
234 - " {$quality} -background white".
235 - " {$decoderHint} " .
236 - wfEscapeShellArg( $this->escapeMagickInput( $params['srcPath'], $scene ) ) .
237 - " {$animation_pre}" .
238 - // For the -thumbnail option a "!" is needed to force exact size,
239 - // or ImageMagick may decide your ratio is wrong and slice off
240 - // a pixel.
241 - " -thumbnail " . wfEscapeShellArg( "{$params['physicalSize']}!" ) .
242 - // Add the source url as a comment to the thumb.
243 - " -set comment " . wfEscapeShellArg( $this->escapeMagickProperty( $params['comment'] ) ) .
244 - " -depth 8 $sharpen" .
245 - " {$animation_post} " .
246 - wfEscapeShellArg( $this->escapeMagickOutput( $params['dstPath'] ) ) . " 2>&1";
 224+ // Use one thread only, to avoid deadlock bugs on OOM
 225+ $env = array( 'OMP_NUM_THREADS' => 1 );
 226+ if ( strval( $wgImageMagickTempDir ) !== '' ) {
 227+ $env['MAGICK_TMPDIR'] = $wgImageMagickTempDir;
 228+ }
247229
248 - wfDebug( __METHOD__.": running ImageMagick: $cmd\n" );
249 - wfProfileIn( 'convert' );
250 - $retval = 0;
251 - $err = wfShellExec( $cmd, $retval, $env );
252 - wfProfileOut( 'convert' );
253 -
254 - if ( $retval !== 0 ) {
255 - $this->logErrorForExternalProcess( $retval, $err, $cmd );
256 - return $this->getMediaTransformError( $params, $err );
257 - }
258 -
259 - return false; # No error
 230+ $cmd =
 231+ wfEscapeShellArg( $wgImageMagickConvertCommand ) .
 232+ // Specify white background color, will be used for transparent images
 233+ // in Internet Explorer/Windows instead of default black.
 234+ " {$quality} -background white" .
 235+ " {$decoderHint} " .
 236+ wfEscapeShellArg( $this->escapeMagickInput( $params['srcPath'], $scene ) ) .
 237+ " {$animation_pre}" .
 238+ // For the -thumbnail option a "!" is needed to force exact size,
 239+ // or ImageMagick may decide your ratio is wrong and slice off
 240+ // a pixel.
 241+ " -thumbnail " . wfEscapeShellArg( "{$params['physicalSize']}!" ) .
 242+ // Add the source url as a comment to the thumb.
 243+ " -set comment " . wfEscapeShellArg( $this->escapeMagickProperty( $params['comment'] ) ) .
 244+ " -depth 8 $sharpen" .
 245+ " {$animation_post} " .
 246+ wfEscapeShellArg( $this->escapeMagickOutput( $params['dstPath'] ) ) . " 2>&1";
 247+
 248+ wfDebug( __METHOD__ . ": running ImageMagick: $cmd\n" );
 249+ wfProfileIn( 'convert' );
 250+ $retval = 0;
 251+ $err = wfShellExec( $cmd, $retval, $env );
 252+ wfProfileOut( 'convert' );
 253+
 254+ if ( $retval !== 0 ) {
 255+ $this->logErrorForExternalProcess( $retval, $err, $cmd );
 256+ return $this->getMediaTransformError( $params, $err );
 257+ }
 258+
 259+ return false; # No error
260260 }
261 -
 261+
262262 /**
263263 * Transform an image using a custom command
264 - *
 264+ *
265265 * @param $image File File associated with this thumbnail
266266 * @param $params array Array with scaler params
267 - *
 267+ *
268268 * @return MediaTransformError Error object if error occured, false (=no error) otherwise
269269 */
270270 protected function transformCustom( $image, $params ) {
271 - # Use a custom convert command
272 - global $wgCustomConvertCommand;
273 -
274 - # Variables: %s %d %w %h
275 - $src = wfEscapeShellArg( $params['srcPath'] );
276 - $dst = wfEscapeShellArg( $params['dstPath'] );
277 - $cmd = $wgCustomConvertCommand;
278 - $cmd = str_replace( '%s', $src, str_replace( '%d', $dst, $cmd ) ); # Filenames
279 - $cmd = str_replace( '%h', $params['physicalHeight'],
280 - str_replace( '%w', $params['physicalWidth'], $cmd ) ); # Size
281 - wfDebug( __METHOD__.": Running custom convert command $cmd\n" );
282 - wfProfileIn( 'convert' );
283 - $retval = 0;
284 - $err = wfShellExec( $cmd, $retval );
285 - wfProfileOut( 'convert' );
286 -
287 - if ( $retval !== 0 ) {
288 - $this->logErrorForExternalProcess( $retval, $err, $cmd );
289 - return $this->getMediaTransformError( $params, $err );
290 - }
291 - return false; # No error
 271+ # Use a custom convert command
 272+ global $wgCustomConvertCommand;
 273+
 274+ # Variables: %s %d %w %h
 275+ $src = wfEscapeShellArg( $params['srcPath'] );
 276+ $dst = wfEscapeShellArg( $params['dstPath'] );
 277+ $cmd = $wgCustomConvertCommand;
 278+ $cmd = str_replace( '%s', $src, str_replace( '%d', $dst, $cmd ) ); # Filenames
 279+ $cmd = str_replace( '%h', $params['physicalHeight'],
 280+ str_replace( '%w', $params['physicalWidth'], $cmd ) ); # Size
 281+ wfDebug( __METHOD__ . ": Running custom convert command $cmd\n" );
 282+ wfProfileIn( 'convert' );
 283+ $retval = 0;
 284+ $err = wfShellExec( $cmd, $retval );
 285+ wfProfileOut( 'convert' );
 286+
 287+ if ( $retval !== 0 ) {
 288+ $this->logErrorForExternalProcess( $retval, $err, $cmd );
 289+ return $this->getMediaTransformError( $params, $err );
 290+ }
 291+ return false; # No error
292292 }
293 -
 293+
294294 /**
295295 * Log an error that occured in an external process
296 - *
 296+ *
297297 * @param $retval int
298298 * @param $err int
299299 * @param $cmd string
@@ -303,87 +303,87 @@
304304 wfHostname(), $retval, trim( $err ), $cmd ) );
305305 }
306306 /**
307 - *
 307+ *
308308 */
309309 protected function getMediaTransformError( $params, $errMsg ) {
310 - return new MediaTransformError( 'thumbnail_error', $params['clientWidth'],
 310+ return new MediaTransformError( 'thumbnail_error', $params['clientWidth'],
311311 $params['clientHeight'], $errMsg );
312312 }
313 -
 313+
314314 /**
315315 * Transform an image using the built in GD library
316 - *
 316+ *
317317 * @param $image File File associated with this thumbnail
318318 * @param $params array Array with scaler params
319 - *
 319+ *
320320 * @return MediaTransformError Error object if error occured, false (=no error) otherwise
321321 */
322322 protected function transformGd( $image, $params ) {
323 - # Use PHP's builtin GD library functions.
324 - #
325 - # First find out what kind of file this is, and select the correct
326 - # input routine for this.
 323+ # Use PHP's builtin GD library functions.
 324+ #
 325+ # First find out what kind of file this is, and select the correct
 326+ # input routine for this.
327327
328 - $typemap = array(
329 - 'image/gif' => array( 'imagecreatefromgif', 'palette', 'imagegif' ),
330 - 'image/jpeg' => array( 'imagecreatefromjpeg', 'truecolor', array( __CLASS__, 'imageJpegWrapper' ) ),
331 - 'image/png' => array( 'imagecreatefrompng', 'bits', 'imagepng' ),
332 - 'image/vnd.wap.wbmp' => array( 'imagecreatefromwbmp', 'palette', 'imagewbmp' ),
333 - 'image/xbm' => array( 'imagecreatefromxbm', 'palette', 'imagexbm' ),
334 - );
335 - if( !isset( $typemap[$params['mimeType']] ) ) {
336 - $err = 'Image type not supported';
337 - wfDebug( "$err\n" );
338 - $errMsg = wfMsg ( 'thumbnail_image-type' );
339 - return $this->getMediaTransformError( $params, $errMsg );
340 - }
341 - list( $loader, $colorStyle, $saveType ) = $typemap[$params['mimeType']];
 328+ $typemap = array(
 329+ 'image/gif' => array( 'imagecreatefromgif', 'palette', 'imagegif' ),
 330+ 'image/jpeg' => array( 'imagecreatefromjpeg', 'truecolor', array( __CLASS__, 'imageJpegWrapper' ) ),
 331+ 'image/png' => array( 'imagecreatefrompng', 'bits', 'imagepng' ),
 332+ 'image/vnd.wap.wbmp' => array( 'imagecreatefromwbmp', 'palette', 'imagewbmp' ),
 333+ 'image/xbm' => array( 'imagecreatefromxbm', 'palette', 'imagexbm' ),
 334+ );
 335+ if ( !isset( $typemap[$params['mimeType']] ) ) {
 336+ $err = 'Image type not supported';
 337+ wfDebug( "$err\n" );
 338+ $errMsg = wfMsg ( 'thumbnail_image-type' );
 339+ return $this->getMediaTransformError( $params, $errMsg );
 340+ }
 341+ list( $loader, $colorStyle, $saveType ) = $typemap[$params['mimeType']];
342342
343 - if( !function_exists( $loader ) ) {
344 - $err = "Incomplete GD library configuration: missing function $loader";
345 - wfDebug( "$err\n" );
346 - $errMsg = wfMsg ( 'thumbnail_gd-library', $loader );
347 - return $this->getMediaTransformError( $params, $errMsg );
348 - }
 343+ if ( !function_exists( $loader ) ) {
 344+ $err = "Incomplete GD library configuration: missing function $loader";
 345+ wfDebug( "$err\n" );
 346+ $errMsg = wfMsg ( 'thumbnail_gd-library', $loader );
 347+ return $this->getMediaTransformError( $params, $errMsg );
 348+ }
349349
350 - if ( !file_exists( $params['srcPath'] ) ) {
351 - $err = "File seems to be missing: {$params['srcPath']}";
352 - wfDebug( "$err\n" );
353 - $errMsg = wfMsg ( 'thumbnail_image-missing', $params['srcPath'] );
354 - return $this->getMediaTransformError( $params, $errMsg );
355 - }
 350+ if ( !file_exists( $params['srcPath'] ) ) {
 351+ $err = "File seems to be missing: {$params['srcPath']}";
 352+ wfDebug( "$err\n" );
 353+ $errMsg = wfMsg ( 'thumbnail_image-missing', $params['srcPath'] );
 354+ return $this->getMediaTransformError( $params, $errMsg );
 355+ }
356356
357 - $src_image = call_user_func( $loader, $params['srcPath'] );
358 - $dst_image = imagecreatetruecolor( $params['physicalWidth'],
359 - $params['physicalHeight'] );
 357+ $src_image = call_user_func( $loader, $params['srcPath'] );
 358+ $dst_image = imagecreatetruecolor( $params['physicalWidth'],
 359+ $params['physicalHeight'] );
360360
361 - // Initialise the destination image to transparent instead of
362 - // the default solid black, to support PNG and GIF transparency nicely
363 - $background = imagecolorallocate( $dst_image, 0, 0, 0 );
364 - imagecolortransparent( $dst_image, $background );
365 - imagealphablending( $dst_image, false );
 361+ // Initialise the destination image to transparent instead of
 362+ // the default solid black, to support PNG and GIF transparency nicely
 363+ $background = imagecolorallocate( $dst_image, 0, 0, 0 );
 364+ imagecolortransparent( $dst_image, $background );
 365+ imagealphablending( $dst_image, false );
366366
367 - if ( $colorStyle == 'palette' ) {
368 - // Don't resample for paletted GIF images.
369 - // It may just uglify them, and completely breaks transparency.
370 - imagecopyresized( $dst_image, $src_image,
371 - 0,0,0,0,
372 - $params['physicalWidth'], $params['physicalHeight'],
373 - imagesx( $src_image ), imagesy( $src_image ) );
374 - } else {
375 - imagecopyresampled( $dst_image, $src_image,
376 - 0,0,0,0,
377 - $params['physicalWidth'], $params['physicalHeight'],
378 - imagesx( $src_image ), imagesy( $src_image ) );
379 - }
 367+ if ( $colorStyle == 'palette' ) {
 368+ // Don't resample for paletted GIF images.
 369+ // It may just uglify them, and completely breaks transparency.
 370+ imagecopyresized( $dst_image, $src_image,
 371+ 0, 0, 0, 0,
 372+ $params['physicalWidth'], $params['physicalHeight'],
 373+ imagesx( $src_image ), imagesy( $src_image ) );
 374+ } else {
 375+ imagecopyresampled( $dst_image, $src_image,
 376+ 0, 0, 0, 0,
 377+ $params['physicalWidth'], $params['physicalHeight'],
 378+ imagesx( $src_image ), imagesy( $src_image ) );
 379+ }
380380
381 - imagesavealpha( $dst_image, true );
 381+ imagesavealpha( $dst_image, true );
382382
383 - call_user_func( $saveType, $dst_image, $params['dstPath'] );
384 - imagedestroy( $dst_image );
385 - imagedestroy( $src_image );
386 -
387 - return false; # No error
 383+ call_user_func( $saveType, $dst_image, $params['dstPath'] );
 384+ imagedestroy( $dst_image );
 385+ imagedestroy( $src_image );
 386+
 387+ return false; # No error
388388 }
389389
390390 /**
@@ -403,14 +403,14 @@
404404 }
405405
406406 /**
407 - * Escape a string for ImageMagick's input filenames. See ExpandFilenames()
 407+ * Escape a string for ImageMagick's input filenames. See ExpandFilenames()
408408 * and GetPathComponent() in magick/utility.c.
409409 *
410410 * This won't work with an initial ~ or @, so input files should be prefixed
411 - * with the directory name.
 411+ * with the directory name.
412412 *
413413 * Glob character unescaping is broken in ImageMagick before 6.6.1-5, but
414 - * it's broken in a way that doesn't involve trying to convert every file
 414+ * it's broken in a way that doesn't involve trying to convert every file
415415 * in a directory, so we're better off escaping and waiting for the bugfix
416416 * to filter down to users.
417417 *
@@ -421,7 +421,7 @@
422422 # Die on initial metacharacters (caller should prepend path)
423423 $firstChar = substr( $path, 0, 1 );
424424 if ( $firstChar === '~' || $firstChar === '@' ) {
425 - throw new MWException( __METHOD__.': cannot escape this path name' );
 425+ throw new MWException( __METHOD__ . ': cannot escape this path name' );
426426 }
427427
428428 # Escape glob chars
@@ -431,7 +431,7 @@
432432 }
433433
434434 /**
435 - * Escape a string for ImageMagick's output filename. See
 435+ * Escape a string for ImageMagick's output filename. See
436436 * InterpretImageFilename() in magick/image.c.
437437 */
438438 function escapeMagickOutput( $path, $scene = false ) {
@@ -440,7 +440,7 @@
441441 }
442442
443443 /**
444 - * Armour a string against ImageMagick's GetPathComponent(). This is a
 444+ * Armour a string against ImageMagick's GetPathComponent(). This is a
445445 * helper function for escapeMagickInput() and escapeMagickOutput().
446446 *
447447 * @param $path string The file path
@@ -454,11 +454,11 @@
455455 // OK, it's a drive letter
456456 // ImageMagick has a similar exception, see IsMagickConflict()
457457 } else {
458 - throw new MWException( __METHOD__.': unexpected colon character in path name' );
 458+ throw new MWException( __METHOD__ . ': unexpected colon character in path name' );
459459 }
460460 }
461461
462 - # If there are square brackets, add a do-nothing scene specification
 462+ # If there are square brackets, add a do-nothing scene specification
463463 # to force a literal interpretation
464464 if ( $scene === false ) {
465465 if ( strpos( $path, '[' ) !== false ) {
@@ -480,15 +480,15 @@
481481 global $wgMemc;
482482
483483 $cache = $wgMemc->get( "imagemagick-version" );
484 - if( !$cache ) {
 484+ if ( !$cache ) {
485485 global $wgImageMagickConvertCommand;
486486 $cmd = wfEscapeShellArg( $wgImageMagickConvertCommand ) . ' -version';
487 - wfDebug( __METHOD__.": Running convert -version\n" );
 487+ wfDebug( __METHOD__ . ": Running convert -version\n" );
488488 $retval = '';
489489 $return = wfShellExec( $cmd, $retval );
490 - $x = preg_match('/Version: ImageMagick ([0-9]*\.[0-9]*\.[0-9]*)/', $return, $matches);
491 - if( $x != 1 ) {
492 - wfDebug( __METHOD__.": ImageMagick version check failed\n" );
 490+ $x = preg_match( '/Version: ImageMagick ([0-9]*\.[0-9]*\.[0-9]*)/', $return, $matches );
 491+ if ( $x != 1 ) {
 492+ wfDebug( __METHOD__ . ": ImageMagick version check failed\n" );
493493 return null;
494494 }
495495 $wgMemc->set( "imagemagick-version", $matches[1], 3600 );
@@ -505,7 +505,7 @@
506506
507507 function getMetadata( $image, $filename ) {
508508 global $wgShowEXIF;
509 - if( $wgShowEXIF && file_exists( $filename ) ) {
 509+ if ( $wgShowEXIF && file_exists( $filename ) ) {
510510 $exif = new Exif( $filename );
511511 $data = $exif->getFilteredData();
512512 if ( $data ) {
@@ -540,7 +540,7 @@
541541 $exif['MEDIAWIKI_EXIF_VERSION'] != Exif::version() )
542542 {
543543 # Wrong version
544 - wfDebug( __METHOD__.": wrong version\n" );
 544+ wfDebug( __METHOD__ . ": wrong version\n" );
545545 return false;
546546 }
547547 return true;
@@ -556,9 +556,9 @@
557557 function visibleMetadataFields() {
558558 $fields = array();
559559 $lines = explode( "\n", wfMsgForContent( 'metadata-fields' ) );
560 - foreach( $lines as $line ) {
 560+ foreach ( $lines as $line ) {
561561 $matches = array();
562 - if( preg_match( '/^\\*\s*(.*?)\s*$/', $line, $matches ) ) {
 562+ if ( preg_match( '/^\\*\s*(.*?)\s*$/', $line, $matches ) ) {
563563 $fields[] = $matches[1];
564564 }
565565 }

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r75702Split BitmapHandler::doTransform in functions: transformImageMagick(), transf...btongminh19:04, 30 October 2010

Status & tagging log