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

Apply subsampling and region to masks

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Trivial
    • Resolution: Fixed
    • 2.0.26
    • 2.0.28, 3.0.0 PDFBox
    • Rendering
    • None

    Description

      When {}`PDImageXObject.getImage()` gets invoked with subsampling and region, internally it loads the entire mask into memory: https://github.com/apache/pdfbox/blob/961c052d52dd9ab2dd3d7cd762a5046e5cc85a91/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/PDImageXObject.java#L465

      and applies the entire mask on the subsampled image.

      Which is extra work and can cause `OOM` exceptions. 

      The proposed optimisation is to pass `region` and `subsampling` params to `PDImageXObject.getOpaqueImage() `here - https://github.com/apache/pdfbox/blob/961c052d52dd9ab2dd3d7cd762a5046e5cc85a91/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/PDImageXObject.java#L548

      such that masks are also subsampled before applying them...

      Attachments

        1. C.pdf
          14.45 MB
          Velislava Yanchina
        2. C-1.pdf
          14.45 MB
          Velislava Yanchina

        Issue Links

          Activity

            People

              lehmi Andreas Lehmkühler
              velyan Velislava Yanchina
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: