Uploaded image for project: 'PDFBox'
  1. PDFBox
  2. PDFBOX-4832

Binary CCITT image with nearest neighbor interpolation instead gets upscaled with bicubic, PDFBox thinks it's downscaling

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.0.19
    • None
    • Rendering
    • None

    Description

      The attached PDF contains a CCITT-encoded black-and-white image of a roughly US Letter-sized page (611x783 PDF points page size), scanned at 200DPI. The image is slightly undersized, at 1696 pixels wide, instead of the expected 1697. The PDF calls for this image to be upscaled using nearest-neighbor interpolation (downscaling is always smoothly interpolated, to avoid artifacts - see PDFBOX-2364).

      When I try to render this page to an RGB image in either 200 or 300 DPI, the image unexpectedly ends up containing shades of gray. Upon closer inspection, it is clear that the upscaling was performed using bicubic interpolation instead of nearest-neighbor. Stepping through the PDF rendering code reveals that, in both cases, PDFBox somehow thinks the image is being _down_scaled, and applies the behavior from PDFBOX-2364. Additionally, PDFBOX-4831 may also be at play here, as the computed target image dimensions aren't round integers, but very slightly undersized (e.g. 2174.999858106px instead of 2175px).

      Attachments

        1. pdf_scanned-eng-bw.pdf
          23 kB
          Gábor Stefanik

        Issue Links

          Activity

            People

              Unassigned Unassigned
              Googulator Gábor Stefanik
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: