"Extract the images from this PDF" sounds like one task. It can mean at least four different tasks, and the libraries answer different ones. This note walks through one small test file where that difference shows up as a concrete number: 903 bytes against 901.
Scope of the test
The observations come from a single Apple-silicon Mac with each method run once. The inputs are two kinds of file. T1 to T4 are four hand-written PDFs; their single photo is a crop taken from the CC0 file "Lake Mountain Landscape" (Bonnie Moreland, Wikimedia Commons); the rest is synthetic. The fifth input is a self-made 6-page A4 product catalog with 8 images, whose product photos are crops of the same CC0 picture. The tools are poppler's pdfimages, PyMuPDF, pypdf 6.10 and the browser tool ImgIng at https://imging.ai/ , which runs on desktop browsers, needs no sign-up and was used as a black box. Treat the results as observations about these files only.
Two ways a PDF stores a picture
One form is the XObject: a numbered object that the page refers to by name, such as /Im1 Do. The other is the inline image, where the pixel data sits directly in the content stream between the keywords BI, ID and EI. Nothing numbers it, and its dictionary uses short key names (/W, /H, /CS, /F and so on). T2, the file used most below, holds six inline images next to a single XObject, and one of the six is nested in a Form XObject, which matters later.
Meaning one is to list what exists
If "extract" means "tell me how many images this page has", the tools already disagree on T1, which holds one XObject and two inline images.
| Tool and call | What it returned on T1 |
|---|---|
| pdfimages -list | 3 entries, inline ones marked [inline] |
PyMuPDF page.get_images() | 1 entry, both inline images missing |
PyMuPDF get_image_info(xrefs=True) | 3 entries, inline ones with xref 0 |
PyMuPDF get_text('dict') image blocks | 3 entries |
pypdf page.images | 3 entries, inline ones with keys like ~0~ |
One explanation for the get_images() result is that it only covers the page's XObject resources, which never contain inline images. That explanation is an inference about the design, not something traced in the source.
On T2, pypdf returned 11 keys. Each of the five inline images on the page showed up twice, and the image nested in the Form XObject was absent. Asking for ['/Fm1', '~0~'] gave back the 32×32 JPEG from the page. That describes pypdf 6.10 on this one PDF, not the library.
Meaning two is to get the stored bytes
For a JPEG, "the stored bytes" means the exact sequence that sits in the PDF, so the result can go straight into a print workflow without a second lossy pass. T2 has one inline JPEG whose data section, from ID to EI, is 903 bytes long. Each exported file was compared with that raw segment of the stream.
| Source of the file | Size | Same as the bytes in the PDF |
|---|---|---|
| pdfimages (listed as jpeg, 903 B) | 903 | yes |
| pypdf image object | 903 | yes |
| ImgIng export | 903 | yes |
PyMuPDF get_text('dict') image block | 901 | no, different hash |
The two-byte gap is computed from the table (903 minus 901). The reason was not checked. One guess (inference) is that the dict block is a re-wrapped JPEG rather than a copy of the stream, but that is untested. Whether it looks the same on screen was not checked; what the comparison shows is that only three of the four files are the PDF's own data.
Meaning three is decoded pixels
Some jobs do not care about the container. A 16×16 RGB inline image in T1 is stored with /F /Fl, which is Flate compression, and the useful output is the 768 decoded bytes (16×16×3).
The same gap shows up with PNG. On the catalog, pdfimages -png wrote 26 PNG files totalling 38,589,909 bytes, none identical to the stored data, while the stored originals added up to roughly 5.4 MB. That is about 7 times larger (computed from 38.6 MB against 5.4 MB, not a separate measurement). Decoding a JPEG and saving it as PNG is a re-encode of the pixels, so it carries the picture but not the stored bytes; how a print workflow reacts to that was not tested.
Meaning four is what is drawn
A fourth reading is "the images that appear on the page". The catalog stores 8 images and the pages draw them 19 times, so counting by storage and by drawing gives different answers. Shortcuts for counting are fragile too. In T3, searching the decompressed streams for BI finds 18 hits, while the real number of inline images is 16: the extra two are the letters inside a text string. On a work computer holding about 887 PDFs, pdfimages found 0 inline images, but PyMuPDF's xref == 0 rule flagged 52 files and 1,691 images. The spot checks turned out to be false positives, probably gradients or shadings (inference). So "xref is 0" is not a safe definition of "inline".
A decision table
| Your next step | Which meaning | A reasonable starting point |
|---|---|---|
| Inventory or audit | List | pdfimages -list, then compare with a second tool |
| Print, re-layout, archive | Stored bytes | pdfimages -all, pypdf, or a tool that keeps the stream; verify with a hash |
| Feed a model or resize | Decoded pixels | a library that decodes the stream (not compared here) |
| Show what readers see | Drawn result | render the page; the simulated screenshot route gave 605×403 for a 3000×2000 image |
What the test did not cover
The mature libraries read the abbreviated keys of T1 to T4 correctly; writing a parser of your own is a different question and is not covered here. Not tested: Type 3 glyph images, /DP predictors, LZW and run-length inline filters, and PDFs from TeX or old scanners.

