diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..aa2343c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,53 @@ +# after Debian 13 (trixie) is released, this can be removed in favor of the libjbig2enc-dev package +FROM debian:bookworm-slim AS jbig2enc-builder + +RUN apt-get update && apt-get install -y --no-install-recommends \ + build-essential autoconf automake libtool \ + libleptonica-dev \ + zlib1g-dev \ + libffi-dev \ + ca-certificates \ + curl \ + git \ + libcairo2-dev \ + pkg-config + +WORKDIR /opt + +RUN git clone --depth 1 https://github.com/agl/jbig2enc && \ + cd jbig2enc && \ + ./autogen.sh && \ + ./configure && \ + make && \ + make install + +# The actual image to be used +FROM python:3.11-bookworm + +RUN apt-get update && apt-get install -y --no-install-recommends \ + libdjvulibre-dev \ + libtiff-dev \ + libjpeg-dev \ + ghostscript \ + poppler-utils \ + libleptonica-dev \ + # libjbig2enc-dev \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +COPY --from=jbig2enc-builder /usr/local/lib/ /usr/local/lib/ +COPY --from=jbig2enc-builder /usr/local/bin/ /usr/local/bin/ + +RUN pip install --no-cache-dir poetry ocrmypdf + +WORKDIR /app +COPY . . + +RUN poetry config virtualenvs.create false \ + && poetry install --no-interaction --no-ansi + +RUN mkdir /files + +WORKDIR /files + +ENTRYPOINT ["python", "-m", "dpsprep"] diff --git a/README.md b/README.md index d4986b3..e212b3a 100644 --- a/README.md +++ b/README.md @@ -95,3 +95,33 @@ http://askubuntu.com/questions/46233/converting-djvu-to-pdf (OCR text transfer) By implementing the procedure of user pyrocrasty for extracting the outline, and putting it into the PDF generated above: http://superuser.com/questions/801893/converting-djvu-to-pdf-and-preserving-table-of-contents-how-is-it-possible (bookmark transfer) + +## Using Docker + +Build the Docker image: + +```bash +docker build -t dpsprep . +``` + +Run the container with a volume mount to process files: + +```bash +docker run --rm -u $(id -u):$(id -g) -v $(pwd):/files dpsprep input.djvu output.pdf +``` + +To use specific options: + +```bash +docker run --rm -u $(id -u):$(id -g) -v $(pwd):/files dpsprep --pool=8 --quality=50 input.djvu output.pdf +``` + +### Add as alias + +Put the following line into `~/.bashrc` or `~/.zshrc`: + +```bash +alias dpsprep='docker run --rm -u $(id -u):$(id -g) -v $(pwd):/files dpsprep' +``` + +This will allow you to run the command as `dpsprep` without needing to specify the Docker command each time.