Add support for JBIG2 (generic coding)
#184
Open
ooBJ3u
wants to merge 3 commits from ooBJ3u/img2pdf:main
into main
Loading…
Reference in New Issue
There is no content yet.
Delete Branch 'ooBJ3u/img2pdf:main'
Deleting a branch is permanent. It CANNOT be undone. Continue?
Implements the proposal detailed at #112.
This is a limited implementation of JBIG2, which can be extended to support multiple pages, symbol tables, and other features of the format in the future.
To test, I included a test fixture. You can also download 042.bmp (the same one as @josch already downloaded in #112 from https://git.ghostscript.com/?p=tests.git;a=blob_plain;f=jbig2/042.bmp;hb=HEAD and run the following command:
This results in a small PDF, just as @josch originally found in the comment mentioned above.
This is my first contribution to this repository so let me know if something else is needed. Thanks for a great library!
154a61a88f
toee42963164
5 months agoWow, thank you! I read through your diff without trying it out yet and it looks really, really good!
My biggest gripe right now is src/tests/input/042.jb2. Why did you use the scan of a page instead the "TEST" image used in the other test cases? One problem with using a "real" test image like you chose in form of the scan of a page is the copyright situation. Even if that page is available in the public domain (is it?) you have to now write that down and keep track of this somewhere.
No problem, I'll swap it out.
2c00f3b66b
tob23d82c45e
5 months agoFixed in
085dd192f6
.@ -1820,7 +1842,41 @@ def read_images(
if rawdata[:12] == b"\x00\x00\x00\x0C\x6A\x50\x20\x20\x0D\x0A\x87\x0A":
# image is jpeg2000
imgformat = ImageFormat.JPEG2000
if rawdata[:14].lower() == b"id=imagemagick":
I wasn't sure why this was
if
instead ofelif
. Won't that make it so JPEG2000 still crashes? I fixed it but wanted to double-check.@ -33,12 +33,14 @@ input file format and image color space.
| JPEG2000 | any | direct |
| PNG (non-interlaced, no transparency) | any | direct |
| TIFF (CCITT Group 4) | monochrome | direct |
| JBIG2 (single-page generic coding) | bi-level | direct |
the other entries seem to use the term
monochrome
for 1 bit per pixel images.Monochrome is also often used for greyscale images, however. See e.g. https://en.wikipedia.org/wiki/Monochrome
Bi-level is pretty standard terminology, though "binary images" or perhaps even "1-bit images" might be clearer. https://en.wikipedia.org/wiki/Binary_image
I'm fine with choosing another term, all I mean is the table should be made consistent.
Apologies for the delay. I've updated the README to consistently say "1-bit monochrome" (to differentiate it from the other meaning of "grayscale"). Does this look good?
Step 1:
From your project repository, check out a new branch and test the changes.Step 2:
Merge the changes and update on Gitea.