How pictures are stored inside a PDF, and why some come out as PNG

What an image object in a PDF is, why a JPEG comes out untouched but other pictures become PNG, and why a logo used on every page is listed only once.

Open the Extract PDF images Free, in your browser, nothing uploaded.

A PDF looks like a printed page, but inside it is a set of instructions: draw this text here, this line there, and paint this picture in that box. The pictures are kept as separate objects, so they can be taken back out whole, often at a higher resolution than the page shows. This article explains how those objects work and what Extract PDF images does with each kind. To turn whole pages into pictures instead, use the file converter; to shrink or crop what you saved, the image resizer; and to make the PDF itself smaller, file compressor.

What it is

A PDF page has a content stream, a list of drawing commands, and a resources list that names the things the commands use: fonts and XObjects (“external objects”). An XObject with the subtype Image is a picture: a width and height in pixels, a colour space (grey, RGB or CMYK), and the pixel data, packed with a filter.

The filter decides what the tool can do:

  • DCTDecode is JPEG. The bytes inside the PDF are a complete JPEG file, so the tool saves them exactly as they are, with no loss and no re-compression.
  • JPXDecode is JPEG 2000, also saved as it is, as a .jp2 file.
  • FlateDecode is plain pixels squeezed with the same method as ZIP files, sometimes after a “predictor” that stores each row as differences from the row above. The tool unpacks the pixels, undoes the predictor and writes a new PNG, adding a soft mask, if there is one, as the see-through channel.
  • CCITT fax and JBIG2 are used for black-and-white scans. They are listed but cannot be rebuilt in the browser.

Two more facts explain most surprises. First, a picture is stored once and drawn by reference, so a logo on every page is a single object; the tool lists it once with all its pages. Second, the page decides the displayed size, crop and rotation. A 2,000-pixel photo shown in a 5 cm box is still 2,000 pixels inside the file, and that is what you get back.

Raw pixels take width × height × channels bytes: a 2,000 × 1,500 RGB picture is 2,000 × 1,500 × 3 = 9,000,000 bytes, about 8.6 MB, before any packing.

How to use it

  1. Open the tool page and choose a PDF. It is read on your device; nothing is uploaded.
  2. Wait for the list. Each card shows a preview, its number, the page or pages it appears on, its size in pixels and its format.
  3. Use Skip pictures smaller than (64, 200 or 500 pixels wide) to hide bullets, lines and icons.
  4. Press the download button on a card to save one picture.
  5. Press Download all as a ZIP to save every picture still shown.

A worked example

We built a 4-page leaflet in Node: a 240 × 80 logo with soft edges on every page, a 1,200 × 800 photo on page 2, a 2,000 × 1,500 photo on page 3, and a 32 × 32 bullet icon on pages 1 and 4. The photos were placed as JPEGs, the logo and icon as PNGs.

  • The tool finds 4 pictures in the 4 pages, not 8 placements: the logo is listed once, on pages 1, 2, 3, 4, and the icon once, on pages 1, 4.
  • The two photos come out as image-03-page-2.jpg and image-04-page-3.jpg, byte for byte the JPEG data that went in.
  • The logo is rebuilt as image-01-page-1.png, with its see-through edges kept, in 621 bytes. The icon becomes a 96-byte PNG.
  • With Skip pictures smaller than 64 pixels wide, the icon is hidden and 3 pictures remain; at 500 pixels only the 2 photos remain.

Had the 2,000 × 1,500 photo been stored as raw RGB pixels instead of JPEG, the PNG would start from 9,000,000 bytes of data, and how small it ended up would depend entirely on the picture.

Checked with the tools

The example PDF was made with pdf-lib, then read by the tool’s own listImages() and imageFile() in src/lib/docs/pdfimages.ts, which gave the counts, page lists, file names and PNG sizes above. The photos were small JPEG stand-ins with the right pixel sizes, so their file sizes are not quoted.

The chart uses the tool’s own PNG writer, encodePng(), on square test pictures. A smooth fade packs down to a few KB; random noise cannot be packed at all and is as big as the raw pixels. Real photos fall between, which is why a photo saved as PNG can be many times bigger than the PDF it came from.

How big the saved PNG isHow big the saved PNG is05001e+31.5e+3200400600800Picture width and height (pixels, square)File size (KB)Raw pixels (w x h x 3)PNG of random noisePNG of a smooth fadefibub.com
Size of the PNG file the tool writes (its own encodePng) for square test pictures, against the raw RGB pixel count. Noise cannot be squeezed; smooth areas shrink a lot. Made-up test pictures, not real photos.

Where it is used

  • Design and marketing. Recover a logo or product photo from a brochure when the original files are lost.
  • Research. Pull microscope images or photos out of a paper’s PDF to look at them closely (respect the paper’s licence).
  • Scanned documents. A scanned PDF usually holds one picture per page, so extracting gives back the page scans.

Common mistakes

  • Expecting charts and diagrams. Charts drawn as lines and text are not pictures, so they are not listed. Convert the page to an image instead.
  • Thinking a picture is missing. A logo used on 20 pages appears once. Read its page list.
  • Assuming the PNG is smaller. Photos stored as raw pixels make large PNGs. Shrink them afterwards, or save as JPG with an image tool.
  • Expecting the page crop. Cropping, rotation and masks applied by the page are not baked in. Crop the saved picture yourself.
  • Using pictures you do not own. Extracting is easy; reusing is a copyright question. Ask the owner.

Questions people ask

Why is the picture bigger than it looks on the page? The page scales it down to fit its box. The file keeps all the pixels it was given.

Can it rebuild a JPEG at better quality? No. A JPEG comes out exactly as stored. Quality lost when the PDF was made cannot be recovered.

Sources

  • PDF image objects (XObject, Subtype Image), the DCTDecode (JPEG), JPXDecode (JPEG 2000) and FlateDecode filters, and the PNG-style predictors are defined in ISO 32000-1:2008 sections 7.4 and 8.9. The PNG file format is the W3C PNG specification. Checked 2026-12-05. Check the official source for the full text.

If you are an author or publisher and want a credit or a passage changed or removed, tell us and we will act quickly.

Tools in this article

Read next