Merge "Allow postEdit hook to be triggered asynchronously"
[lhc/web/wiklou.git] / includes / media / Bitmap.php
index 0ad862d..9f7a09c 100644 (file)
@@ -29,7 +29,7 @@
 class BitmapHandler extends ImageHandler {
        /**
         * @param $image File
-        * @param $params array Transform parameters. Entries with the keys 'width'
+        * @param array $params Transform parameters. Entries with the keys 'width'
         * and 'height' are the respective screen width and height, while the keys
         * 'physicalWidth' and 'physicalHeight' indicate the thumbnail dimensions.
         * @return bool
@@ -83,8 +83,8 @@ class BitmapHandler extends ImageHandler {
         * stored as raw landscape with 90-degress rotation, the resulting size
         * will be wider than it is tall.
         *
-        * @param $params array Parameters as returned by normaliseParams
-        * @param $rotation int The rotation angle that will be applied
+        * @param array $params Parameters as returned by normaliseParams
+        * @param int $rotation The rotation angle that will be applied
         * @return array ($width, $height) array
         */
        public function extractPreRotationDimensions( $params, $rotation ) {
@@ -131,7 +131,7 @@ class BitmapHandler extends ImageHandler {
                        # The size of the image on the page
                        'clientWidth' => $params['width'],
                        'clientHeight' => $params['height'],
-                       # Comment as will be added to the EXIF of the thumbnail
+                       # Comment as will be added to the Exif of the thumbnail
                        'comment' => isset( $params['descriptionUrl'] ) ?
                                "File source: {$params['descriptionUrl']}" : '',
                        # Properties of the original image
@@ -261,7 +261,7 @@ class BitmapHandler extends ImageHandler {
         * client side
         *
         * @param $image File File associated with this thumbnail
-        * @param $scalerParams array Array with scaler params
+        * @param array $scalerParams Array with scaler params
         * @return ThumbnailImage
         *
         * @todo fixme: no rotation support
@@ -278,7 +278,7 @@ class BitmapHandler extends ImageHandler {
         * Transform an image using ImageMagick
         *
         * @param $image File File associated with this thumbnail
-        * @param $params array Array with scaler params
+        * @param array $params Array with scaler params
         *
         * @return MediaTransformError Error object if error occurred, false (=no error) otherwise
         */
@@ -377,7 +377,7 @@ class BitmapHandler extends ImageHandler {
         * Transform an image using the Imagick PHP extension
         *
         * @param $image File File associated with this thumbnail
-        * @param $params array Array with scaler params
+        * @param array $params Array with scaler params
         *
         * @return MediaTransformError Error object if error occurred, false (=no error) otherwise
         */
@@ -398,7 +398,7 @@ class BitmapHandler extends ImageHandler {
                                        $im->sharpenImage( $radius, $sigma );
                                }
                                $im->setCompressionQuality( 80 );
-                       } elseif( $params['mimeType'] == 'image/png' ) {
+                       } elseif ( $params['mimeType'] == 'image/png' ) {
                                $im->setCompressionQuality( 95 );
                        } elseif ( $params['mimeType'] == 'image/gif' ) {
                                if ( $this->getImageArea( $image ) > $wgMaxAnimatedGifArea ) {
@@ -454,7 +454,7 @@ class BitmapHandler extends ImageHandler {
         * Transform an image using a custom command
         *
         * @param $image File File associated with this thumbnail
-        * @param $params array Array with scaler params
+        * @param array $params Array with scaler params
         *
         * @return MediaTransformError Error object if error occurred, false (=no error) otherwise
         */
@@ -497,8 +497,8 @@ class BitmapHandler extends ImageHandler {
        /**
         * Get a MediaTransformError with error 'thumbnail_error'
         *
-        * @param $params array Parameter array as passed to the transform* functions
-        * @param $errMsg string Error message
+        * @param array $params Parameter array as passed to the transform* functions
+        * @param string $errMsg Error message
         * @return MediaTransformError
         */
        public function getMediaTransformError( $params, $errMsg ) {
@@ -510,7 +510,7 @@ class BitmapHandler extends ImageHandler {
         * Transform an image using the built in GD library
         *
         * @param $image File File associated with this thumbnail
-        * @param $params array Array with scaler params
+        * @param array $params Array with scaler params
         *
         * @return MediaTransformError Error object if error occurred, false (=no error) otherwise
         */
@@ -619,7 +619,7 @@ class BitmapHandler extends ImageHandler {
         * in a directory, so we're better off escaping and waiting for the bugfix
         * to filter down to users.
         *
-        * @param $path string The file path
+        * @param string $path The file path
         * @param bool|string $scene The scene specification, or false if there is none
         * @throws MWException
         * @return string
@@ -634,7 +634,7 @@ class BitmapHandler extends ImageHandler {
                # Escape glob chars
                $path = preg_replace( '/[*?\[\]{}]/', '\\\\\0', $path );
 
-               return self::escapeMagickPath( $path, $scene );
+               return $this->escapeMagickPath( $path, $scene );
        }
 
        /**
@@ -644,14 +644,14 @@ class BitmapHandler extends ImageHandler {
         */
        function escapeMagickOutput( $path, $scene = false ) {
                $path = str_replace( '%', '%%', $path );
-               return self::escapeMagickPath( $path, $scene );
+               return $this->escapeMagickPath( $path, $scene );
        }
 
        /**
         * Armour a string against ImageMagick's GetPathComponent(). This is a
         * helper function for escapeMagickInput() and escapeMagickOutput().
         *
-        * @param $path string The file path
+        * @param string $path The file path
         * @param bool|string $scene The scene specification, or false if there is none
         * @throws MWException
         * @return string
@@ -757,31 +757,31 @@ class BitmapHandler extends ImageHandler {
 
        /**
         * @param $file File
-        * @param $params array Rotate parameters.
+        * @param array $params Rotate parameters.
         *      'rotation' clockwise rotation in degrees, allowed are multiples of 90
         * @since 1.21
         * @return bool
         */
-       public static function rotate( $file, $params ) {
+       public function rotate( $file, $params ) {
                global $wgImageMagickConvertCommand;
 
-               $rotation = ( $params[ 'rotation' ] + self::getRotation( $file ) ) % 360;
+               $rotation = ( $params['rotation'] + $this->getRotation( $file ) ) % 360;
                $scene = false;
 
                $scaler = self::getScalerType( null, false );
                switch ( $scaler ) {
                        case 'im':
                                $cmd = wfEscapeShellArg( $wgImageMagickConvertCommand ) . " " .
-                                       wfEscapeShellArg( self::escapeMagickInput( $params[ 'srcPath' ], $scene ) ) .
+                                       wfEscapeShellArg( $this->escapeMagickInput( $params['srcPath'], $scene ) ) .
                                        " -rotate -$rotation " .
-                                       wfEscapeShellArg( self::escapeMagickOutput( $params[ 'dstPath' ] ) ) . " 2>&1";
+                                       wfEscapeShellArg( $this->escapeMagickOutput( $params['dstPath'] ) ) . " 2>&1";
                                wfDebug( __METHOD__ . ": running ImageMagick: $cmd\n" );
                                wfProfileIn( 'convert' );
                                $retval = 0;
                                $err = wfShellExec( $cmd, $retval, $env );
                                wfProfileOut( 'convert' );
                                if ( $retval !== 0 ) {
-                                       self::logErrorForExternalProcess( $retval, $err, $cmd );
+                                       $this->logErrorForExternalProcess( $retval, $err, $cmd );
                                        return new MediaTransformError( 'thumbnail_error', 0, 0, $err );
                                }
                                return false;