r79662 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r79661‎ | r79662 | r79663 >
Date:20:09, 5 January 2011
Author:ashley
Status:deferred
Tags:
Comment:
SocialProfile: bug #26588 - image converting code should use $wgImageMagickConvertCommand instead of hardcoded "convert"
Modified paths:
  • /trunk/extensions/SocialProfile/SystemGifts/SpecialSystemGiftManagerLogo.php (modified) (history)
  • /trunk/extensions/SocialProfile/UserGifts/SpecialGiftManagerLogo.php (modified) (history)
  • /trunk/extensions/SocialProfile/UserProfile/SpecialUploadAvatar.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SocialProfile/UserProfile/SpecialUploadAvatar.php
@@ -235,6 +235,8 @@
236236 public $mExtension;
237237
238238 function createThumbnail( $imageSrc, $imageInfo, $imgDest, $thumbWidth ) {
 239+ global $wgImageMagickConvertCommand;
 240+
239241 list( $origWidth, $origHeight, $typeCode ) = $imageInfo;
240242
241243 if ( $origWidth < $thumbWidth ) {
@@ -246,13 +248,28 @@
247249 $border = ' -bordercolor white -border 0x' . ( ( $thumbWidth - $thumbHeight ) / 2 );
248250 }
249251 if ( $typeCode == 2 ) {
250 - exec( 'convert -size ' . $thumbWidth . 'x' . $thumbWidth . ' -resize ' . $thumbWidth . ' -crop ' . $thumbWidth . 'x' . $thumbWidth . '+0+0 -quality 100 ' . $border . ' ' . $imageSrc . ' ' . $this->avatarUploadDirectory . '/' . $imgDest . '.jpg' );
 252+ exec(
 253+ $wgImageMagickConvertCommand . ' -size ' . $thumbWidth . 'x' . $thumbWidth .
 254+ ' -resize ' . $thumbWidth . ' -crop ' . $thumbWidth . 'x' .
 255+ $thumbWidth . '+0+0 -quality 100 ' . $border . ' ' .
 256+ $imageSrc . ' ' . $this->avatarUploadDirectory . '/' . $imgDest . '.jpg'
 257+ );
251258 }
252259 if ( $typeCode == 1 ) {
253 - exec( 'convert -size ' . $thumbWidth . 'x' . $thumbWidth . ' -resize ' . $thumbWidth . ' -crop ' . $thumbWidth . 'x' . $thumbWidth . '+0+0 ' . $imageSrc . ' ' . $border . ' ' . $this->avatarUploadDirectory . '/' . $imgDest . '.gif' );
 260+ exec(
 261+ $wgImageMagickConvertCommand . ' -size ' . $thumbWidth . 'x' . $thumbWidth .
 262+ ' -resize ' . $thumbWidth . ' -crop ' . $thumbWidth . 'x' .
 263+ $thumbWidth . '+0+0 ' . $imageSrc . ' ' . $border . ' ' .
 264+ $this->avatarUploadDirectory . '/' . $imgDest . '.gif'
 265+ );
254266 }
255267 if ( $typeCode == 3 ) {
256 - exec( 'convert -size ' . $thumbWidth . 'x' . $thumbWidth . ' -resize ' . $thumbWidth . ' -crop ' . $thumbWidth . 'x' . $thumbWidth . '+0+0 ' . $imageSrc . ' ' . $this->avatarUploadDirectory . '/' . $imgDest . '.png' );
 268+ exec(
 269+ $wgImageMagickConvertCommand . ' -size ' . $thumbWidth . 'x' . $thumbWidth .
 270+ ' -resize ' . $thumbWidth . ' -crop ' . $thumbWidth . 'x' .
 271+ $thumbWidth . '+0+0 ' . $imageSrc . ' ' .
 272+ $this->avatarUploadDirectory . '/' . $imgDest . '.png'
 273+ );
257274 }
258275 }
259276
Index: trunk/extensions/SocialProfile/SystemGifts/SpecialSystemGiftManagerLogo.php
@@ -231,6 +231,8 @@
232232 }
233233
234234 function createThumbnail( $imageSrc, $ext, $imgDest, $thumbWidth ) {
 235+ global $wgImageMagickConvertCommand;
 236+
235237 list( $origWidth, $origHeight, $typeCode ) = getimagesize( $imageSrc );
236238
237239 if ( $origWidth < $thumbWidth ) {
@@ -238,16 +240,29 @@
239241 }
240242 $thumbHeight = ( $thumbWidth * $origHeight / $origWidth );
241243 if ( $thumbHeight < $thumbWidth ) {
242 - $border = " -bordercolor white -border 0x" . ( ( $thumbWidth - $thumbHeight ) / 2 );
 244+ $border = ' -bordercolor white -border 0x' . ( ( $thumbWidth - $thumbHeight ) / 2 );
243245 }
244246 if ( $typeCode == 2 ) {
245 - exec( 'convert -size ' . $thumbWidth . 'x' . $thumbWidth . ' -resize ' . $thumbWidth . ' -quality 100 ' . $border . ' ' . $imageSrc . ' ' . $this->avatarUploadDirectory . '/sg_' . $imgDest . '.jpg' );
 247+ exec(
 248+ $wgImageMagickConvertCommand . ' -size ' . $thumbWidth . 'x' .
 249+ $thumbWidth . ' -resize ' . $thumbWidth . ' -quality 100 ' .
 250+ $border . ' ' . $imageSrc . ' ' .
 251+ $this->avatarUploadDirectory . '/sg_' . $imgDest . '.jpg'
 252+ );
246253 }
247254 if ( $typeCode == 1 ) {
248 - exec( 'convert -size ' . $thumbWidth . 'x' . $thumbWidth . ' -resize ' . $thumbWidth . ' ' . $imageSrc . ' ' . $border . ' ' . $this->avatarUploadDirectory . '/sg_' . $imgDest . '.gif' );
 255+ exec(
 256+ $wgImageMagickConvertCommand . ' -size ' . $thumbWidth . 'x' .
 257+ $thumbWidth . ' -resize ' . $thumbWidth . ' ' . $imageSrc .
 258+ ' ' . $border . ' ' . $this->avatarUploadDirectory . '/sg_' . $imgDest . '.gif'
 259+ );
249260 }
250261 if ( $typeCode == 3 ) {
251 - exec( 'convert -size ' . $thumbWidth . 'x' . $thumbWidth . ' -resize ' . $thumbWidth . ' ' . $imageSrc . ' ' . $this->avatarUploadDirectory . '/sg_' . $imgDest . '.png' );
 262+ exec(
 263+ $wgImageMagickConvertCommand . ' -size ' . $thumbWidth . 'x' .
 264+ $thumbWidth . ' -resize ' . $thumbWidth . ' ' . $imageSrc .
 265+ ' ' . $this->avatarUploadDirectory . '/sg_' . $imgDest . '.png'
 266+ );
252267 }
253268 }
254269
Index: trunk/extensions/SocialProfile/UserGifts/SpecialGiftManagerLogo.php
@@ -238,6 +238,8 @@
239239 }
240240
241241 function createThumbnail( $imageSrc, $ext, $imgDest, $thumbWidth ) {
 242+ global $wgImageMagickConvertCommand;
 243+
242244 list( $origWidth, $origHeight, $typeCode ) = getimagesize( $imageSrc );
243245
244246 if ( $origWidth < $thumbWidth ) {
@@ -248,13 +250,27 @@
249251 $border = ' -bordercolor white -border 0x' . ( ( $thumbWidth - $thumbHeight ) / 2 );
250252 }
251253 if ( $typeCode == 2 ) {
252 - exec( 'convert -size ' . $thumbWidth . 'x' . $thumbWidth . ' -resize ' . $thumbWidth . ' -quality 100 ' . $border . ' ' . $imageSrc . ' ' . $this->avatarUploadDirectory . '/' . $imgDest . '.jpg' );
 254+ exec(
 255+ $wgImageMagickConvertCommand . ' -size ' . $thumbWidth . 'x' .
 256+ $thumbWidth . ' -resize ' . $thumbWidth . ' -quality 100 ' .
 257+ $border . ' ' . $imageSrc . ' ' .
 258+ $this->avatarUploadDirectory . '/' . $imgDest . '.jpg'
 259+ );
253260 }
254261 if ( $typeCode == 1 ) {
255 - exec( 'convert -size ' . $thumbWidth . 'x' . $thumbWidth . ' -resize ' . $thumbWidth . ' ' . $imageSrc . ' ' . $border . ' ' . $this->avatarUploadDirectory . '/' . $imgDest . '.gif' );
 262+ exec(
 263+ $wgImageMagickConvertCommand . ' -size ' . $thumbWidth . 'x' .
 264+ $thumbWidth . ' -resize ' . $thumbWidth . ' ' . $imageSrc .
 265+ ' ' . $border . ' ' .
 266+ $this->avatarUploadDirectory . '/' . $imgDest . '.gif'
 267+ );
256268 }
257269 if ( $typeCode == 3 ) {
258 - exec( 'convert -size ' . $thumbWidth . 'x' . $thumbWidth . ' -resize ' . $thumbWidth . ' ' . $imageSrc . ' ' . $this->avatarUploadDirectory . '/' . $imgDest . ".png" );
 270+ exec(
 271+ $wgImageMagickConvertCommand . ' -size ' . $thumbWidth . 'x' .
 272+ $thumbWidth . ' -resize ' . $thumbWidth . ' ' . $imageSrc .
 273+ ' ' . $this->avatarUploadDirectory . '/' . $imgDest . '.png'
 274+ );
259275 }
260276 }
261277

Status & tagging log