Bug 104861 - pdfimages adds a superfluous 0.5 to image ppi shown using -list (patch provided)
Summary: pdfimages adds a superfluous 0.5 to image ppi shown using -list (patch provided)
Status: RESOLVED MOVED
Alias: None
Product: poppler
Classification: Unclassified
Component: utils (show other bugs)
Version: unspecified
Hardware: All All
: medium normal
Assignee: poppler-bugs
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-01-30 14:50 UTC by freedesktop.mrbax
Modified: 2018-08-21 11:17 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments

Description freedesktop.mrbax 2018-01-30 14:50:42 UTC
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);
Comment 1 Albert Astals Cid 2018-02-01 21:38:45 UTC
Adrian the code is yours i think, do you remember why you added those 0.5?
Comment 2 GitLab Migration User 2018-08-21 11:17:57 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/poppler/poppler/issues/608.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.