Re-encode plates to lossless JBIG2 / JPEG at build time (115 MB -> 12 MB)
The scan is a bilevel 300 dpi JBIG2 layer plus lower-resolution colour, so storing every plate as 8-bit PNG only added size. tools/optimize_plates.py writes copies under work/plates-opt (bilevel to generic-mode, lossless JBIG2; genuine halftone to JPEG q88) and repoints work/pages at them; plates/ and src/ are untouched. The Dockerfile builds jbig2enc and adds qpdf, ghostscript and img2pdf. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
c4aec3becf
commit
d48ce1f50c
4 files changed
+213
-1
No files matched your search
+14
@@ -9,9 +9,23 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
poppler-utils tesseract-ocr tesseract-ocr-eng \
|
||||
python3 python3-pip python3-pil python3-numpy \
|
||||
make curl ca-certificates \
|
||||
qpdf ghostscript img2pdf \
|
||||
git automake autoconf libtool g++ pkg-config libleptonica-dev zlib1g-dev \
|
||||
&& rm -rf /var/lib/apt/lists/* \
|
||||
&& pip3 install --no-cache-dir --break-system-packages pdfplumber fonttools \
|
||||
&& fc-cache -f
|
||||
|
||||
# jbig2enc: the encoder the ProQuest scan itself uses for its bilevel page
|
||||
# layer, and the reason a 2556x3305 page fits in 4900 bytes there. It builds a
|
||||
# dictionary of repeated letterforms and stores each shape once, which general
|
||||
# compressors cannot do -- measured on this scan, 0.019 bits/pixel against
|
||||
# 0.084 for CCITT G4 and 0.159 for 1-bit PNG. Not packaged for Ubuntu 24.04, so
|
||||
# it is built from source.
|
||||
RUN git clone --depth 1 https://github.com/agl/jbig2enc /tmp/jbig2enc \
|
||||
&& cd /tmp/jbig2enc \
|
||||
&& ./autogen.sh && ./configure && make -j"$(nproc)" && make install \
|
||||
&& ldconfig \
|
||||
&& rm -rf /tmp/jbig2enc
|
||||
WORKDIR /work
|
||||
# The project directory is bind-mounted at /work (see compose.yaml); nothing is copied in.
|
||||
CMD ["bash"]
|
||||
Reference in new issue
Block a user