Which is better, PNG or JPG?

I’ve been saving a ton of photos lately, and don’t know much technically. Is one better than the other?

I’ve been saving everything in JPG out of habit, but my PC has a default option of PNG. If JPG is the better option, is there a way to change the default for saving a photo (which would spare me a step), or should I be using PNG or something else altogether?

JPEG is definitely better for photos than PNG (unless you need to make sure every pixel is exact.) You could use a different format that might get you smaller files, but JPEG support is ubiquitous, and can be saved at higher quality than, say, WebP.*

As for how to change the default, you’d need to tell us what program or app you are using. It may or may not be possible to change a setting to default to .jpg.

*Note for WebP fans: yes, WebP does tend to have better lossy compression at equivalent quality. But it lacks the ability to disable chroma subsampling, meaning the colors always get blurry. With JPEG, you can disable chroma sampling.

They’re designed for different things. To many users, such as yourself, the difference is minimal at best.

To get into the technicalities a bit, JPG compresses files at about a 10:1 ratio, and does it by determining which pixels are similar enough to each other they can be grouped together in a “tile,” but the “extra” pixels are then discarded. Every time you open and save a JPG file you lose some information that can’t be recovered. It’s like analog generational loss.

PNG OTOH is lossless, which means the files are generally always going to be larger. They also support transparency where JPG does not. If something has a lot of fine detail or small text, you’ll want to use PNG or the text might become unreadable in a JPG.

I suppose the “raw” or DNG option would be technically best. If you are just going to be viewing them, JPEG could be smaller than PNG, especially if you start cranking up the compression. HEIC, JP2, and so on will be smaller yet.

If file size is not an issue, I save images in tif or tiff format if it’s an option. And then I’ll convert to png if I need to make it smaller, e.g. posting it to the web.

PNG was intended to replace GIF format for most images. Mostly to allow a lot more colors. As noted, it is lossless. You can repeatedly compress and decompress a PNG image without quality degradation.

Another “win” for PNG are simple graphic images. E.g., large areas of the same color. A simple scan of a text document is another good example. These “sameness” areas compress really well.

OTOH, realistic photo images with common textures don’t compress well in PNG. But such areas work well for JPG since the little bit of blurring caused by the lossy compression is mostly hidden within the natural “noise” in the image. But if you really drop the quality setting when creating a JPG you will easily notice it.

There was an innate prejudice against PNG from the get-go. Most of them were minor nits including the usual “Oh no, another image format???” So it was slow to become accepted. I mean really slow. So slow that some software still doesn’t support it.

Regarding Tiff images. Tiff is actually a general container for images. The actual image format inside a Tiff image can be stored in all sorts of ways. From run length encoding to jpeg encoding and all sorts of things in between. If you happen across a random Tiff image it is pure chance whether your image software can decode it.

In short

  1. If permanently saving a simple looking graphics file, PNG is an option…
  2. If saving a realistic image from a camera or some such, use JPG.
  3. If you want to do some editing on an image, PNG is one option. Edit it as a PNG, then save the final output per 1 or 2.

Possibly more important to your needs is resolution. If you will at some point want to print an image (photo) on home inkjet you’ll want about 150ppi (pixels per inch). Offset printing minimum 250ppi - 300 preferred. If there’s text involved you may want higher.
Screen resolution is 72ppi.

For either, jpg will work just fine. Yes it’s technically a lossy format but you won’t see the difference. Again, it’s all about resolution. And resolution will also determine size.
I would set the camera to high quality setting with jpg output.
Keep in mind you can always reduce the image size afterwards but you can’t add to it (without great loss, aka pixelating).

An exception to using jpg is if you require a transparent background. Someone noted this above. jpg doesn’t support transparency. You’ll get a white background whether you like it or not. png does support transparency. Unlikely to be an issue if we’re just talking vacation photos.

Suggest you lookup image resolution for further explanation & understanding. Note that ppi (pixels per inch) and dpi (dots per inch) are not quite the same, but are close enough to use interchangeably.

It was my understanding that PNG can be lossy, for better compression ratios, but it doesn’t have to be. And unlike the GIF format that it was created to replace, it can do a decent job with photographs, but JPEG is still better for that purpose (especially photographs of people).

The one I don’t get is WebP. In The Beginning, there was GIF and JPEG, plus various simple lossless formats like BMP. BMP images were always too large to be practical for anything over a network, so browsers all supported the compressed GIF and JPEG formats. And GIF and JPEG worked well for different kinds of images, so there was a pretty good breadth of capability, between the two of them.

