http://www.mediawiki.org/wiki/Special:Code/MediaWiki/84635

Revision: 84635
Author:   btongminh
Date:     2011-03-23 21:42:46 +0000 (Wed, 23 Mar 2011)
Log Message:
-----------
VipsHandler: Fix target width by offsetting the file dimensions per bug 25990#c7

Modified Paths:
--------------
    trunk/extensions/VipsScaler/VipsScaler_body.php

Modified: trunk/extensions/VipsScaler/VipsScaler_body.php
===================================================================
--- trunk/extensions/VipsScaler/VipsScaler_body.php     2011-03-23 21:39:17 UTC 
(rev 84634)
+++ trunk/extensions/VipsScaler/VipsScaler_body.php     2011-03-23 21:42:46 UTC 
(rev 84635)
@@ -48,13 +48,16 @@
                        # Set the new rotated file
                        $tmp = $tmp2;
                }
+               
+               # Calculate shrink factors. Offsetting by 0.5 pixels is 
required 
+               # because of rounding down of the target size by VIPS. See 
25990#c7 
                if ( $rotation % 180 == 90 ) {
                        # Rotated 90 degrees, so width = height and vice versa
-                       $rx = $params['srcWidth'] / $params['physicalHeight'];
-                       $ry = $params['srcHeight'] / $params['physicalWidth'];
+                       $rx = $params['srcWidth'] / ($params['physicalHeight'] 
+ 0.5);
+                       $ry = $params['srcHeight'] / ($params['physicalWidth'] 
+ 0.5);
                } else {
-                       $rx = $params['srcWidth'] / $params['physicalWidth'];
-                       $ry = $params['srcHeight'] / $params['physicalHeight'];
+                       $rx = $params['srcWidth'] / ($params['physicalWidth'] + 
0.5);
+                       $ry = $params['srcHeight'] / ($params['physicalHeight'] 
+ 0.5);
                }
                
                # Scale the image to the final output


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

Reply via email to