From: Bryan Tong Minh Date: Wed, 2 Mar 2011 19:42:30 +0000 (+0000) Subject: (bug 27809) Check for availability of imagerotate function before using it X-Git-Tag: 1.31.0-rc.0~31689 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22suivi_revisions%22%29%20.%20%22?a=commitdiff_plain;h=569546c59be01477916cfe46e7c962d53915c76a;p=lhc%2Fweb%2Fwiklou.git (bug 27809) Check for availability of imagerotate function before using it --- diff --git a/includes/media/Bitmap.php b/includes/media/Bitmap.php index 7e93994eea..cc7b052030 100644 --- a/includes/media/Bitmap.php +++ b/includes/media/Bitmap.php @@ -402,7 +402,8 @@ class BitmapHandler extends ImageHandler { } $src_image = call_user_func( $loader, $params['srcPath'] ); - $rotation = $this->getRotation( $image ); + + $rotation = function_exists( 'imagerotate' ) ? $this->getRotation( $image ) : 0; if ( $rotation == 90 || $rotation == 270 ) { # We'll resize before rotation, so swap the dimensions again $width = $params['physicalHeight']; @@ -698,7 +699,18 @@ class BitmapHandler extends ImageHandler { */ public static function canRotate() { $scaler = self::getScalerType( null, false ); - return $scaler == 'im' || $scaler == 'gd'; + switch ( $scaler ) { + case 'im': + # ImageMagick supports autorotation + return true; + case 'gd': + # GD's imagerotate function is used to rotate images, but not + # all precompiled PHP versions have that function + return function_exists( 'imagerotate' ); + default: + # Other scalers don't support rotation + return false; + } } /**