If you size an image-extraction job by counting inline images, the way you count matters more than you would expect. On about 887 PDFs from one work Mac, counting images whose xref is 0 in PyMuPDF reported 52 files with 1,691 inline images. pdfimages -list reported 0 files with inline images on the same set. Every spot check that could be traced pointed at the first number being wrong.

All numbers come from one Apple-silicon Mac, one pass per counting method. The census ran over PDFs already on that machine (everyday documents, downloads and test samples, first 150 pages of each); only counts and generator fields were recorded, no text was read. Of the 887 files, 884 were read by the PyMuPDF method; why three were skipped was not checked. The small test PDFs, T1 to T4, were written by hand for this comparison. The one photo in them is cropped from Bonnie Moreland's "Lake Mountain Landscape" (Wikimedia Commons, CC0), and nothing else in them is third-party.

What an inline image is, in two lines

Most images in a PDF are XObjects: they have an object number, and the page content only says /Im1 Do. An inline image sits inside the content stream itself, between BI and EI, with no object number. That second kind is what a count of xref == 0 is meant to find; xref == 0 is how PyMuPDF's get_image_info(xrefs=True) labels an image block with no object behind it.

The two counts side by side

Table comparing the PyMuPDF xref equals 0 count with the pdfimages inline count over the same PDFs, with three spot-check notes below

The figure to read is the two coloured rows: 52 and 1,691 in red for xref == 0, 0 and 0 in green for pdfimages. The grey line at the bottom is the limit of the whole experiment, covered below.

What the spot checks showed

The false hits were traceable. A CC BY 4.0 brochure from Creative Commons Indonesia (Wikimedia Commons) got one xref == 0 "image" of 517×12 on page 2, yet none of its content streams contains a BI. That a gradient or shading was reported as an image block is a guess (inference); the cause was not checked. Two PDFs made with the browser's print-to-PDF were reported with 342 and 76 xref == 0 images, and the first page of each has zero BI in its content stream. In the one browser-printed test file, all six 32×32 icons were XObjects, not inline.

The error also runs the other way. In T4, an inline stencil mask whose bytes match an XObject mask was labelled xref=1, so the xref == 0 count came out at 1 where pdfimages listed 2.

Searching for BI is not a fix either

Counting BI keywords in decompressed streams is the other shortcut. On T3 it found 18, while the real number is 16. The two extra came from a text string in the page that contains the words "(BI ... ID ... EI)", so the difference of 2 is 18 minus 16, not a separate measurement.

File xref == 0 pdfimages [inline] BI in streams
T1 2 2 2
T2 6 6 6
T3 16 16 18
T4 1 2 2
R1 (brochure) 1 0 0
R2, R3, R4 0 0 0

On the hand-written files the three methods mostly agree; the big mismatch (52 files against 0) only showed up on the existing PDFs.

A cheap cross-check

Treat a number from any one method as a lead. A check that costs one subprocess call is to count the tags pdfimages prints, and compare with your own count per file. This is an illustration, not the script behind the table above:

import subprocess def inline_count(pdf): out = subprocess.run(["pdfimages", "-list", pdf], capture_output=True, text=True).stdout return out.count("[inline]") # any file where this disagrees gets a manual look 

Assumptions behind this habit, not measured here: that pdfimages is the better judge on files like these (it was the one whose zero held up in the spot checks), and that a disagreement is worth a manual look before it goes into an estimate or a go/no-go decision.

How common are inline images, really

On this machine, 0 of 887 files. That says nothing about TeX output, old scanners or fax software, which were not in the set. The usual claim that inline images show up around icons, formulas and chopped-up scans is something this run neither supported nor ruled out, so no ratio is given here.

For a quick look at one file without scripting, ImgIng ( https://imging.ai/ ) is one option in a desktop browser. On the four test PDFs, the ordinary inline images came out as files, and the 903-byte inline JPEG in T2 matched the bytes between its ID and EI exactly, the same as the pdfimages and pypdf exports. ImgIng was not part of the census.