Move getRotation and getImageArea to the base class
authorBrian Wolff <bawolff+wn@gmail.com>
Sun, 29 Sep 2013 02:12:58 +0000 (23:12 -0300)
committerBrian Wolff <bawolff+wn@gmail.com>
Sun, 29 Sep 2013 04:31:56 +0000 (01:31 -0300)
This way we know we can always safely call getRotation on any image.

In particular, PagedTiffHandler doesn't extend BitmapHandler, and I
want to make VipsScaler work with PagedTiffHandler, and it calls
getRotation.

Change-Id: I63f2be2a6f31398918b8562e15343f8a839d91c1

includes/media/Bitmap.php
includes/media/ImageHandler.php
includes/media/MediaHandler.php

index 9f7a09c..41915f6 100644 (file)
@@ -99,17 +99,6 @@ class BitmapHandler extends ImageHandler {
                return array( $width, $height );
        }
 
-       /**
-        * Function that returns the number of pixels to be thumbnailed.
-        * Intended for animated GIFs to multiply by the number of frames.
-        *
-        * @param File $image
-        * @return int
-        */
-       function getImageArea( $image ) {
-               return $image->getWidth() * $image->getHeight();
-       }
-
        /**
         * @param $image File
         * @param  $dstPath
@@ -712,24 +701,6 @@ class BitmapHandler extends ImageHandler {
                imagejpeg( $dst_image, $thumbPath, 95 );
        }
 
-       /**
-        * On supporting image formats, try to read out the low-level orientation
-        * of the file and return the angle that the file needs to be rotated to
-        * be viewed.
-        *
-        * This information is only useful when manipulating the original file;
-        * the width and height we normally work with is logical, and will match
-        * any produced output views.
-        *
-        * The base BitmapHandler doesn't understand any metadata formats, so this
-        * is left up to child classes to implement.
-        *
-        * @param $file File
-        * @return int 0, 90, 180 or 270
-        */
-       public function getRotation( $file ) {
-               return 0;
-       }
 
        /**
         * Returns whether the current scaler supports rotation (im and gd do)
index 8e46f2f..e079003 100644 (file)
@@ -200,6 +200,19 @@ abstract class ImageHandler extends MediaHandler {
                wfRestoreWarnings();
                return $gis;
        }
+       /**
+        * Function that returns the number of pixels to be thumbnailed.
+        * Intended for animated GIFs to multiply by the number of frames.
+        *
+        * If the file doesn't support a notion of "area" return 0.
+        *
+        * @param File $image
+        * @return int
+        */
+       function getImageArea( $image ) {
+               return $image->getWidth() * $image->getHeight();
+       }
+
 
        /**
         * @param $file File
index 2e8d41d..8ec2e9a 100644 (file)
@@ -643,4 +643,23 @@ abstract class MediaHandler {
        public static function canRotate() {
                return false;
        }
+
+       /**
+        * On supporting image formats, try to read out the low-level orientation
+        * of the file and return the angle that the file needs to be rotated to
+        * be viewed.
+        *
+        * This information is only useful when manipulating the original file;
+        * the width and height we normally work with is logical, and will match
+        * any produced output views.
+        *
+        * For files we don't know, we return 0.
+        *
+        * @param $file File
+        * @return int 0, 90, 180 or 270
+        */
+       public function getRotation( $file ) {
+               return 0;
+       }
+
 }