← All Tools

Why Does Converting Images to PDF Increase File Size? The Canvas Re-encoding Trap

Guide · Last verified Aug 28, 2026

If you've converted a single photo to PDF and been surprised that the file ended up bigger than the original, the tool isn't broken. The word "convert" makes you expect compression, but wrapping a file in PDF is not, by itself, a compression step. Depending on the image format, there's a hidden stage that fully re-encodes the original — and that's exactly where the size can balloon.

1. PDF conversion is "packaging," not compression

PDF isn't a format that compresses images — it's a container format that wraps image data inside its own structure of page objects, coordinates, and resource dictionaries. Whether the original image data is embedded as-is or re-encoded first, PDF's own structural overhead (xref table, page tree, stream headers, etc.) always gets added on top. In other words, the "image → PDF" conversion step itself has no logic built in to shrink the file. The final size depends entirely on how the image data gets inserted into the PDF.

2. Completely different insertion paths depending on format

Looking at the actual source code of this site's image-to-PDF converter, the insertion path splits completely depending on the file type.

JPEG (image/jpeg): The raw bytes read from the file are passed directly to pdf.embedJpg() and inserted into the PDF. There's no separate re-encoding or recompression step, so both quality and file size stay almost identical to the original.
PNG · GIF · WebP · BMP: The image is first loaded via an <img> tag, drawn onto an HTML5 canvas, and then canvas.toBlob(..., 'image/png') generates a brand-new, freshly-encoded lossless PNG, which is what actually gets inserted with pdf.embedPng(). In other words, it's not the original file but a PNG the browser just encoded on the spot that ends up in the final PDF.

3. Why the size inflates at exactly this step

The problem is that the browser Canvas API's PNG encoder doesn't optimize compression as aggressively as dedicated tools (pngcrush, oxipng, ImageOptim, etc.). Canvas is faithful about storing pixel data losslessly, but it often skips post-processing optimizations like filter selection or zlib compression-level tuning. On top of that, if the original GIF or WebP file was already fairly small thanks to lossy compression (WebP) or a limited color palette (GIF, max 256 colors), unpacking it into a truecolor lossless PNG can noticeably inflate the size. GIF in particular is palette-based and compresses well by nature — and that advantage commonly disappears entirely once it's re-encoded as PNG.

4. What you'll actually notice: which combinations are risky

Original formatPDF insertion methodSize-increase risk
JPEGRaw bytes embedded as-is (embedJpg)Low — nearly identical to original
PNGVia canvas → re-encoded PNG (embedPng)Medium — depends on original PNG's compression level
GIFVia canvas → converted to truecolor PNGHigh — loses palette-compression advantage
WebPVia canvas → converted to lossless PNGHigh — loses lossy-compression advantage

Also, since PDF has no concept of animation, an animated GIF only gets its first frame inserted, no matter how many frames it originally had. And if you're combining multiple images into one PDF, keep in mind the size increase from the table above compounds across every image.

5. If file size matters, do this

Frequently Asked Questions

Q. Why does JPEG barely change in size?

A. Because JPEG isn't redrawn and re-encoded — the original compressed bytes are inserted directly into the PDF as-is. Since there's no recompression or re-encoding step at all, both quality loss and size increase are minimized.

Q. It's just PNG to PNG — why does the size change at all?

A. It's not a literal "PNG to PNG" copy. The pixels are redrawn onto a canvas and the browser's PNG encoder compresses them from scratch. If the original PNG was already well compressed, the re-encoded result can actually end up larger.

Q. Does an animated GIF become an animated PDF?

A. No. PDF is a static document format with no concept of animation, so only the first of the multiple frames gets inserted as a still image.

Q. What's the best order of operations to keep file size down?

A. For photographic images, saving as JPEG first and then converting to PDF is the most reliable approach. If you've already created a large PDF, running it through a separate PDF compression tool afterward is another option.