diff --git a/README.md b/README.md index 6314a48..36c471d 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # pdf-segmented -Generate PDFs (or DJVU) using separate compression for foreground and background +Generate PDFs (or DjVu) using separate compression for foreground and background ## Usage @@ -14,7 +14,7 @@ All black pixels (#000000) will be considered to be foreground, and all remainin The foreground will be compressed losslessly using [JBIG2](https://en.wikipedia.org/wiki/JBIG2). The background will be compressed lossily using [JPEG](https://en.wikipedia.org/wiki/JPEG). JPEG quality can be controlled using the `--jpeg-quality` option; the default is the Pillow default (75% at time of writing). -Additional compression algorithms are supported (JPEG 2000, PNG); see `--help` for detailed options. DJVU output (foreground JB2, background IW44) is also supported. +Additional compression algorithms are supported (JPEG 2000, PNG); see `--help` for detailed options. DjVu output (foreground JB2, background IW44) is also supported. ## Dependencies @@ -22,5 +22,6 @@ Additional compression algorithms are supported (JPEG 2000, PNG); see `--help` f * [NumPy](https://numpy.org/) (tested using 2.2.5) * [Pillow](https://pillow.readthedocs.io/en/stable/) (tested using 11.2.1) * [pikepdf](https://pikepdf.readthedocs.io/en/latest/) (tested using 9.7.0) +* [DjVuLibre](https://djvu.sourceforge.net/) (tested using 3.5.28) – for DjVu output * [ImageMagick](https://imagemagick.org/) (tested using 7.1.1.47) -* [jbig2enc](https://github.com/agl/jbig2enc) (tested using 0.30) +* [jbig2enc](https://github.com/agl/jbig2enc) (tested using 0.30) – for JBIG2 diff --git a/pdf_segmented/__init__.py b/pdf_segmented/__init__.py index 5693b66..1ff3d60 100644 --- a/pdf_segmented/__init__.py +++ b/pdf_segmented/__init__.py @@ -81,10 +81,10 @@ def convert_file( if output_format == 'djvu': if bg_compression != 'iw44': - print('Error: Unsupported --bg-compression for DJVU format (supported: iw44)') + print('Error: Unsupported --bg-compression for DjVu format (supported: iw44)') sys.exit(1) if fg_compression != 'jb2': - print('Error: Unsupported --fg-compression for DJVU format (supported: jb2)') + print('Error: Unsupported --fg-compression for DjVu format (supported: jb2)') sys.exit(1) # Get input pages diff --git a/pdf_segmented/compression/iw44.py b/pdf_segmented/compression/iw44.py index 8d633ab..5537c6f 100644 --- a/pdf_segmented/compression/iw44.py +++ b/pdf_segmented/compression/iw44.py @@ -33,8 +33,8 @@ class IW44Layer(CompressedLayer): os.unlink(self.filename) def iw44_compress_layer(layer: Image, dpi: float, tempdir: str) -> IW44Layer: - assert_has_c44('IW44 compression requires DjvuLibre') - assert_has_djvuextract('IW44 compression requires DjvuLibre') + assert_has_c44('IW44 compression requires DjVuLibre') + assert_has_djvuextract('IW44 compression requires DjVuLibre') # Save image to PBM temporarily _, ppm_file = tempfile.mkstemp(suffix='.ppm', dir=tempdir) diff --git a/pdf_segmented/compression/jb2.py b/pdf_segmented/compression/jb2.py index 02b3956..3f693e2 100644 --- a/pdf_segmented/compression/jb2.py +++ b/pdf_segmented/compression/jb2.py @@ -33,7 +33,7 @@ class JB2Layer(CompressedLayer): os.unlink(self.filename) def jb2_compress_layer(layer: Image, dpi: float, tempdir: str) -> JB2Layer: - assert_has_cjb2('JB2 compression requires DjvuLibre') + assert_has_cjb2('JB2 compression requires DjVuLibre') # Save image to PPM temporarily _, pbm_file = tempfile.mkstemp(suffix='.pbm', dir=tempdir) diff --git a/pdf_segmented/output/djvu.py b/pdf_segmented/output/djvu.py index 9675caa..11a1018 100644 --- a/pdf_segmented/output/djvu.py +++ b/pdf_segmented/output/djvu.py @@ -30,8 +30,8 @@ def djvu_write_pages( tempdir: str ) -> None: - assert_has_djvm('DJVU output requires DjvuLibre') - assert_has_djvumake('DJVU output requires DjvuLibre') + assert_has_djvm('DjVu output requires DjVuLibre') + assert_has_djvumake('DjVu output requires DjVuLibre') djvu_page_files = [] diff --git a/pdf_segmented/util.py b/pdf_segmented/util.py index a541371..4b96049 100644 --- a/pdf_segmented/util.py +++ b/pdf_segmented/util.py @@ -17,27 +17,27 @@ import shutil import sys -def assert_has_c44(error_message: str = 'DjvuLibre is required') -> None: +def assert_has_c44(error_message: str = 'DjVuLibre is required') -> None: if shutil.which('c44') is None: print('Error: {} (c44 not found on PATH)'.format(error_message), file=sys.stderr) sys.exit(1) -def assert_has_cjb2(error_message: str = 'DjvuLibre is required') -> None: +def assert_has_cjb2(error_message: str = 'DjVuLibre is required') -> None: if shutil.which('cjb2') is None: print('Error: {} (cjb2 not found on PATH)'.format(error_message), file=sys.stderr) sys.exit(1) -def assert_has_djvm(error_message: str = 'DjvuLibre is required') -> None: +def assert_has_djvm(error_message: str = 'DjVuLibre is required') -> None: if shutil.which('djvm') is None: print('Error: {} (djvm not found on PATH)'.format(error_message), file=sys.stderr) sys.exit(1) -def assert_has_djvuextract(error_message: str = 'DjvuLibre is required') -> None: +def assert_has_djvuextract(error_message: str = 'DjVuLibre is required') -> None: if shutil.which('djvuextract') is None: print('Error: {} (djvuextract not found on PATH)'.format(error_message), file=sys.stderr) sys.exit(1) -def assert_has_djvumake(error_message: str = 'DjvuLibre is required') -> None: +def assert_has_djvumake(error_message: str = 'DjVuLibre is required') -> None: if shutil.which('djvumake') is None: print('Error: {} (djvumake not found on PATH)'.format(error_message), file=sys.stderr) sys.exit(1)