From 1aea0ce29ea898b536bb1fe03fa65081ae998f54 Mon Sep 17 00:00:00 2001 From: Brian Wolff Date: Sat, 28 Sep 2013 23:12:58 -0300 Subject: [PATCH] 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 --- includes/media/Bitmap.php | 29 ----------------------------- includes/media/ImageHandler.php | 13 +++++++++++++ includes/media/MediaHandler.php | 19 +++++++++++++++++++ 3 files changed, 32 insertions(+), 29 deletions(-) diff --git a/includes/media/Bitmap.php b/includes/media/Bitmap.php index 9f7a09cc85..41915f6bfc 100644 --- a/includes/media/Bitmap.php +++ b/includes/media/Bitmap.php @@ -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) diff --git a/includes/media/ImageHandler.php b/includes/media/ImageHandler.php index 8e46f2f2fa..e079003b22 100644 --- a/includes/media/ImageHandler.php +++ b/includes/media/ImageHandler.php @@ -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 diff --git a/includes/media/MediaHandler.php b/includes/media/MediaHandler.php index 2e8d41dee4..8ec2e9a87a 100644 --- a/includes/media/MediaHandler.php +++ b/includes/media/MediaHandler.php @@ -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; + } + } -- 2.20.1