Created attachment 99199 [details] Avoid round-off errors when determining raster dimensions. The code in pdftoppm.cc and pdftocairo.cc carefully avoided overflow when converting page sizes from points to pixels. This worked well when the math was performed at extended precision, as is done when using x387 opcodes, but could lead to results too large by a ulp when computed without extra precision. The code then needs to call ceil(3) to round fractional results up to the next larger integer, resulting in an off-by-one error if the computed size is even one ulp more than an integer. The initial size is already a multiple of 72, so rearranging the math to multiply before dividing by 72 avoids that imprecision. Please consider pulling the signed tag at: git://people.freedesktop.org/~cloos/poppler.git refs/tags/roundoff utils/pdftocairo.cc | 4 ++-- utils/pdftoppm.cc | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) I’ve also attached the formatted patch for review.
I must have been more exhausted than I realized last night. The repo is fixed, you can pull: git://people.freedesktop.org/~cloos/poppler.git roundoff I also forgot to note that I tested a wide range of page sizes and output resolutions, each of standard inch and metric sizes, and odd sizes in inches, metres and points. I also tried different optimization levels. The new calcuation order matched up with exact results for every test I tried. The existing order got it wrong a small but noticible percentage of the time. To see the error when using pdftocairo, use -png output.
So this would result in output files with wrong pixel size? Do you have a file that would cause that? Is this in some special architecture?
-- 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/253.
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.