TL;DR
A photo can't be stored losslessly for cheap: the smallest lossless copy of my test photo was 2.4 MB, 4.4 times its original JPEG. Resized to 1600 px and saved as JPEG at quality 75, it came to 232 KB and scored 81 on SSIMULACRA 2. Lossless is for screenshots, text and files you'll edit again.
I'm adding photo uploads to an app I built for a painting company. Staff walk a site, measure each wall and photograph it, and the photos go to the office for approval. They'll land in Vercel Blob, whose free plan includes 1 GB of storage.
Before writing the upload code, I did the arithmetic. My test photo is the flower from the JPEG XL project's test images: 3.4 megapixels, saved as a 547 KB JPEG. Stored as it is, at 100 photos a week, five site visits of twenty photos each, the free gigabyte is full in week 19. Most phones save 12 megapixels or more, so their files are bigger and that week comes sooner. Vercel doesn't bill a free account for going over. It shuts Blob off for 30 days, which makes that the week the app needs a paid plan.
So before shipping, I measured what each kind of compression keeps, and what it costs to keep it.
Two ways to make a file smaller
Every image format does one of two things, or both.
Lossless compression finds patterns and writes them down more briefly. Neighbouring pixels tend to be alike, so the encoder guesses each pixel from the ones around it and stores only how wrong the guess was. Small errors take few bits. Decode the file and every pixel comes back exactly.
Lossy compression decides that part of the picture isn't worth keeping. It rewrites the image as layers of coarse and fine detail, then rounds off the fine detail the eye is least likely to miss. That rounding is the only step that loses anything, and it's the step the quality setting controls.
Lossless
- Guess pixels
- Keep errors
- Pack the bits
Lossy
- Split detail
- Round it off
- Pack the bits
Visually lossless is lossy compression tuned until nobody can see the rounding. It isn't a format or a setting. It's a claim about people, and it has a test: show viewers the original and the compressed image in the same place, swapping between them, and count how often they spot the difference. ISO/IEC 29170-2 standardises that procedure. SSIMULACRA 2, the quality score used below, calls 90 visually lossless and defines it the same way: "not noticeable by an average observer in a flicker test at 1:1 from a normal viewing distance." At 80 you can't tell them apart side by side. At 70 you can just about tell, if you look.
A lossless photo stays big
Lossless can only remove what is predictable, and a photo isn't very predictable. Every pixel carries a little sensor noise, and noise is random by definition. A lossless encoder has to store all of it. Claude Shannon put a floor under this in 1948: no lossless code can average fewer bits than the information actually in the source.
In practice that floor sits high. In David Barina's comparison of lossless formats, the two best, FLIF and JPEG XL, kept photos at about 9.4 bits per pixel. Raw is 24. So a lossless photo is still around 40% of its raw size.
One photo, KB
Raw pixels
10,288 KB
- JPEG XL lossless
2,395 KB - Original file
547 KB - In the app
232 KB
The original had already made its call. 3.4 million pixels are 10 MB raw, and its JPEG keeps them in 547 KB, because JPEG is lossy. Ask for the same pixels losslessly and the best you get is 2.4 MB.
The trap is converting a JPEG to PNG "to keep the quality". The quality is already gone. The PNG keeps every pixel the JPEG decoder produced, rounding artefacts included, and pays for each one as if it were detail: 547 KB became 4.4 MB, 8.0 times bigger. If a file is already a JPEG and you want it smaller without losing a bit, JPEG XL can repack the JPEG's own data more tightly and hand back the original file byte for byte. That took this one to 456 KB, 17% smaller.
Which lossless format is smallest
Each format below ran at its slowest, strongest setting, and every file was checked to decode back to exactly the same pixels.
The photo, 2268 × 1512
A screenshot of a post, 2560 × 1600
On the photo, JPEG XL was smallest and PNG biggest. The screenshot nearly flipped the order at the top: WebP 29 KB, JPEG XL 31 KB, close enough to call a draw. AVIF, at 133 KB, lost even to PNG.
On photos that matches Barina's results, measured with older encoders: JPEG XL second only to FLIF, whose developers stopped work on it in favour of JPEG XL, and AVIF at or near the bottom on photos, illustrations and scanned books. AVIF comes from a video codec built for lossy frames, and its lossless mode shows it.
The first screenshot I took had this site's paper grain switched on, a faint noise texture over the whole page. It made the lossless WebP 12 times bigger and the JPEG XL 72 times bigger, 2.3 MB. Noise doesn't have to come from a sensor to cost bytes. WebP suffered least because the grain is one small tile repeated across the page, and WebP's lossless mode is good at finding exact repeats.
The smallest format isn't automatically the one to ship. As of November 2026, JPEG XL decodes in Safari since version 17, Chrome since 155 and Firefox since 158, but not yet in Edge or Samsung Internet. WebP works everywhere current. For lossless on the web today, I'd serve WebP and add JPEG XL as an upgrade for the browsers that take it.
How much loss you can see
Lossless is the wrong tool for photos people will look at on a screen. Here is the original against what I'd store instead.