Then, though, there were some legal questions about the rights to the GIF format (IIRC, it was owned by Compuserve, and they were flexing their muscles about not letting anyone else use it). So PNG was created as a replacement, that was (mostly) good at the same things as GIF. Adoption of PNG support was rocky at first, but nowadays they’re pretty universal.

And then there came SVG, which served a different purpose than GIF or JPEG. It’s a vector format, not a pixel format at all, which means (among other things) that you can zoom in or out as much as you want without ever losing quality. And as a bonus compared to other vector formats, it was based on HTML, so it was easy to make web browsers support it. Unfortunately, support for SVG is still uncommon in anything other than web browsers, but there’s still a good reason for it.

WebP, however, doesn’t do anything new, and it’s not supported by ANYTHING other than web browsers. It might have slightly smaller file sizes than JPEG, but with network speeds what they are nowadays, that slight improvement makes almost no difference. Why anyone wants to use WebP, given the marginal benefits and utter lack of support, is beyond me.

Or if you want to compose an image of other images. I do a decent amount of graphic design for marketing materials, and I keep everything in PNG until I have my final image to be put online, then I go JPG.

It does make it slightly harder to scrape pics off a website.

Many pictures I take need to have resolution reduced and annotations. Those pictures are usually of machines, tools, and things I build with them, not photos of people or places where the incredibly hi-res image I get from my flashlight/alarm-clock/email/browser/solitaire device that also takes pictures and maybe has some other function. Generally just use Paint for that and save them as PNGs. It’s always been good enough for those purposes. My wife is the real photographer, occasionally still doing weddings and the like for friends and family, and she would stick to JPG.

I have never even heard of WebP. Is this a common format? (ETA: I see you say “utter lack of support,” so I guess not. But why WebP in particular to mention? I’m sure there must be other oddball formats out there besides it.)

It’s becoming more ubiquitous in websites.

Sorta. There’s nothing in the PNG spec that makes it lossy. But you can degrade the image in certain ways that will make it compress better. The main way to do this is by reducing the number of colors. But it still gets nowhere hear JPEG’s compression rates.

And therein lies the biggest benefit of WebP. It has both transparency and lossy compression, while also having a lossless mode. It can efficiently compress photographic data with transparency, something neither PNG nor JPEG can do. And that lossy compression looks better, as it doesn’t get blocky or have as noticeable artifacts. You can get away with lower quality settings without it being so obvious like it is with JPEG.

I don’t recommend it (in lossy mode) for storing images because of the color issues I mentioned above. That’s the one place where they dropped the ball. With somewhere between 95% and 98% quality JPEG (depending on the type of image) and no color subsampling, you can make it where the image is indistinguishable even at 4x zoom. But if I were making a website or web app and I needed it to be snappy, I’d probably use it.

Sure, bandwidth is a lot better now, but there are still people with slower connections on mobile or DSL. There’s a reason YouTube still keeps around its 360p and 240p options.

It is some stupid Google format, and there is no compelling reason to use it.

By the way, it may not be the latest and greatest, but I have a soft spot for JPEG 2000 with its cute biorthogonal wavelet transform.

If your not planning to re edit or enlarge a photo there is really no downside to using jpg. I always assumed png to be lossless as I never been asked to specify a compression ratio, its interesting to find otherwise.

PNG compression is not lossy. However, if processing is an issue, as I said you may want to save the raw files.

…I’m finding I’m getting reductions between 50-80% in size when converting JPEGs to WebP, which has a significant impact on the load-time of the websites I’m building. I’m a convert.

Re: GIF and patents. The only real IP issue was that the compression algorithm was “LZW”* whose patent was owned by Unisys. CompuServe thought they had the right license from Unisys but then lawyers got involved. Hardly anybody else got chased by Unisys’s lawyers but the few that did caused some chilling in the spread of the format (and other compression systems that used “LZW”). The patents covering it are long expired.

* Some of the original, weakish, ideas came from papers by Ziv and Lempel. (Note order.) But the big breakthrough was by Welch. His trick allowed one-pass compression. Hence the abbreviation WZL. Er, um, well, yeah, about that.

Yeah, the legal dispute has died down by now, and so GIFs are no big deal, but at the time, the need for a replacement seemed pretty important. And now, PNGs have enough other advantages over GIF that they’re still around. Mostly all you see GIFs for now is animations, to the point that the term “GIF” has come to mean “short silent movie”, regardless of actual format.

(I think there’s a way to make animated PNGs, too, but almost nobody ever actually does that)

In that case, why not AVIF?