Package: djvubind
Version: 1.2.1-3
Severity: important
Hi, Clint.
When trying to create a book with some tiff files that were (very
laboriously) generated by scantailor (with lots of fine-tuning by hand), I
get the following, very non-informative stack trace from djvubind, when I
have files that are "mixed mode":
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(...)
msg: s-260_1L.tif: Bitonal image but with a depth greater than 1. Modifying
image depth.
msg: s-260_2R.tif: Bitonal image but with a depth greater than 1. Modifying
image depth.
* Performing optical character recognition.
OCR is disabled and will be skipped.
* Encoding all information to /tmp/solutions/out/book.djvu.
Traceback (most recent call last):
File "/usr/bin/djvubind", line 446, in <module>
proj.bind()
File "/usr/bin/djvubind", line 171, in bind
self.enc.enc_book(self.book, self.out)
File "/usr/lib/python3/dist-packages/djvubind/encode.py", line 281, in
enc_book
self._csepdjvu(page.path, tempfile, page.dpi)
File "/usr/lib/python3/dist-packages/djvubind/encode.py", line 137, in
_csepdjvu
self._cjb2('temp_textual.tif', 'enc_bitonal_out.djvu', dpi)
File "/usr/lib/python3/dist-packages/djvubind/encode.py", line 84, in _cjb2
utils.execute(cmd)
File "/usr/lib/python3/dist-packages/djvubind/utils.py", line 193, in execute
print(utils.color("err: [utils.execute()] Command exited with bad status.",
'red'), file=sys.stderr)
NameError: name 'utils' is not defined
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Digging through, I found that the problem is that the call to cjb2 above is
failing when it is fed the file temp_textual.tif which is supposed to be
only bilevel (that is only black and white).
I found (and tested successfully) that temp_textual.tif isn't being
generated as cjb2 expects because the call to convert that created it isn't
creating a bilevel image.
Adding the option -depth 1 to the line that precedes the call to cjb2 fixes
this. I am including a patch that I tested here.
It would be super nice if you could upload a new version with this change
applied, since djvubind very frequently dies when I try to convert some
books.
Thanks for packaging djvubind,
Rogério Brito.
-- System Information:
Debian Release: buster/sid
APT prefers buildd-unstable
APT policy: (500, 'buildd-unstable'), (500, 'testing'), (200, 'unstable'),
(150, 'experimental'), (1, 'buildd-experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386
Kernel: Linux 4.15.0-2-amd64 (SMP w/2 CPU cores)
Locale: LANG=en_US.utf-8, LC_CTYPE=pt_BR.utf-8 (charmap=UTF-8),
LANGUAGE=en_US.utf-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
Versions of packages djvubind depends on:
ii djvulibre-bin 3.5.27.1-8
ii imagemagick 8:6.9.9.34+dfsg-3+b1
ii imagemagick-6.q16 [imagemagick] 8:6.9.9.34+dfsg-3+b1
ii python3 3.6.4-1
ii tesseract-ocr 4.00~git2219-40f43111-1.2
Versions of packages djvubind recommends:
ii minidjvu 0.8.svn.2010.05.06+dfsg-5+b4
djvubind suggests no packages.
-- no debconf information
--
Rogério Brito : rbrito@{ime.usp.br,gmail.com} : GPG key 4096R/BCFCAAAA
http://cynic.cc/blog/ : github.com/rbrito : profiles.google.com/rbrito
DebianQA: http://qa.debian.org/developer.php?login=rbrito%40ime.usp.br
>From 99aa73b107a233c8306f157e7351fba8013adb5c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rog=C3=A9rio=20Brito?= <[email protected]>
Date: Sat, 14 Apr 2018 01:29:17 -0300
Subject: [PATCH] djvubind/encode: Force file to cjb2 to be only black and
white.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Note above that convert (Debian's at least), even if asked to
create a monochrome tif will still generate one with 8 bits per
color and cj2b will barf, telling us (correctly) that it is not in
a format that it accepts.
The -depth 1 forces convert to generate a bilevel grayscale tif.
An alternative to using -depth 1 would be to specify the extension
as .pbm, but we would, then, need to modify the name of the file
in more places.
Signed-off-by: Rogério Theodoro de Brito <[email protected]>
---
djvubind/encode.py | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/djvubind/encode.py b/djvubind/encode.py
index b0ed70d..b6622d3 100644
--- a/djvubind/encode.py
+++ b/djvubind/encode.py
@@ -131,7 +131,18 @@ class Encoder:
#utils.execute('convert -opaque black "{0}" "temp_graphics.tif"'.format(infile))
#utils.execute('convert +opaque black "{0}" "temp_textual.tif"'.format(infile))
utils.execute('convert "{0}" -opaque black "temp_graphics.tif"'.format(infile))
- utils.execute('convert "{0}" +opaque black -monochrome "temp_textual.tif"'.format(infile))
+ utils.execute('convert "{0}" +opaque black -monochrome -depth 1 "temp_textual.tif"'.format(infile))
+
+ # Note above that convert (Debian's at least), even if asked to
+ # create a monochrome tif will still generate one with 8 bits per
+ # color and cj2b will barf, telling us (correctly) that it is not in
+ # a format that it accepts.
+ #
+ # The -depth 1 forces convert to generate a bilevel grayscale tif.
+ #
+ # An alternative to using -depth 1 would be to specify the extension
+ # as .pbm, but we would, then, need to modify the name of the file
+ # in more places.
# Encode the bitonal image.
self._cjb2('temp_textual.tif', 'enc_bitonal_out.djvu', dpi)
--
2.16.3