Copied or redrawn
Photographic visual for Copied or redrawn

Copied or redrawn: how a JPEG goes into a PDF unchanged

A PDF can hold a JPEG exactly as it came off the camera. Most converters decode it and compress it again anyway, and every time a JPEG is compressed it loses a little more. Here is when this site copies instead, and how to see for yourself.

Why copying is possible at all

A PDF page can display an image stored in the same compression a JPEG file uses (the PDF name for it is DCTDecode). Scaling the picture to the page, turning it by a right angle and cutting it to a box are all things the page itself does with a matrix and a clipping path. So a photo that only needs those — which is most photos — can go into the PDF as its own compressed bytes, with the metadata segments (camera, date, location) left out. Nothing is decoded and nothing is compressed a second time.

When it has to be redrawn

  • The resolution ceiling is below what the photo carries across its box, so it must be made smaller.
  • Grey pages are on, or the photo is put through document mode.
  • The JPEG is progressive, arithmetic-coded, 12-bit or CMYK — legal JPEG that many PDF readers draw badly.
  • The photo is mirrored by its EXIF orientation (rare), which a quarter turn cannot undo.
  • It carries a wide-gamut colour profile and the colour policy is Screen colour, so it is converted to sRGB rather than misread.
  • A size target can only be reached by lowering it, after the pages already redrawn have been lowered first.

Before you save, the JPG to PDF page shows a live count — “11 of 12 photos will be copied unchanged” — worked out by the same two checks the writer uses. After you save, the receipt and the page table say which pages were copied and which were redrawn, read back out of the finished file.

A worked example: a 63,184-byte JPEG saved through JPG to PDF at “As opened” made a 63,956-byte PDF. Extracted again with pdfimages, the embedded JPEG is 63,166 bytes — the original minus its 18-byte JFIF header — and every byte from the first quantisation table to the end of the file is identical to the original.

Check it yourself

  1. Save a PDF from one untouched JPEG. Add one JPEG, leave the resolution ceiling at As opened, keep grey off, and save. The receipt says how many photos were copied unchanged.
  2. List the images inside the PDF. Run pdfimages -list on the PDF (part of the free Poppler tools). The image is listed with filter DCT and the photo's own pixel size.
  3. Extract the JPEG stream. Run pdfimages -j on the PDF to write the embedded JPEG out as a file.
  4. Compare it with your original. The extracted file is your original with its metadata segments removed: the same pixels, the same compressed bytes for the picture itself, and no camera or location data.

The same check works for any converter: if the extracted image has a different pixel size or a different filter, it was redrawn. For the opposite job — making a file smaller on purpose — see the size-limited builder; for screenshots, where JPEG is the wrong choice entirely, screenshots to PDF writes pages without loss.

Back to the builder