At the size anyone will view it, the two are the same picture. The difference only shows when you zoom in, so the figure below does: a 312 × 208 px crop at 2×, every pixel drawn as four. Pick a format and a quality and compare.


- Size
- 232 KB
- Score
- 81, very high
- Vs original
- 2.4× smaller
JPEG quality 75: 232 KB, SSIMULACRA 2 score 81, very high.
SSIMULACRA 2 against file size, every step of every format
| Format and setting | Size | SSIMULACRA 2 |
|---|---|---|
| JPEG quality 20 | 80 KB | 38 |
| JPEG quality 30 | 107 KB | 55 |
| JPEG quality 40 | 130 KB | 64 |
| JPEG quality 50 | 151 KB | 70 |
| JPEG quality 60 | 174 KB | 74 |
| JPEG quality 70 | 210 KB | 79 |
| JPEG quality 75 | 232 KB | 81 |
| JPEG quality 80 | 268 KB | 83 |
| JPEG quality 85 | 316 KB | 86 |
| JPEG quality 90 | 399 KB | 89 |
| JPEG quality 95 | 566 KB | 91 |
| WebP quality 20 | 61 KB | 44 |
| WebP quality 30 | 73 KB | 52 |
| WebP quality 40 | 85 KB | 58 |
| WebP quality 50 | 97 KB | 63 |
| WebP quality 60 | 112 KB | 68 |
| WebP quality 70 | 125 KB | 70 |
| WebP quality 75 | 131 KB | 72 |
| WebP quality 80 | 164 KB | 77 |
| WebP quality 85 | 210 KB | 81 |
| WebP quality 90 | 289 KB | 85 |
| WebP quality 95 | 439 KB | 89 |
| AVIF quality 20 | 31 KB | 35 |
| AVIF quality 30 | 43 KB | 50 |
| AVIF quality 40 | 61 KB | 63 |
| AVIF quality 50 | 91 KB | 73 |
| AVIF quality 60 | 135 KB | 79 |
| AVIF quality 70 | 186 KB | 83 |
| AVIF quality 75 | 215 KB | 85 |
| AVIF quality 80 | 253 KB | 87 |
| AVIF quality 85 | 291 KB | 89 |
| AVIF quality 90 | 401 KB | 91 |
| AVIF quality 95 | 599 KB | 93 |
| JPEG XL distance 8 | 60 KB | 54 |
| JPEG XL distance 6 | 74 KB | 62 |
| JPEG XL distance 4 | 100 KB | 72 |
| JPEG XL distance 3 | 124 KB | 77 |
| JPEG XL distance 2 | 178 KB | 83 |
| JPEG XL distance 1.5 | 222 KB | 86 |
| JPEG XL distance 1 | 303 KB | 89 |
| JPEG XL distance 0.75 | 377 KB | 91 |
| JPEG XL distance 0.5 | 539 KB | 93 |
- 1
The resize saves more than the quality setting. JPEG quality 75 at the full 2268 px is 467 KB, 1.2 times smaller than the original file. Resizing to 1600 px keeps 50% of the pixels and makes it 2.0 times smaller again.
- 2
Newer formats reach the same score with fewer bytes. JPEG at quality 75 scores 81 in 232 KB. WebP gets there in about 210 KB, AVIF gets there in about 154 KB, JPEG XL gets there in about 159 KB.
- 3
Near the top, every point costs more. Going from quality 75 to 95 makes the JPEG 2.4 times bigger and moves the score from 81 to 91.
How it was measured
- Photo
- 2268 × 1512 JPEG, 547 KB. The flower from the JPEG XL test images, © the JPEG XL Project Authors, BSD-3-Clause
- Resized
- 1600 × 1067, Lanczos, before every encode
- Encoders
- libjpeg-turbo 3.2.0, libwebp 1.6.0, libavif 1.4.2 with aom, libjxl 0.12.0
- Settings
- Defaults, except the quality knob
- Score
- SSIMULACRA 2 against the resized photo, whole image
- Crop
- 312 × 208 px at 644, 429, shown at 2×. Each side is the decoder's output, saved losslessly
Step the quality down and each format fails in its own way. JPEG cuts the picture into 8 × 8 pixel blocks, and at low settings the blocks show. WebP smears fine texture into flat patches. AVIF and JPEG XL smooth texture away but keep edges clean, which is why they hold their scores at sizes where JPEG falls apart.
The same number doesn't mean the same thing across formats. WebP at quality 75 is 131 KB and scores 72, against JPEG's 232 KB and 81. Compare formats by score, never by setting.
What I picked, and why
The app will resize each photo to 1600 px on the long edge and save it as JPEG at quality 75, on the phone, before it uploads. That's 232 KB a photo, 2.4 times smaller than the original, with a score no one will notice side by side.
AVIF would reach the same score in about 34% fewer bytes. I still picked JPEG. Every phone can encode it on the device before upload, the quote PDFs the office sends can embed it as it is, and every browser, gallery and messaging app opens it. The AVIF saving is real, but it's small next to the one already made, and it would cost every place a JPEG simply works.
The JPEG itself can still shrink without changing format. jpegli, Google's newer JPEG encoder, reached the same score in about 198 KB, 15% smaller, and any JPEG decoder opens the result. It needs a native library on the phone, so the app will start with the phone's own encoder.
Photos stored, GB
Original files: 0.055 GB a week, so the 1 GB limit lasts about 4 months. In the app: 0.023 GB a week, so the 1 GB limit lasts about 10 months.
At 232 KB a photo, the same 100 photos a week fill the free gigabyte in week 44 instead of week 19.
When lossless is the right call
Photos are the case lossy compression was built for. Other images break its assumptions.
- Screenshots, UI, text and diagrams. Hard edges and flat colour are exactly what lossless predicts well and lossy handles badly. Rounding off fine detail leaves a speckled halo around every hard edge. As a JPEG at quality 75, my screenshot was 86 KB, 2.9 times the lossless WebP, and it scored 87. Lossy PNG, the trick pngquant uses, cuts the image to 256 colours instead. That came to 40 KB with a score of 99, close to lossless, though lossless WebP was still smaller. On the photo the same trick came to 893 KB and scored 59, because a photo needs far more than 256 colours.
- Anything you'll edit and save again. Each lossy save rounds again, on top of the last rounding. Keep the master lossless and export lossy copies from it.
- Pixels that are measurements. Medical scans, scientific images, maps. When someone will read values off the image, every value has to survive.


Lossless promises every bit back. For a photo, most of those bits are noise the eye was never going to see, and storing them is the most expensive way to keep a picture nobody can tell apart from a far smaller one.