Hacker News new | past | comments | ask | show | jobs | submit login

This:

When you need full color, but don’t need transparency, use JPEG instead.

implies that pixel-perfect results (non-lossy compression) is never desirable for images with full color, which I find to be a very provocative simplification.

On the other hand, on the web in general, perhaps it is good advice as a "rule of thumb" for people who aren't likely to deal with images where each pixel really matters.




You can set JPEG compression levels such that it's lossless, which gives a filesize not dissimilar to PNG.


> You can set JPEG compression levels such that it's lossless

No you can't. You can use Lossless JPEG instead, but regular JPEG (or JPEG2000) is a lossy format period.

edit: as tspiteri points out, JPEG 2000 does have a lossless mode. My bad. JPEG still does not though.


There are actually two lossless JPEG modes even ignoring JPEG-2000: JPEG-LS and LJPEG. I don't know how widespread support for either is, but ffmpeg can encode to both. It confused the crap out of me a few months ago when I was trying to fix a bug and realized that the two were actually totally different formats.

The latter seems to be older and part of the original spec, while the former seems to be newer and a lot less bad.


These are not modes, they're different formats (like very, very different) using the same name.

And yes, LJPEG is the "complete crap" version which predates (and was blown away by) PNG, JPEG-LS is a second take on a lossless jpeg format.


I don't know about JPEG, but JPEG2000 definitely has a lossless mode.


> JPEG still does not though.

You're right in practise (AFAIK, libjpeg still doesn't support this mode), but see http://en.wikipedia.org/wiki/Lossless_JPEG


I will simply quote myself:

> No you can't. You can use Lossless JPEG


Duh. missed that one.


Did he mean it literally, or just that you can fiddle with compression until you don't notice any artefacts? At that point, it's as good as lossless for most uses, IMHO.


> At that point, it's as good as lossless for most uses, IMHO.

It's not, and the size of the file blows up to insane levels.


Could you then give me a common use where a loss not noticeable to the human eye is, in fact, important?


When saving and closing an image, only to realize you need need to change something, thus necessitating a second save, which compounds loss. Granted, if you keep a lossless file around to edit, your problem is gone. But does everyone really do that with every file?


That's the only one I could imagine encountering, and if I've not saved the original, serves me right AFAIC.

But then, if I save the second with a higher-than-otherwise-optimal setting, then I can reduce the compounding of effects. It's cost me filesize to limit loss to the imperceptible, but it's still possible.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: