PhilterPaper / Perl-PDF-Builder

Extended version of the popular PDF::API2 Perl-based PDF library for creating, reading, and modifying PDF documents
https://www.catskilltech.com/FreeSW/product/PDF%2DBuilder/title/PDF%3A%3ABuilder/freeSW_full
Other
6 stars 7 forks source link

[CTS 12] JPEG2000 image file support #97

Closed PhilterPaper closed 1 year ago

PhilterPaper commented 5 years ago

In #90, carylewis replied 29 July 2018:

I’m seeing more and more jp2 files, and pdf 1.4 doesn’t support that fije type. This necessitates converting files to 1.4 and that means converted the jpeg2000 images to tiff which is slow.

I'll throw support of JPEG2000 images into the hopper. The first thing is to confirm that some PDF 1.x version properly handles it. I've seen claims that it's in PDF 1.5.

PhilterPaper commented 5 years ago

I've done some reading on JPEG2000 (.jp2, .jpx). Apparently it has some much-improved compression algorithms (less artifacting, smaller size, or lossless compression if desired). However, uptake has been very slow, and it has little support. Nonetheless, if I can get some documentation on it, I can consider how much effort it will take to implement it. There's also the question of patents used in it, and whether they've expired by now (same goes for GIF and LZW). If it's a big project, it may not be worth doing unless there is more demand for JPEG2000 support (so far, only one request). I don't see any libraries on CPAN for this format.

PhilterPaper commented 5 years ago

Browsing the PDF documentation some more, it talks a bit about JP2/JPX using the JPXDecode filter instead of JPEG's DCTDecode. If that's all it is (or at least, covers most of the waterfront), it shouldn't be too much effort to put this in PDF::Builder as a PDF-1.5 feature. However, the JPEG2000 pages talk about all sorts of other features and capabilities (e.g., opacity by band, combining multiple images at different samplings into one, etc.) that leads me to suspect that there may be much more work to do. At the least, it should benignly ignore extra features and still do the basic job of showing a JP2/JPX image. At this point, unless a CPAN library shows up that handles it for me, I'll have to wait until someone knowledgeable in JPEG2000 can lend a hand.

PhilterPaper commented 5 years ago

It seems that there is another contender who's thrown its hat into the ring: WebP from Google. Its chief claim to fame seems to be an improvement to the compression method (both lossless compression, like PNG, and lossy compression, like JPEG) giving smaller files. .webp support is now built in to Chrome, Edge, and Firefox. See https://developers.google.com/speed/webp/ .

I expect that we would have to await a new filter to be supplied to PDF readers to allow this format to be used. Maybe something would have to be done on the PDF::Builder end to do more than just specify a new filter.

In the meantime, there are tools to convert .webp into other formats such as PNG and JPEG, so not all is lost if only WebP images are available.

PhilterPaper commented 1 year ago

I don't see any Perl support yet for JP2, and it seems to have withered on the vine on the Web, so I'm going to set this one aside and close it. Maybe I'll do WebP format some day.