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

[PATCH]: Support simple lossless compression of 16 bit RGB images

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.0.9
    • Fix Version/s: 2.0.12, 3.0.0 PDFBox
    • Component/s: Writing
    • Labels:
      None
    • Flags:
      Patch

      Description

      The attached patch add support to write 16 bit per component images correctly. I've integrated a test for this here: https://github.com/rototor/pdfbox-graphics2d/commit/8bf089cb74945bd4f0f15054754f51dd5b361fe9

      It only supports 16-Bit TYPE_CUSTOM with DataType == USHORT images - but this is what you usually get when you read a 16 bit PNG file.

      This would also fix https://github.com/danfickle/openhtmltopdf/issues/173.

      The patch is against 2.0.9, but should apply to 3.0.0 too.

      There is still some room for improvements when writing lossless images, as the images are currently not efficiently encoded. I.e. you could use PNG encodings to get a better compression. (By adding a COSName.DECODE_PARMS with a COSName.PREDICTOR == 15 and encoding the images as PNG). But this is something for a later patch. It would also need another API, as there is a tradeoff speed vs compression ratio. 

        Attachments

        1. 032163.jpg
          3 kB
          Tim Allison
        2. 16bit.png
          0.6 kB
          Tilman Hausherr
        3. fix_profile_use.patch
          0.7 kB
          Emmeran Seehuber
        4. fix_profile_use3.patch
          3 kB
          Emmeran Seehuber
        5. fix_profile_use4.patch
          3 kB
          Emmeran Seehuber
        6. images.zip
          4.16 MB
          Tilman Hausherr
        7. LoadGovdocs.java
          7 kB
          Tilman Hausherr
        8. lossless_predictor_based_imageencoding_v2.patch
          26 kB
          Emmeran Seehuber
        9. lossless_predictor_based_imageencoding_v3.patch
          37 kB
          Emmeran Seehuber
        10. lossless_predictor_based_imageencoding_v4.patch
          35 kB
          Emmeran Seehuber
        11. lossless_predictor_based_imageencoding_v5.patch
          52 kB
          Emmeran Seehuber
        12. lossless_predictor_based_imageencoding_v6.patch
          48 kB
          Emmeran Seehuber
        13. lossless_predictor_based_imageencoding.patch
          24 kB
          Emmeran Seehuber
        14. pdfbox_support_16bit_image_write.patch
          5 kB
          Emmeran Seehuber
        15. png16-arrow-bad.pdf
          1 kB
          Tilman Hausherr
        16. png16-arrow-bad-no-smask.pdf
          1 kB
          Tilman Hausherr
        17. png16-arrow-good.pdf
          2 kB
          Tilman Hausherr
        18. png16-arrow-good-no-mask.pdf
          2 kB
          Tilman Hausherr
        19. size_compare.txt
          308 kB
          Emmeran Seehuber

          Issue Links

            Activity

              People

              • Assignee:
                tilman Tilman Hausherr
                Reporter:
                rototor Emmeran Seehuber
              • Votes:
                1 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: