jenkins-bot has submitted this change and it was merged.

Change subject: Move getRotation and getImageArea to the base class
......................................................................


Move getRotation and getImageArea to the base class

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
---
M includes/media/Bitmap.php
M includes/media/ImageHandler.php
M includes/media/MediaHandler.php
3 files changed, 32 insertions(+), 29 deletions(-)

Approvals:
  BryanDavis: Looks good to me, but someone else must approve
  Aaron Schulz: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/media/Bitmap.php b/includes/media/Bitmap.php
index 9f7a09c..41915f6 100644
--- a/includes/media/Bitmap.php
+++ b/includes/media/Bitmap.php
@@ -100,17 +100,6 @@
        }
 
        /**
-        * 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
         * @param  $dstUrl
@@ -712,24 +701,6 @@
                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)
diff --git a/includes/media/ImageHandler.php b/includes/media/ImageHandler.php
index 8e46f2f..e079003 100644
--- a/includes/media/ImageHandler.php
+++ b/includes/media/ImageHandler.php
@@ -200,6 +200,19 @@
                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
diff --git a/includes/media/MediaHandler.php b/includes/media/MediaHandler.php
index 2e8d41d..8ec2e9a 100644
--- a/includes/media/MediaHandler.php
+++ b/includes/media/MediaHandler.php
@@ -643,4 +643,23 @@
        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;
+       }
+
 }

-- 
To view, visit https://gerrit.wikimedia.org/r/86404
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I63f2be2a6f31398918b8562e15343f8a839d91c1
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Brian Wolff <[email protected]>
Gerrit-Reviewer: Aaron Schulz <[email protected]>
Gerrit-Reviewer: BryanDavis <[email protected]>
Gerrit-Reviewer: Reedy <[email protected]>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to