commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dam...@apache.org
Subject svn commit: r1325111 - /commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/TiffImageParser.java
Date Thu, 12 Apr 2012 03:38:40 GMT
Author: damjan
Date: Thu Apr 12 03:38:40 2012
New Revision: 1325111

URL: http://svn.apache.org/viewvc?rev=1325111&view=rev
Log:
Fix reading DPI for TIFF files.

Jira issue key: SANSELAN-68
Submitted by: VVD <vvd at pochta dot ru>


Modified:
    commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/TiffImageParser.java

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/TiffImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/TiffImageParser.java?rev=1325111&r1=1325110&r2=1325111&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/TiffImageParser.java
(original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/TiffImageParser.java
Thu Apr 12 03:38:40 2012
@@ -201,8 +201,8 @@ public class TiffImageParser extends Ima
         case 2: // Inch
             unitsPerInch = 1.0;
             break;
-        case 3: // Meter
-            unitsPerInch = 0.0254;
+        case 3: // Centimeter
+            unitsPerInch = 2.54;
             break;
         default:
             break;
@@ -223,7 +223,7 @@ public class TiffImageParser extends Ima
             {
                 double XResolutionPixelsPerUnit = xResolutionField
                         .getDoubleValue();
-                physicalWidthDpi = (int) (XResolutionPixelsPerUnit / unitsPerInch);
+                physicalWidthDpi = (int) Math.round((XResolutionPixelsPerUnit * unitsPerInch));
                 physicalWidthInch = (float) (width / (XResolutionPixelsPerUnit * unitsPerInch));
             }
             if ((yResolutionField != null)
@@ -231,7 +231,7 @@ public class TiffImageParser extends Ima
             {
                 double YResolutionPixelsPerUnit = yResolutionField
                         .getDoubleValue();
-                physicalHeightDpi = (int) (YResolutionPixelsPerUnit / unitsPerInch);
+                physicalHeightDpi = (int) Math.round((YResolutionPixelsPerUnit * unitsPerInch));
                 physicalHeightInch = (float) (height / (YResolutionPixelsPerUnit * unitsPerInch));
             }
         }



Mime
View raw message