How does JPG to PDF conversion work here?
JPG to PDF conversion wraps a JPEG image inside a PDF page so it can be sent, printed or merged like any other document. This tool creates a one-page PDF with pdf-lib, sizes the page to match the image, and embeds the original JPEG data unchanged. It runs in your browser and produces image.pdf.
The "unchanged" part is worth explaining, because it's why the result looks exactly like your photo.
Your JPEG goes in untouched
The PDF format can store a JPEG image as-is and let the viewer decode it, using a filter called DCTDecode (ISO 32000-1, section 7.4.8). pdf-lib takes that route: it reads the image's width, height and colour mode from the JPEG header, then copies the whole file into the PDF. We checked this by converting two test images and finding each original file's exact bytes inside the output PDF.
That has three consequences:
- No quality loss. There's no decode and re-encode, so no new compression artefacts.
- Predictable size. The PDF is the JPEG plus a little under 1 KB of PDF structure. In our tests a 715-byte image produced a 1,645-byte PDF and a 1,457-byte image a 2,388-byte one.
- Metadata comes along. Everything inside the JPEG file travels with it, including EXIF data such as camera model, timestamp and GPS coordinates. If you're sharing a photo taken at home, check it with the EXIF viewer and strip it with the EXIF remover before converting.
Greyscale, RGB and CMYK JPEGs are all accepted, as are progressive JPEGs.
Page size follows the pixels
The page is set to the image's pixel dimensions in PDF points, and a point is 1/72 inch. Any DPI value stored in the JPEG is ignored. Some examples:
| Image | Pixels | Page size |
|---|---|---|
| Instagram portrait post | 1080 x 1350 | 15 x 18.75 in |
| A4 scanned at 300 dpi | 2480 x 3508 | 34.4 x 48.7 in |
| US Letter scanned at 150 dpi | 1275 x 1650 | 17.7 x 22.9 in |
| 12-megapixel phone photo | 4032 x 3024 | 56 x 42 in |
Big numbers, but they rarely cause trouble on screen: PDF viewers open the page zoomed to fit. They matter when printing. Choose "Fit to page" or "Shrink to fit" in the print dialog, otherwise you'll print one corner of a 56-inch page. If you need a PDF that prints at true A4 or Letter size out of the box, this tool isn't the right one, since it has no paper-size or margin options.
Step by step
- Click Choose a JPG image and select a
.jpgor.jpegfile. - Click Convert.
- Click Download to save
image.pdf. - For more photos, repeat, renaming each download, then combine them with the PDF merger.
Sideways photos
Phones often store a portrait photo's pixels sideways and add an EXIF orientation tag saying "rotate 90 degrees when displaying" (CIPA DC-008, the Exif standard). Your gallery app obeys the tag. pdf-lib only reads the JPEG's frame header and never looks at EXIF, so the PDF shows the raw pixel layout and the photo can appear on its side.
Two fixes:
- Before converting: run the photo through the EXIF remover. It redraws the image through a browser canvas, and current browsers apply the orientation tag when they decode, so the saved pixels come out upright with no tag. The trade-off is one JPEG re-encode at quality 0.95.
- After converting: turn the page with Rotate PDF, which is lossless.
Errors
| Message | Cause | Fix |
|---|---|---|
| "Choose a JPG image." | No file chosen, or the file isn't an image | Pick a JPEG file |
| "Could not convert that image: SOI not found in JPEG" | The file isn't actually a JPEG, often a PNG or WebP renamed to .jpg |
Use PNG to PDF for PNGs, or convert other formats to JPG first |
| "Could not convert that image: Invalid JPEG" | The file is truncated or damaged | Re-export or re-download the image |
There's no file size limit in the code, but the image is held in memory as base64 text during conversion, so very large files are bounded by your device's memory.
Last updated