Datagrunt 4.6.32: Stricter Image Checks in PDF Extraction

November 2, 2026by Martin Graham

Datagrunt 4.6.32 tightens how PDFReader and PDFWriter handle embedded images before decoding them. Upgrading is recommended for everyone who reads PDFs.


What changed

JPEG 2000 images were already checked before decoding. From 4.6.32 (#431), JBIG2 images and images with unreadable filters are checked too:

  • JBIG2 images: Datagrunt reads a JBIG2 image’s segment headers before decoding it.
    • Generic-region JBIG2, the usual output of black-and-white scanners, decodes and renders as before.
    • An image that uses JBIG2 symbol dictionaries, text regions or /JBIG2Globals is not decoded. It is skipped with a warning naming its page and image.
  • Page renders: a document that holds such an image is not rendered (render_pages_as_images, and OCR of its scanned pages), and a warning says why. This is how documents with unchecked JPEG 2000 images were already handled.
  • Unreadable filters: an image whose filter list can’t be read is skipped with a warning, rather than decoded as if unfiltered.
  • Both engines: the pdfium engine decodes a JBIG2 image only when PyMuPDF reads the same image the same way, so the two engines agree on what is checked.

Each page’s own text layer is extracted as before, and output on documents without such images is unchanged. No code changes are needed.

If a document you process is skipped this way, the page warnings in to_dicts() name the image and the reason.


Upgrading

uv pip install --upgrade datagrunt