| Index: trunk/extensions/SocialProfile/SystemGifts/SpecialSystemGiftManagerLogo.php |
| — | — | @@ -203,7 +203,7 @@ |
| 204 | 204 | |
| 205 | 205 | global $wgCheckFileExtensions; |
| 206 | 206 | if ( $wgCheckFileExtensions ) { |
| 207 | | - if ( ! $this->checkFileExtension( $finalExt, $this->fileExtensions ) ) { |
| | 207 | + if ( !$this->checkFileExtension( $finalExt, $this->fileExtensions ) ) { |
| 208 | 208 | $warning .= '<li>' . wfMsg( 'badfiletype', htmlspecialchars( $fullExt ) ) . '</li>'; |
| 209 | 209 | } |
| 210 | 210 | } |
| — | — | @@ -230,7 +230,11 @@ |
| 231 | 231 | * Try actually saving the thing... |
| 232 | 232 | * It will show an error form on failure. |
| 233 | 233 | */ |
| 234 | | - $status = $this->saveUploadedFile( $this->mUploadSaveName, $this->mUploadTempName, strtoupper( $fullExt ) ); |
| | 234 | + $status = $this->saveUploadedFile( |
| | 235 | + $this->mUploadSaveName, |
| | 236 | + $this->mUploadTempName, |
| | 237 | + strtoupper( $fullExt ) |
| | 238 | + ); |
| 235 | 239 | |
| 236 | 240 | if ( $status > 0 ) { |
| 237 | 241 | $this->showSuccess( $status ); |
| — | — | @@ -238,37 +242,94 @@ |
| 239 | 243 | } |
| 240 | 244 | |
| 241 | 245 | function createThumbnail( $imageSrc, $ext, $imgDest, $thumbWidth ) { |
| 242 | | - global $wgImageMagickConvertCommand; |
| | 246 | + global $wgUseImageMagick, $wgImageMagickConvertCommand; |
| 243 | 247 | |
| 244 | 248 | list( $origWidth, $origHeight, $typeCode ) = getimagesize( $imageSrc ); |
| 245 | 249 | |
| 246 | | - if ( $origWidth < $thumbWidth ) { |
| 247 | | - $thumbWidth = $origWidth; |
| 248 | | - } |
| 249 | | - $thumbHeight = ( $thumbWidth * $origHeight / $origWidth ); |
| 250 | | - if ( $thumbHeight < $thumbWidth ) { |
| 251 | | - $border = ' -bordercolor white -border 0x' . ( ( $thumbWidth - $thumbHeight ) / 2 ); |
| 252 | | - } |
| 253 | | - if ( $typeCode == 2 ) { |
| 254 | | - exec( |
| 255 | | - $wgImageMagickConvertCommand . ' -size ' . $thumbWidth . 'x' . |
| 256 | | - $thumbWidth . ' -resize ' . $thumbWidth . ' -quality 100 ' . |
| 257 | | - $border . ' ' . $imageSrc . ' ' . |
| 258 | | - $this->avatarUploadDirectory . '/sg_' . $imgDest . '.jpg' |
| | 250 | + if ( $wgUseImageMagick ) { // ImageMagick is enabled |
| | 251 | + if ( $origWidth < $thumbWidth ) { |
| | 252 | + $thumbWidth = $origWidth; |
| | 253 | + } |
| | 254 | + $thumbHeight = ( $thumbWidth * $origHeight / $origWidth ); |
| | 255 | + if ( $thumbHeight < $thumbWidth ) { |
| | 256 | + $border = ' -bordercolor white -border 0x' . ( ( $thumbWidth - $thumbHeight ) / 2 ); |
| | 257 | + } |
| | 258 | + if ( $typeCode == 2 ) { |
| | 259 | + exec( |
| | 260 | + $wgImageMagickConvertCommand . ' -size ' . $thumbWidth . 'x' . |
| | 261 | + $thumbWidth . ' -resize ' . $thumbWidth . ' -quality 100 ' . |
| | 262 | + $border . ' ' . $imageSrc . ' ' . |
| | 263 | + $this->avatarUploadDirectory . '/sg_' . $imgDest . '.jpg' |
| | 264 | + ); |
| | 265 | + } |
| | 266 | + if ( $typeCode == 1 ) { |
| | 267 | + exec( |
| | 268 | + $wgImageMagickConvertCommand . ' -size ' . $thumbWidth . 'x' . |
| | 269 | + $thumbWidth . ' -resize ' . $thumbWidth . ' ' . $imageSrc . |
| | 270 | + ' ' . $border . ' ' . |
| | 271 | + $this->avatarUploadDirectory . '/sg_' . $imgDest . '.gif' |
| | 272 | + ); |
| | 273 | + } |
| | 274 | + if ( $typeCode == 3 ) { |
| | 275 | + exec( |
| | 276 | + $wgImageMagickConvertCommand . ' -size ' . $thumbWidth . 'x' . |
| | 277 | + $thumbWidth . ' -resize ' . $thumbWidth . ' ' . $imageSrc . |
| | 278 | + ' ' . $this->avatarUploadDirectory . '/sg_' . $imgDest . '.png' |
| | 279 | + ); |
| | 280 | + } |
| | 281 | + } else { // ImageMagick is not enabled, so fall back to PHP's GD library |
| | 282 | + // Get the image size, used in calculations later. |
| | 283 | + switch( $typeCode ) { |
| | 284 | + case '1': |
| | 285 | + $fullImage = imagecreatefromgif( $imageSrc ); |
| | 286 | + $ext = 'gif'; |
| | 287 | + break; |
| | 288 | + case '2': |
| | 289 | + $fullImage = imagecreatefromjpeg( $imageSrc ); |
| | 290 | + $ext = 'jpg'; |
| | 291 | + break; |
| | 292 | + case '3': |
| | 293 | + $fullImage = imagecreatefrompng( $imageSrc ); |
| | 294 | + $ext = 'png'; |
| | 295 | + break; |
| | 296 | + } |
| | 297 | + |
| | 298 | + $scale = ( $thumbWidth / $origWidth ); |
| | 299 | + |
| | 300 | + // Create our thumbnail size, so we can resize to this, and save it. |
| | 301 | + $tnImage = imagecreatetruecolor( |
| | 302 | + $origWidth * $scale, |
| | 303 | + $origHeight * $scale |
| 259 | 304 | ); |
| 260 | | - } |
| 261 | | - if ( $typeCode == 1 ) { |
| 262 | | - exec( |
| 263 | | - $wgImageMagickConvertCommand . ' -size ' . $thumbWidth . 'x' . |
| 264 | | - $thumbWidth . ' -resize ' . $thumbWidth . ' ' . $imageSrc . |
| 265 | | - ' ' . $border . ' ' . $this->avatarUploadDirectory . '/sg_' . $imgDest . '.gif' |
| | 305 | + |
| | 306 | + // Resize the image. |
| | 307 | + imagecopyresampled( |
| | 308 | + $tnImage, |
| | 309 | + $fullImage, |
| | 310 | + 0, 0, 0, 0, |
| | 311 | + $origWidth * $scale, |
| | 312 | + $origHeight * $scale, |
| | 313 | + $origWidth, |
| | 314 | + $origHeight |
| 266 | 315 | ); |
| 267 | | - } |
| 268 | | - if ( $typeCode == 3 ) { |
| 269 | | - exec( |
| 270 | | - $wgImageMagickConvertCommand . ' -size ' . $thumbWidth . 'x' . |
| 271 | | - $thumbWidth . ' -resize ' . $thumbWidth . ' ' . $imageSrc . |
| 272 | | - ' ' . $this->avatarUploadDirectory . '/sg_' . $imgDest . '.png' |
| | 316 | + |
| | 317 | + // Create a new image thumbnail. |
| | 318 | + if ( $typeCode == 1 ) { |
| | 319 | + imagegif( $tnImage, $imageSrc ); |
| | 320 | + } elseif ( $typeCode == 2 ) { |
| | 321 | + imagejpeg( $tnImage, $imageSrc ); |
| | 322 | + } elseif ( $typeCode == 3 ) { |
| | 323 | + imagepng( $tnImage, $imageSrc ); |
| | 324 | + } |
| | 325 | + |
| | 326 | + // Clean up. |
| | 327 | + imagedestroy( $fullImage ); |
| | 328 | + imagedestroy( $tnImage ); |
| | 329 | + |
| | 330 | + // Copy the thumb |
| | 331 | + copy( |
| | 332 | + $imageSrc, |
| | 333 | + $this->avatarUploadDirectory . '/sg_' . $imgDest . '.' . $ext |
| 273 | 334 | ); |
| 274 | 335 | } |
| 275 | 336 | } |
| Index: trunk/extensions/SocialProfile/UserProfile/SpecialUploadAvatar.php |
| — | — | @@ -235,40 +235,98 @@ |
| 236 | 236 | public $mExtension; |
| 237 | 237 | |
| 238 | 238 | function createThumbnail( $imageSrc, $imageInfo, $imgDest, $thumbWidth ) { |
| 239 | | - global $wgImageMagickConvertCommand; |
| | 239 | + global $wgUseImageMagick, $wgImageMagickConvertCommand; |
| 240 | 240 | |
| 241 | | - list( $origWidth, $origHeight, $typeCode ) = $imageInfo; |
| | 241 | + if ( $wgUseImageMagick ) { // ImageMagick is enabled |
| | 242 | + list( $origWidth, $origHeight, $typeCode ) = $imageInfo; |
| 242 | 243 | |
| 243 | | - if ( $origWidth < $thumbWidth ) { |
| 244 | | - $thumbWidth = $origWidth; |
| 245 | | - } |
| 246 | | - $thumbHeight = ( $thumbWidth * $origHeight / $origWidth ); |
| 247 | | - $border = ' -bordercolor white -border 0x'; |
| 248 | | - if ( $thumbHeight < $thumbWidth ) { |
| 249 | | - $border = ' -bordercolor white -border 0x' . ( ( $thumbWidth - $thumbHeight ) / 2 ); |
| 250 | | - } |
| 251 | | - if ( $typeCode == 2 ) { |
| 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' |
| | 244 | + if ( $origWidth < $thumbWidth ) { |
| | 245 | + $thumbWidth = $origWidth; |
| | 246 | + } |
| | 247 | + $thumbHeight = ( $thumbWidth * $origHeight / $origWidth ); |
| | 248 | + $border = ' -bordercolor white -border 0x'; |
| | 249 | + if ( $thumbHeight < $thumbWidth ) { |
| | 250 | + $border = ' -bordercolor white -border 0x' . ( ( $thumbWidth - $thumbHeight ) / 2 ); |
| | 251 | + } |
| | 252 | + if ( $typeCode == 2 ) { |
| | 253 | + exec( |
| | 254 | + $wgImageMagickConvertCommand . ' -size ' . $thumbWidth . 'x' . $thumbWidth . |
| | 255 | + ' -resize ' . $thumbWidth . ' -crop ' . $thumbWidth . 'x' . |
| | 256 | + $thumbWidth . '+0+0 -quality 100 ' . $border . ' ' . |
| | 257 | + $imageSrc . ' ' . $this->avatarUploadDirectory . '/' . $imgDest . '.jpg' |
| | 258 | + ); |
| | 259 | + } |
| | 260 | + if ( $typeCode == 1 ) { |
| | 261 | + exec( |
| | 262 | + $wgImageMagickConvertCommand . ' -size ' . $thumbWidth . 'x' . $thumbWidth . |
| | 263 | + ' -resize ' . $thumbWidth . ' -crop ' . $thumbWidth . 'x' . |
| | 264 | + $thumbWidth . '+0+0 ' . $imageSrc . ' ' . $border . ' ' . |
| | 265 | + $this->avatarUploadDirectory . '/' . $imgDest . '.gif' |
| | 266 | + ); |
| | 267 | + } |
| | 268 | + if ( $typeCode == 3 ) { |
| | 269 | + exec( |
| | 270 | + $wgImageMagickConvertCommand . ' -size ' . $thumbWidth . 'x' . $thumbWidth . |
| | 271 | + ' -resize ' . $thumbWidth . ' -crop ' . $thumbWidth . 'x' . |
| | 272 | + $thumbWidth . '+0+0 ' . $imageSrc . ' ' . |
| | 273 | + $this->avatarUploadDirectory . '/' . $imgDest . '.png' |
| | 274 | + ); |
| | 275 | + } |
| | 276 | + } else { // ImageMagick is not enabled, so fall back to PHP's GD library |
| | 277 | + // Get the image size, used in calculations later. |
| | 278 | + list( $origWidth, $origHeight, $typeCode ) = getimagesize( $imageSrc ); |
| | 279 | + |
| | 280 | + switch( $typeCode ) { |
| | 281 | + case '1': |
| | 282 | + $fullImage = imagecreatefromgif( $imageSrc ); |
| | 283 | + $ext = 'gif'; |
| | 284 | + break; |
| | 285 | + case '2': |
| | 286 | + $fullImage = imagecreatefromjpeg( $imageSrc ); |
| | 287 | + $ext = 'jpg'; |
| | 288 | + break; |
| | 289 | + case '3': |
| | 290 | + $fullImage = imagecreatefrompng( $imageSrc ); |
| | 291 | + $ext = 'png'; |
| | 292 | + break; |
| | 293 | + } |
| | 294 | + |
| | 295 | + $scale = ( $thumbWidth / $origWidth ); |
| | 296 | + |
| | 297 | + // Create our thumbnail size, so we can resize to this, and save it. |
| | 298 | + $tnImage = imagecreatetruecolor( |
| | 299 | + $origWidth * $scale, |
| | 300 | + $origHeight * $scale |
| 257 | 301 | ); |
| 258 | | - } |
| 259 | | - if ( $typeCode == 1 ) { |
| 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' |
| | 302 | + |
| | 303 | + // Resize the image. |
| | 304 | + imagecopyresampled( |
| | 305 | + $tnImage, |
| | 306 | + $fullImage, |
| | 307 | + 0, 0, 0, 0, |
| | 308 | + $origWidth * $scale, |
| | 309 | + $origHeight * $scale, |
| | 310 | + $origWidth, |
| | 311 | + $origHeight |
| 265 | 312 | ); |
| 266 | | - } |
| 267 | | - if ( $typeCode == 3 ) { |
| 268 | | - exec( |
| 269 | | - $wgImageMagickConvertCommand . ' -size ' . $thumbWidth . 'x' . $thumbWidth . |
| 270 | | - ' -resize ' . $thumbWidth . ' -crop ' . $thumbWidth . 'x' . |
| 271 | | - $thumbWidth . '+0+0 ' . $imageSrc . ' ' . |
| 272 | | - $this->avatarUploadDirectory . '/' . $imgDest . '.png' |
| | 313 | + |
| | 314 | + // Create a new image thumbnail. |
| | 315 | + if ( $typeCode == 1 ) { |
| | 316 | + imagegif( $tnImage, $imageSrc ); |
| | 317 | + } elseif ( $typeCode == 2 ) { |
| | 318 | + imagejpeg( $tnImage, $imageSrc ); |
| | 319 | + } elseif ( $typeCode == 3 ) { |
| | 320 | + imagepng( $tnImage, $imageSrc ); |
| | 321 | + } |
| | 322 | + |
| | 323 | + // Clean up. |
| | 324 | + imagedestroy( $fullImage ); |
| | 325 | + imagedestroy( $tnImage ); |
| | 326 | + |
| | 327 | + // Copy the thumb |
| | 328 | + copy( |
| | 329 | + $imageSrc, |
| | 330 | + $this->avatarUploadDirectory . '/' . $imgDest . '.' . $ext |
| 273 | 331 | ); |
| 274 | 332 | } |
| 275 | 333 | } |
| Index: trunk/extensions/SocialProfile/UserGifts/SpecialGiftManagerLogo.php |
| — | — | @@ -1,5 +1,12 @@ |
| 2 | 2 | <?php |
| 3 | | - |
| | 3 | +/** |
| | 4 | + * A special page to upload images for gifts. |
| | 5 | + * This is mostly copied from an old version of Special:Upload and changed a |
| | 6 | + * bit. |
| | 7 | + * |
| | 8 | + * @file |
| | 9 | + * @ingroup Extensions |
| | 10 | + */ |
| 4 | 11 | class GiftManagerLogo extends UnlistedSpecialPage { |
| 5 | 12 | |
| 6 | 13 | var $mUploadFile, $mUploadDescription, $mIgnoreWarning; |
| — | — | @@ -37,7 +44,11 @@ |
| 38 | 45 | } |
| 39 | 46 | |
| 40 | 47 | $gift = Gifts::getGift( $this->gift_id ); |
| 41 | | - if ( $wgUser->getID() == $gift['creator_user_id'] || in_array( 'giftadmin', $wgUser->getGroups() ) ) { |
| | 48 | + if ( |
| | 49 | + $wgUser->getID() == $gift['creator_user_id'] || |
| | 50 | + in_array( 'giftadmin', $wgUser->getGroups() ) |
| | 51 | + ) |
| | 52 | + { |
| 42 | 53 | return true; |
| 43 | 54 | } |
| 44 | 55 | |
| — | — | @@ -205,13 +216,12 @@ |
| 206 | 217 | |
| 207 | 218 | global $wgUploadSizeWarning; |
| 208 | 219 | if ( $wgUploadSizeWarning && ( $this->mUploadSize > $wgUploadSizeWarning ) ) { |
| 209 | | - |
| 210 | 220 | $skin = $wgUser->getSkin(); |
| 211 | 221 | $wsize = $skin->formatSize( $wgUploadSizeWarning ); |
| 212 | 222 | $asize = $skin->formatSize( $this->mUploadSize ); |
| 213 | 223 | $warning .= '<li>' . wfMsgHtml( 'large-file', $wsize, $asize ) . '</li>'; |
| | 224 | + } |
| 214 | 225 | |
| 215 | | - } |
| 216 | 226 | if ( $this->mUploadSize == 0 ) { |
| 217 | 227 | $warning .= '<li>' . wfMsg( 'emptyfile' ) . '</li>'; |
| 218 | 228 | } |
| — | — | @@ -229,7 +239,11 @@ |
| 230 | 240 | * Try actually saving the thing... |
| 231 | 241 | * It will show an error form on failure. |
| 232 | 242 | */ |
| 233 | | - $status = $this->saveUploadedFile( $this->mUploadSaveName, $this->mUploadTempName, strtoupper( $fullExt ) ); |
| | 243 | + $status = $this->saveUploadedFile( |
| | 244 | + $this->mUploadSaveName, |
| | 245 | + $this->mUploadTempName, |
| | 246 | + strtoupper( $fullExt ) |
| | 247 | + ); |
| 234 | 248 | |
| 235 | 249 | if ( $status > 0 ) { |
| 236 | 250 | $this->showSuccess( $status ); |
| — | — | @@ -237,38 +251,94 @@ |
| 238 | 252 | } |
| 239 | 253 | |
| 240 | 254 | function createThumbnail( $imageSrc, $ext, $imgDest, $thumbWidth ) { |
| 241 | | - global $wgImageMagickConvertCommand; |
| | 255 | + global $wgUseImageMagick, $wgImageMagickConvertCommand; |
| 242 | 256 | |
| 243 | 257 | list( $origWidth, $origHeight, $typeCode ) = getimagesize( $imageSrc ); |
| 244 | 258 | |
| 245 | | - if ( $origWidth < $thumbWidth ) { |
| 246 | | - $thumbWidth = $origWidth; |
| 247 | | - } |
| 248 | | - $thumbHeight = ( $thumbWidth * $origHeight / $origWidth ); |
| 249 | | - if ( $thumbHeight < $thumbWidth ) { |
| 250 | | - $border = ' -bordercolor white -border 0x' . ( ( $thumbWidth - $thumbHeight ) / 2 ); |
| 251 | | - } |
| 252 | | - if ( $typeCode == 2 ) { |
| 253 | | - exec( |
| 254 | | - $wgImageMagickConvertCommand . ' -size ' . $thumbWidth . 'x' . |
| 255 | | - $thumbWidth . ' -resize ' . $thumbWidth . ' -quality 100 ' . |
| 256 | | - $border . ' ' . $imageSrc . ' ' . |
| 257 | | - $this->avatarUploadDirectory . '/' . $imgDest . '.jpg' |
| | 259 | + if ( $wgUseImageMagick ) { // ImageMagick is enabled |
| | 260 | + if ( $origWidth < $thumbWidth ) { |
| | 261 | + $thumbWidth = $origWidth; |
| | 262 | + } |
| | 263 | + $thumbHeight = ( $thumbWidth * $origHeight / $origWidth ); |
| | 264 | + if ( $thumbHeight < $thumbWidth ) { |
| | 265 | + $border = ' -bordercolor white -border 0x' . ( ( $thumbWidth - $thumbHeight ) / 2 ); |
| | 266 | + } |
| | 267 | + if ( $typeCode == 2 ) { |
| | 268 | + exec( |
| | 269 | + $wgImageMagickConvertCommand . ' -size ' . $thumbWidth . 'x' . |
| | 270 | + $thumbWidth . ' -resize ' . $thumbWidth . ' -quality 100 ' . |
| | 271 | + $border . ' ' . $imageSrc . ' ' . |
| | 272 | + $this->avatarUploadDirectory . '/' . $imgDest . '.jpg' |
| | 273 | + ); |
| | 274 | + } |
| | 275 | + if ( $typeCode == 1 ) { |
| | 276 | + exec( |
| | 277 | + $wgImageMagickConvertCommand . ' -size ' . $thumbWidth . 'x' . |
| | 278 | + $thumbWidth . ' -resize ' . $thumbWidth . ' ' . $imageSrc . |
| | 279 | + ' ' . $border . ' ' . |
| | 280 | + $this->avatarUploadDirectory . '/' . $imgDest . '.gif' |
| | 281 | + ); |
| | 282 | + } |
| | 283 | + if ( $typeCode == 3 ) { |
| | 284 | + exec( |
| | 285 | + $wgImageMagickConvertCommand . ' -size ' . $thumbWidth . 'x' . |
| | 286 | + $thumbWidth . ' -resize ' . $thumbWidth . ' ' . $imageSrc . |
| | 287 | + ' ' . $this->avatarUploadDirectory . '/' . $imgDest . '.png' |
| | 288 | + ); |
| | 289 | + } |
| | 290 | + } else { // ImageMagick is not enabled, so fall back to PHP's GD library |
| | 291 | + // Get the image size, used in calculations later. |
| | 292 | + switch( $typeCode ) { |
| | 293 | + case '1': |
| | 294 | + $fullImage = imagecreatefromgif( $imageSrc ); |
| | 295 | + $ext = 'gif'; |
| | 296 | + break; |
| | 297 | + case '2': |
| | 298 | + $fullImage = imagecreatefromjpeg( $imageSrc ); |
| | 299 | + $ext = 'jpg'; |
| | 300 | + break; |
| | 301 | + case '3': |
| | 302 | + $fullImage = imagecreatefrompng( $imageSrc ); |
| | 303 | + $ext = 'png'; |
| | 304 | + break; |
| | 305 | + } |
| | 306 | + |
| | 307 | + $scale = ( $thumbWidth / $origWidth ); |
| | 308 | + |
| | 309 | + // Create our thumbnail size, so we can resize to this, and save it. |
| | 310 | + $tnImage = imagecreatetruecolor( |
| | 311 | + $origWidth * $scale, |
| | 312 | + $origHeight * $scale |
| 258 | 313 | ); |
| 259 | | - } |
| 260 | | - if ( $typeCode == 1 ) { |
| 261 | | - exec( |
| 262 | | - $wgImageMagickConvertCommand . ' -size ' . $thumbWidth . 'x' . |
| 263 | | - $thumbWidth . ' -resize ' . $thumbWidth . ' ' . $imageSrc . |
| 264 | | - ' ' . $border . ' ' . |
| 265 | | - $this->avatarUploadDirectory . '/' . $imgDest . '.gif' |
| | 314 | + |
| | 315 | + // Resize the image. |
| | 316 | + imagecopyresampled( |
| | 317 | + $tnImage, |
| | 318 | + $fullImage, |
| | 319 | + 0, 0, 0, 0, |
| | 320 | + $origWidth * $scale, |
| | 321 | + $origHeight * $scale, |
| | 322 | + $origWidth, |
| | 323 | + $origHeight |
| 266 | 324 | ); |
| 267 | | - } |
| 268 | | - if ( $typeCode == 3 ) { |
| 269 | | - exec( |
| 270 | | - $wgImageMagickConvertCommand . ' -size ' . $thumbWidth . 'x' . |
| 271 | | - $thumbWidth . ' -resize ' . $thumbWidth . ' ' . $imageSrc . |
| 272 | | - ' ' . $this->avatarUploadDirectory . '/' . $imgDest . '.png' |
| | 325 | + |
| | 326 | + // Create a new image thumbnail. |
| | 327 | + if ( $typeCode == 1 ) { |
| | 328 | + imagegif( $tnImage, $imageSrc ); |
| | 329 | + } elseif ( $typeCode == 2 ) { |
| | 330 | + imagejpeg( $tnImage, $imageSrc ); |
| | 331 | + } elseif ( $typeCode == 3 ) { |
| | 332 | + imagepng( $tnImage, $imageSrc ); |
| | 333 | + } |
| | 334 | + |
| | 335 | + // Clean up. |
| | 336 | + imagedestroy( $fullImage ); |
| | 337 | + imagedestroy( $tnImage ); |
| | 338 | + |
| | 339 | + // Copy the thumb |
| | 340 | + copy( |
| | 341 | + $imageSrc, |
| | 342 | + $this->avatarUploadDirectory . '/' . $imgDest . '.' . $ext |
| 273 | 343 | ); |
| 274 | 344 | } |
| 275 | 345 | } |