Images to PDF without quality loss: how JPEG embedding works
Many image-to-PDF tools re-compress your photos. How a PDF can carry a JPEG byte for byte, how to check that yours does, and what happens to PNG and other formats.
Put a 2.4 MB photo into a PDF and you might get a 600 KB PDF that looks soft, or a 9 MB PDF that looks the same. Neither is necessary. A PDF can carry a JPEG exactly as it is.
JPEG inside PDF
PDF supports JPEG natively, with a filter called DCTDecode. The image object in the PDF can hold the JPEG file's compressed bytes unchanged, and the reader decodes it like any JPEG. So the honest way to put a JPEG in a PDF is to copy its bytes in. Same pixels, same size, plus a few hundred bytes of PDF structure.
Tools that decode the JPEG to pixels and then encode it again lose quality each time (generation loss), and usually change the size too.
What the JustAPI API does
The Image to PDF API embeds baseline and progressive JPEGs byte for byte. For other formats:
- PNG, GIF, BMP, TIFF: stored losslessly, with Flate compression, as PDF does for any lossless image.
- WebP: decoded and stored losslessly, because PDF has no WebP filter.
- CMYK JPEGs: also embedded as they are.
How to check any tool
- Take a JPEG and note its size.
- Convert it to a one-page PDF.
- The PDF should be the JPEG's size plus 1 to 2 KB. Much smaller means it was re-compressed; much larger means it was decoded and stored raw.
You can also extract the image from the PDF with a tool like pdfimages -all and compare its checksum with the original.
When you want smaller
Sometimes you do want a smaller PDF, for email. Do that on purpose, before the join: resize the photos with the image optimization API to the width you need, then combine. Or compress the finished PDF with the PDF compression API. Either way you choose the trade.
The free JPG to PDF tool uses the same embedding; try the size check on it.