From c524394f5f3e080dd6696a43bec6265a5a61992f Mon Sep 17 00:00:00 2001 From: Bas-Jan 't Jong Date: Sat, 10 May 2014 23:52:10 +0200 Subject: [PATCH 1/2] Fixed conversion factor Centimeters to Pixels and vice versa. --- src/PhpWord/Shared/Drawing.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PhpWord/Shared/Drawing.php b/src/PhpWord/Shared/Drawing.php index 825ce8f1..f1d61eb6 100644 --- a/src/PhpWord/Shared/Drawing.php +++ b/src/PhpWord/Shared/Drawing.php @@ -108,7 +108,7 @@ class Drawing */ public static function pixelsToCentimeters($value = 0) { - return $value * 0.028; + return $value * 0.026458333; } /** @@ -120,7 +120,7 @@ class Drawing public static function centimetersToPixels($value = 0) { if ($value != 0) { - return $value / 0.028; + return $value / 0.026458333; } else { return 0; } From 967c8b273ebf09e5ec3e9fffebbefb0c1d814c99 Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Sun, 11 May 2014 10:39:39 +0700 Subject: [PATCH 2/2] Fix unit test for px2cm and cm2px conversion --- tests/PhpWord/Tests/Shared/DrawingTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/PhpWord/Tests/Shared/DrawingTest.php b/tests/PhpWord/Tests/Shared/DrawingTest.php index 02eeda9b..3fce6dc7 100644 --- a/tests/PhpWord/Tests/Shared/DrawingTest.php +++ b/tests/PhpWord/Tests/Shared/DrawingTest.php @@ -56,10 +56,10 @@ class DrawingTest extends \PHPUnit_Framework_TestCase $this->assertEquals(round($value / 60000), $result); $result = Drawing::pixelsToCentimeters($value); - $this->assertEquals($value * 0.028, $result); + $this->assertEquals($value * 0.026458333, $result); $result = Drawing::centimetersToPixels($value); - $this->assertEquals($value / 0.028, $result); + $this->assertEquals($value / 0.026458333, $result); } }