From c40f091272c64da6e755ce03b8597712c259b04a Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Tue, 16 Dec 2008 05:45:28 +0000 Subject: [PATCH] Follow-up to r44651 -- stay in floats until we finish the SVG size, so aspect ratios in silly tiny units are preserved better. --- includes/ImageFunctions.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/includes/ImageFunctions.php b/includes/ImageFunctions.php index 219b5b0baa..7b55ad555a 100644 --- a/includes/ImageFunctions.php +++ b/includes/ImageFunctions.php @@ -5,7 +5,7 @@ * * @param $length String: CSS/SVG length. * @param $viewpoerSize: Float optional scale for percentage units... - * @return Integer: length in pixels + * @return float: length in pixels */ function wfScaleSVGUnit( $length, $viewportSize=512 ) { static $unitLength = array( @@ -24,13 +24,13 @@ function wfScaleSVGUnit( $length, $viewportSize=512 ) { $length = floatval( $matches[1] ); $unit = $matches[2]; if( $unit == '%' ) { - return round( $length * 0.01 * $viewportSize ); + return $length * 0.01 * $viewportSize; } else { - return round( $length * $unitLength[$unit] ); + return $length * $unitLength[$unit]; } } else { // Assume pixels - return round( floatval( $length ) ); + return floatval( $length ); } } @@ -76,8 +76,11 @@ class XmlSizeFilter { $width = $height * $aspect; } - $this->width = $width; - $this->height = $height; + if( $width > 0 && $height > 0 ) { + $this->width = intval( round( $width ) ); + $this->height = intval( round( $height ) ); + } + $this->first = false; } } -- 2.20.1