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

Support imageio-jnr / imageio-openjpeg library for JPEG2000 decoding

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.0.32, 3.0.3 PDFBox
    • 2.0.33, 3.0.4 PDFBox, 4.0.0
    • Rendering
    • None

    Description

      https://github.com/dbmdz/imageio-jnr / https://mvnrepository.com/artifact/de.digitalcollections.imageio/imageio-openjpeg is an alternative JPEG2000 implementation for Java ImageIO that uses the native OpenJPEG library as its backend.

      Unfortunately, it doesn't work out of the box because it doesn't implement raster reading (canReadRaster not overridden, returns false), and PDFBox uses canReadRaster() to validate image reader instances. However, it doesn't appear that there is any real reliance on raster support in PDFBox (at least in version 3) - if I patch the library to lie about raster support, it seems to work perfectly.

      A further complication arises when the OpenJPEG native library cannot be found: imageio-openjpeg returns null as the reader instance, which causes PDF rendering to fail with an NPE, even if another JPEG2000 reader is available. This can be remedied with a simple null check.

      https://github.com/apache/pdfbox/pull/197 shows a possible solution. Until then, https://github.com/Googulator/imageio-jnr can be used with PDFBox 3.0.3 as a workaround, so long as the native library is correctly installed.

      Attachments

        Issue Links

          Activity

            People

              tilman Tilman Hausherr
              Googulator Gábor Stefanik
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: