From 569546c59be01477916cfe46e7c962d53915c76a Mon Sep 17 00:00:00 2001 From: Bryan Tong Minh Date: Wed, 2 Mar 2011 19:42:30 +0000 Subject: [PATCH] (bug 27809) Check for availability of imagerotate function before using it --- includes/media/Bitmap.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) 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; + } } /** -- 2.20.1