[Poppler-bugs] [Bug 104861] New: pdfimages adds a superfluous 0.5 to image ppi shown using -list (patch provided)

bugzilla-daemon at freedesktop.org bugzilla-daemon at freedesktop.org
Tue Jan 30 14:50:42 UTC 2018


https://bugs.freedesktop.org/show_bug.cgi?id=104861

            Bug ID: 104861
           Summary: pdfimages adds a superfluous 0.5 to image ppi shown
                    using -list (patch provided)
           Product: poppler
           Version: unspecified
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: medium
         Component: utils
          Assignee: poppler-bugs at lists.freedesktop.org
          Reporter: freedesktop.mrbax at spamgourmet.com

Adding 0.5 to a double before formatting with "%5.0f" results in a rounding
error.  Presumably it was originally done before truncating to int.


--- utils/ImageOutputDev.cc.old       2018-01-30 16:38:42.179170000 +0200
+++ utils/ImageOutputDev.cc   2018-01-30 16:39:13.506750000 +0200
@@ -234,13 +234,13 @@
   double *mat = state->getCTM();
   double width2 = mat[0] + mat[2];
   double height2 = mat[1] + mat[3];
-  double xppi = fabs(width*72.0/width2) + 0.5;
-  double yppi = fabs(height*72.0/height2) + 0.5;
+  double xppi = fabs(width*72.0/width2);
+  double yppi = fabs(height*72.0/height2);
   if (xppi < 1.0)
     printf("%5.3f ", xppi);
   else
     printf("%5.0f ", xppi);
   if (yppi < 1.0)
     printf("%5.3f ", yppi);
   else
     printf("%5.0f ", yppi);

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/poppler-bugs/attachments/20180130/dd49831a/attachment.html>


More information about the Poppler-bugs mailing list