Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

IMPROVED : Conversion of centimeters to pixels and pixels to centimeters

  • Loading branch information...
commit 59bb7bc46a699a4b84a63e8a2d954b44d3cad4fe 1 parent 41b2761
@Progi1984 Progi1984 authored
Showing with 6 additions and 2 deletions.
  1. +6 −2 Classes/PHPPowerPoint/Shared/Drawing.php
View
8 Classes/PHPPowerPoint/Shared/Drawing.php
@@ -35,6 +35,9 @@
*/
class PHPPowerPoint_Shared_Drawing
{
+
+ const DPI_96 = 96;
+
/**
* Convert pixels to EMU
*
@@ -90,7 +93,8 @@ public static function pointsToPixels($pValue = 0) {
* @return int Value in centimeters
*/
public static function pixelsToCentimeters($pValue = 0) {
- return $pValue * 0.028;
+ //return $pValue * 0.028;
+ return (($pValue / self::DPI_96) * 2.54);
}
/**
@@ -101,7 +105,7 @@ public static function pixelsToCentimeters($pValue = 0) {
*/
public static function centimetersToPixels($pValue = 0) {
if ($pValue != 0) {
- return $pValue * 0.028;
+ return ($pValue / 2.54) * self::DPI_96;
} else {
return 0;
}
Please sign in to comment.
Something went wrong with that request. Please try again.