How JPEG Images Are Embedded in PDF Files Without Recompression
PDF objects, the DCTDecode filter, points versus pixels, and why some images must be re-encoded before they can be placed on a page.
Primary Browser Tool
Image to PDF Converter
Combine JPG, PNG, and WebP images into a single PDF with page size, orientation, margin, and fit controls.
A PDF Is a List of Numbered Objects
Internally, a PDF is a collection of numbered objects followed by a table that records the byte position of each one. A catalog object points to a page tree; each page object states its size and which resources it uses; a content stream holds drawing instructions; and image objects hold picture data.
An image-only PDF needs just three objects per page: the page, a one-line content stream, and the image. That is why the PDF is only a few hundred bytes larger than the images it contains.
DCTDecode: JPEG Is a Native PDF Format
PDF image objects declare a filter that tells the reader how their data is compressed. One of the standard filters, DCTDecode, is JPEG. A complete JPEG file can be placed inside an image object as it is, and every PDF reader will decode it with its own JPEG decoder.
RapidPNG uses this for ordinary JPEGs: it reads the width, height, and number of color channels from the file’s frame header, writes those into the image object’s dictionary, and copies the file’s bytes into the stream. No pixel is decoded or re-encoded, so there is no quality loss and the operation is nearly instant.
- One channel is declared as DeviceGray, three as DeviceRGB.
- Both baseline and progressive JPEGs qualify.
- Four-channel (CMYK) JPEGs and other unusual variants are re-encoded instead, to avoid inverted or wrong colors in some readers.
Points, Pixels, and Placement
PDF measures pages in points, 72 to the inch. An A4 page is 595.28 × 841.89 points and US Letter is 612 × 792. An image has no inherent physical size; the content stream scales it into a rectangle on the page. The tool computes the largest rectangle that fits within the margins while keeping the image’s proportions, and centers it.
With “Fit each page to its image”, the page takes its size from the image at 0.75 points per pixel, which corresponds to 96 pixels per inch. The effective print resolution of any image is simply its pixel width divided by its printed width in inches.
| Image width on an A4 page with small margins | Effective resolution |
|---|---|
| 1000 px | About 132 ppi: fine on screen, soft in print |
| 1600 px | About 211 ppi: good for documents |
| 2400 px | About 316 ppi: photo-quality print |
Why Some Images Are Re-Encoded
Three kinds of input cannot be embedded directly. PNG, WebP, GIF, and AVIF are not JPEG, so they are drawn on a white background and saved as JPEG at the chosen quality. JPEGs with an EXIF orientation other than “normal” are redrawn upright, because PDF readers do not apply that flag and the page would otherwise appear rotated. And non-standard JPEG variants are redrawn for compatibility.
Practical Examples
Ten scanner JPEGs
Total input 6.20 MB; the PDF is 6.20 MB plus about 3 KB of structure. Every page is bit-for-bit the scanner’s original JPEG.
Common Mistakes & Honest Limitations
Mistakes to Avoid
- Assuming every image-to-PDF conversion degrades quality. Direct JPEG embedding does not.
Technical Limitations
- Transparency is not carried into the PDF; transparent areas are flattened to white before encoding.