62

I prefer PNG format to JPG, because JPG uses lossy compression.

When I capture a screen in my PC or scan a picture or document in my scanner, I always save them as PNG format.
If a camera could save its data as PNG format, I'd use the feature even if I needed to buy more memory cards.

But I haven't see any camera that does. Why not? Why don't most (or any) cameras support PNG format?

P.S My camera doesn't support RAW.

Benjamin
  • 653
  • 1
  • 5
  • 8
  • 7
    Many support TIFF, which also supported lossless compression. But then the question becomes "Why don't most web browsers support TIFF?" – mattdm May 05 '11 at 11:14
  • 3
    You prefer PNG to JPG for photography? I have not seen an argument for that before. – dpollitt May 05 '11 at 13:27
  • 1
    Its kindof ironic that the link you give uses png as an examply of lossy compression :) – Toby Allen May 05 '11 at 17:27
  • 1
    As far as I know, PNG is more effective for computer generated graphics, as the format internally carries a palette of all the colors used in the image, so, for a high quality photograph it will be a HUGE palette. In other words, you wont get as much compression as for other formats, such as JPEG without other compromises (quality or performance). JPEG in the other hand, was designed specifically for photographs. http://en.wikipedia.org/wiki/Portable_Network_Graphics – Jahaziel May 05 '11 at 19:01
  • 6
    @JZL While PNG supports color palettes (indexed color), it does not require them. I'm sure we're talking about good old 24- or 48-bit RGB color here. GIF, on the other hand, only supported indexed color and was limited to 256 colors in the palette. – coneslayer May 05 '11 at 19:45
  • 1
    Lossless JPEG or JPEG2000 would probably be better than PNG for photography. IT could be possible to use PNG in a TIFF container, but it isn't clear that PNG compression would be more effective than lossless JPEG or JPEG2000. JPEG2000 is still patent encumbered, but in the years to come we might see this as the way forward. – user1207217 Apr 19 '13 at 10:07
  • There's not really a practical point of having a lossless format like PNG, at 24 bits. At 85%, a JPG is practically the same as a PNG. Only in specific situations you will be able to see the difference, like zooming in or making very large prints. It's just not practical to store such a large format when most people will only be confused by it. – Nick Aug 22 '14 at 07:22
  • @mattdm, Which browsers don't support TIFF? – Pacerier Aug 19 '15 at 23:09
  • 2
    @Pacerier Most of them. Rather than listing, check out this table on wikipedia. – mattdm Aug 19 '15 at 23:13
  • Checkout the first answer to get a technical and practical view - https://stackoverflow.com/questions/2336522/png-vs-gif-vs-jpeg-vs-svg-when-best-to-use – Regmi May 26 '17 at 00:42

7 Answers7

66

The JPEG format has the advantage of giving small files. The RAW formats have the advantage of preserving all the data collected at the shot.

The PNG format gives neither of these advantages, so you don't even get a compromise between the other formats, you get almost only the drawbacks from both formats.

Guffa
  • 21,309
  • 3
  • 58
  • 85
  • 3
    One point to note here, there is no "the RAW format". So if Benjamin wished for a standard, he would have to convert his RAW to DNG. – Leonidas May 05 '11 at 14:31
  • 1
    Yes, RAW just means the cameras internal format, and varies from camera to camera. I recently used a camera whose raw format involved two bytes per pixel and several thousand extra header/footer bytes (ugh). – John Robertson May 05 '11 at 16:20
  • I'd tend to agree with Leonidas here. The real issue is that DNG is not adopted by more camera makers. As photographers, we own our negatives, but our digital negatives are locked up in proprietary file formats, often with details concealed under NDA. Adoption of DNG by either Canon or Nikon would go a long way toward solving that. It won't happen, though. – RBerteig May 05 '11 at 18:20
  • @RBerteig In the meantime, it would be wise for people to buy cameras that are already supported by dcraw. – erjiang May 05 '11 at 19:27
  • 2
    @John, using 2 bytes/pixel is abnormal? How else would you fit the 12 or 14-bit value the sensor provides for each pixel? You could do a little compression afterwards, but for a bunch of more-or-less random data it may not even be worth it. – Nick T May 06 '11 at 00:22
  • @erjiang, I certainly agree with that. I've advocated archiving a copy of dcraw.c that works with your camera along with your periodic backups of your raw files as at least one way to make sure you've got a document that describes them. – RBerteig May 06 '11 at 01:57
  • @RBerteig Native DNG support was one of the reasons why I went into Pentax DSLR system. – sastanin May 06 '11 at 09:54
  • @Nick T. Does the sensor typically really only provide a 12 or 14 bit value for each pixel? I haven't dealt with anything RAW until recently and I suppose I expected it provided raw data much closer to 24 bits of color (8 green bits, 8 red bits, 8 blue bits). – John Robertson May 06 '11 at 15:40
  • @Nick T. I went ahead and posted [http://photo.stackexchange.com/questions/11766/how-many-bits-of-data-is-typically-actually-captured-by-a-digital-camera-sensor](a question) asking about digital camera sensor bits of data. Feel free to answer if this is something you know a lot about. – John Robertson May 06 '11 at 15:51
  • 1
    @John Robertson: Most chips only record one color per pixel, not three, so 14 bit RAW corresponds to 42 bit RGB, after two color components per pixel has been interpolated from surrounding pixels. – Guffa May 06 '11 at 16:48
  • @jetxee, Yup, Pentax and a couple of the very high end cameras do native DNG. I just won't hold my breath waiting for Canon or Nikon to move away from their proprietary RAW formats. – RBerteig May 06 '11 at 18:29
  • What a precise answer! – Nandakumar Edamana Jan 18 '18 at 05:59
  • I see it the other way around. PNGs have the advantage over JPEGs that they are lossless, and they have the advantage over RAWs that they are smaller. So I'd say that it's the best of both worlds, if you're not interested in very small images, nor very detailed ones. – Iulian Onofrei Feb 22 '20 at 08:33
  • 1
    @IulianOnofrei: Although the PNG format is lossless, a lot of data is lost before it is put in the file. The format (as used) only supports a bit depth up to 8 bits, so the 12-14 bits from the sensor has to be reduced to 8 in the same way as for JPEG. The JPEG compression removes some more data, but if you compare JPEG images to PNG images (overlaying by subtraction) you see that the differences are very small, and doesn't really warrant the larger file size. – Guffa Feb 23 '20 at 18:09
  • This should have been the answer! – Iulian Onofrei Feb 23 '20 at 18:21
  • This answer is incorrect. The correct answer is industry inertia and cost cutting measures. PNG would be a far better option, unlike JPG, it would get worse everytime you edit and save it because it's lossless. And unlike RAW, it does have as much compression as possible so that filesize, while bigger than JPG, are still much more manageable than RAW. Camera designers simply don't feel much pressure to improve this aspect because most consumers cannot tell the difference. – Shodan Jun 04 '21 at 17:14
  • @Shodan: No, the PNG is not a better option, as it doesn't preserve the original data and doesn't offer optimal compression. The data from the sensor typically has one color component per pixel, while the data in the PNG image has to contain the interpolated values of all three color components for each pixel. That means that the PNG file contains three times as much information as the RAW file, but it still can't be used to get the original information from the sensor as the values have been processed. – Guffa Jul 05 '21 at 10:39
  • 1
    @Guffa, unlike RAW, PNG are standardized, open with everything and don't degrade on every save. In 2021 space or speed doesn't matter for 99% of camera users as they are effectively unlimited. If camera manufacturers could agree on one RAW image format then that would be better, but there's 40 of them ! This is impractical. Also they don't need 3x the space but about 1.5x. – Shodan Jul 24 '21 at 00:05
  • @Shodan: You are comparing apples and oranges. A RAW file doesn't degrade on every save as you never resave a RAW file. I never said that a PNG file takes three times the space, I said that it contains three times the amount of information. The files are compressed at different ratios depending on the image content and type of information. – Guffa Aug 26 '21 at 08:10
  • 1
    99% of users simply do not care about RAW files and have no software that can read them. Most of these users just use the normal JPG files that come from their devices and those get damage every time they are modified and reposted. PNG files are a happy in between, usable by nearly all software yet do not degrade over time. – Shodan Aug 28 '21 at 03:58
  • @Shodan: A PNG is still not capable of containing all the information from the sensor. It doesn't matter much if you can resave a PNG without losing data when you have lost a lot of the data even before creating the PNG file. – Guffa Oct 15 '21 at 17:32
  • @Guffa I disagree, it matters a lot that you can save and modify a file without further damaging it. This is like saying "It doesn't matter to stop the bleeding because you already lost a lot of blood". Yes, the compressed raw format would be better, but those file are largely unusable by most software and users. – Shodan Oct 16 '21 at 19:24
  • @Shodan: Your analogy is backwards. Your argument for PNGs is like saying "you lost a lot of blood, but we stopped the bleeding so you were actually not injured at all". – Guffa Oct 19 '21 at 12:23
  • @Guffa PNG has supported 16 bits per RGBA channel since its inception in the year 1996. http://www.libpng.org/pub/png/spec/1.0/PNG-Chunks.html#C.IHDR – Nayuki Dec 04 '23 at 03:32
52

Image size notes aside, a big reason is that PNG does not have a standardized means of EXIF embedding and that will immediately shy the camera makers away from it. There would be a lot of information lost by doing image conversion to PNG in camera as a result and, for the most part, would probably been seen as a negative by most photographers.

Joanne C
  • 33,138
  • 4
  • 72
  • 132
  • 8
    +1 Never realized that there was no standardized EXIF embedding for PNG. Good to know. – coneslayer May 05 '11 at 13:43
  • 6
    Most likely reason. Metadata is nice. – Leonidas May 05 '11 at 13:54
  • Just because the metadata isn't standardized, don't mean you cannot do it. PNG supports metadata to be added to the file, it just doesn't define EXIF directly as part of the metadata. The metadata of a PNG file is "freeform" to a certain degree. – Kevin Peno May 05 '11 at 15:35
  • 4
    Wiki: iTXt contains UTF-8 text, compressed or not, with an optional language tag. iTXt chunk with the keyword 'XML:com.adobe.xmp' can contain Extensible Metadata Platform (XMP). – Kevin Peno May 05 '11 at 15:38
  • This is another point for TIFF, by the way. – mattdm May 05 '11 at 15:42
  • @mattdm, sure it is. Just wanted to point out that it could technically be supported if the manufacturers wanted it to be :P – Kevin Peno May 05 '11 at 16:00
  • 8
    Lack of EXIF data would be "seen as a negative" by photographers? Bah! These young digital photographer whipper-snappers! In my day, photographers used film and knew what a negative really looked like! :-) – Oddthinking May 05 '11 at 16:25
  • 4
    @Oddthinking At least the negative had a little metadata at the edges! – coneslayer May 05 '11 at 16:41
  • @Oddthinking Hell yeah, how I miss the time when I took some note regarding a photo with pencil and paper. Not. – Leonidas May 05 '11 at 16:47
  • @coneslayer I took a quick look at Wikipedia, but it had almost nothing on Photograph negatives. Can you point me to a link on that metadata? – penguin359 May 05 '11 at 22:02
  • 2
    @Kevin Actually, after diving into Exif, I loathe some of it's features which XMP solves. I just wish XMP was more widely supported, especially since PNG supports it. The most frustrating thing about Exif is the lack of time zone information in Exif time stamps. When my phone automatically changes time zones, it makes it difficult to determine the correct relative time later. It's also an argument against changing the time on one's camera if they wish to geotag their photos later from their GPS logger. – penguin359 May 05 '11 at 22:06
  • @penguin: good to hear it solves some problems. The only way to get it supported is to spread the word and get people asking for it. – Kevin Peno May 05 '11 at 22:09
  • @Kevin I'm more concerned about camera manufactures supporting it, but I have no influence in that arena. I want my photos originally stored with proper timezone and other meta data where Exif lacks. – penguin359 May 05 '11 at 22:16
  • @penguin, by "get people asking for it" I was referring to asking the manufactures for said support. Until the community backs it, they won't spend the money :) – Kevin Peno May 05 '11 at 22:19
  • @penguin Film had edge markings showing the film type and frame number. For example http://micro.magnet.fsu.edu/primer/photomicrography/images/chromeprocessingerrors/unexposed.jpg (Also, there were camera backs that could imprint date/time or exposure info between the frames, for example http://en.wikipedia.org/wiki/Nikon_F80 .) – coneslayer May 05 '11 at 22:21
  • @penguin359: Even in the 1940s films had date codes on the edges. – supercat Nov 24 '14 at 23:18
  • 1
    Well, I should have downvoted this, as the current version of PNG does support EXIF chunks, eXIf. Added in July 2017, at the version 1.5.0 of the Extensions to the PNG 1.2 Specification. – Константин Ван Dec 24 '20 at 01:13
28

PNG may use a lossless compression algorithm, but it is lossy in comparison to the raw data. You lose bit depth, the camera may introduce demosaicing artifacts, you may bake in a bad color balance, the camera may apply inappropriate sharpening, the in-camera noise reduction may wash out detail, etc. I don't think there's a big demand for a format that's as large as raw, but less amenable to postprocessing.

coneslayer
  • 7,406
  • 3
  • 37
  • 55
  • 4
    The .png would almost certainly be bigger than the raw as the png would have to store three colour values per pixel instead of one raw sample, so for an 8bit png that's 24 bits per pixel vs. 12 or 14 bpp for the raw. – Matt Grum May 05 '11 at 13:12
  • @Matt I wasn't sure whether it would be bigger or not and can't currently test. Obviously there's correlations of RGB values from one pixel to the next, since the values came from demosaicing, and the PNG compression may be able to exploit those correlations. And raw compression varies; some Pentax DSLRs didn't compress DNG raw output at all. So I didn't consider "which is bigger" to be a question I could answer just by thinking, and not measuring. :-) – coneslayer May 05 '11 at 13:20
  • 1
    PNG, being lossless, however doesn't suffer from generational loss as a result of editing in the same manner that JPEG does. So, in that aspect, I don't think it's any worse than JPEG in camera. – Joanne C May 05 '11 at 13:28
  • 3
    @John But it is worse than raw, which is what you should be using for editing. PNG just seems like an unhappy medium between JPEG and raw. – coneslayer May 05 '11 at 13:31
  • 6
    @Matt As the PNG does use compression (too), the result does not have to be bigger at all (depends on algorithms). To put it to you in a question: if you convert an ASCII-file (8 bit per character) to a UTF16-file, should a compressed result become significantly bigger?

    If you answer that with "yes", please re-read compression-algorithms.

    – Leonidas May 05 '11 at 13:42
  • 1
    @coneslayer The only no-revertable conversion that really has to be done is demosaicing. Denoising, further white-balance, sharpening could all be done in postprocessing (as for RAW). You will not lose bit depth if you save as 16 bit per channel PNG (as you would not with TIFF). – Leonidas May 05 '11 at 13:50
  • 1
    @Leonidas You are correct, but I would expect that anyone asking for PNG output (instead of raw) will expect the result to be immediately usable out of camera, which means you want things like sharpening to mitigate the antialiasing filter and probably noise reduction. Not technically necessary, but if your PNG files require further editing, then, again, I don't see the benefit over raw. – coneslayer May 05 '11 at 13:53
  • 3
    @coneslayer I guess that Benjanmin has the same problem I had/have when reworking pictures: (1) JPG already lost some picture data and (2a) RAW is proprietary (software only available now for some time), (2b) not every camera offers RAW. Several years ago I too desperately wished for TIFF or PNG in my compact. – Leonidas May 05 '11 at 13:59
  • @Leonidas Regarding #1/#2a, since raw software is available now, you can shoot raw, and immediately develop to PNG for long-term archiving. Plus you have the raw file, so as long as the raw software exists, you have perfect information. I don't understand #2b. Not every camera offers raw, but neither do they offer PNG. If we're making wishes, I'd wish for raw, not PNG. – coneslayer May 05 '11 at 14:06
  • @Lionidas PNG has the potential to use compression yes, but the compression would have to be unbelievably clever to be able to exploit the correlations between colour channels that arise from demosaicing as it would effectively have to reverse engineer the demosaicing algorithm which is usually proprietary). It's nothing like the padding you get converting to UTF-16. The only way I could see the PNG version not being bigger was if the camera used the most naive demosaicing algorithm ever, which simply duplicated adjacent pixels to fill the gaps. – Matt Grum May 05 '11 at 14:12
  • 1
    @coneslayer - Never said it was a good option, I just noted that you can do lossless on PNG versus JPEG, so the issues of in-camera development equally apply to it and JPEG. – Joanne C May 05 '11 at 14:14
  • @Matt PNG only uses the pretty dumb ZIP (and this won't be changed anymore) and so surely won't be smaller. But. By demosaicing you don't add any information, so if you use clever compression algorithms (LZMA e.g.), the compressed results will be identical in size for pre-/post-demosaicing. – Leonidas May 05 '11 at 14:17
  • @Lionidas Yes, from a theoretical point of view demosaicing doesn't add information and thus compressing the demosiaced image will give the same filesize, but in practice the demosiacing process will introduce rounding errors i.e. noise, which is uncompressable. – Matt Grum May 05 '11 at 14:26
  • @coneslayer I speak from experience - back in 2003 I rather wished for a method to save the images lossless in a known and supported format instead of another darn proprietary format, group-called RAW. PNG was a bit more appealing, as TIFF has some problems here and there. – Leonidas May 05 '11 at 14:29
  • Anyway in summary you might get smaller files with 8bit PNGs but you are throwing away data, and if you do that you might as well shoot JPEG and get better compression ratios. You wont get smaller files with 16bit PNGs as the demosaicing process is not reversible by image compression. – Matt Grum May 05 '11 at 14:36
  • @Matt The variance that causes the noise does stem from the RAW data itself. I still fail to see why several discrete pixels-values should be better compressable than a functional transformation of these values to another discrete version. Is there a highly random element in demosaicing? – Leonidas May 05 '11 at 14:41
  • @Lionidas Demosaicing is deterministic but the best methods are nonlinear. If you take a discrete value, such as 4294967296, then that compresses well, it's 2^32, so you can use run length encoding or something even better. If you now raise it to the power 0.9 and round it you get 467373274 and suddenly it doesn't compress well any more! You can't even compress it by storing the constants 2,32 and 0.9 as that would technically be lossy compression, due to rounding errors the value we're trying to compress is not exactly equal to 2^32^0.9 – Matt Grum May 05 '11 at 15:19
  • In practice, PNG files are somewhere in between JPG which throw data out and RAW. The PNG standard supports 16bit/channel images (as does TIFF), so you don't have to lose bit depth. You will get better results compressing the raw data--which is potentially what a camera manufacturer would do. NOTE: TIFF has pluggable compression algorithms, one of which is JPEG compression. Even a TIFF can throw out data. – Berin Loritsch May 05 '11 at 16:13
  • @Matt The only conclusion is that the demosaicing does add information to the picture by its transformation: the algorithm. The entropy stays the same in the whole file, but that can't be exploited because you'd need to reverse-apply exactly these deterministic interpolations to take advantage of it locally (as PNG for example does small scale with its neighbour-filters). – Leonidas May 05 '11 at 16:27
  • But this also applies to JPEGs! The comparison was between JPEGs and PNGs, not between PNGs and RAWs. – Iulian Onofrei Feb 22 '20 at 08:34
  • Modern PNG supports 16-bit/channel. – xenoid Jul 28 '21 at 19:44
9

PNG is portable network graphics. It is targetted for the web, and rather simple (in colors) images. Its compression is very ineffective for realistic graphics as you will shoot with a camera, so the results are nearly uncompressed. As such you can then simply use RAW files, which do add the benefit, that there is no lossy conversion to an RGB colorspace.

The reason JPEG is used is simply that its compression is very good and works very well with more realistic graphics where individual artifacts are invisible to the human eye. In addition JPEG is supported by nearly any device and offers many way to add additional metadata, including color profiles.

No single RGB file format is able to store the image exactly as the camera sensor sees it; there is always some kind of loss in that conversion. As such it makes sense to use a format that has good compression which doesn't really harm the picture in total. If you are looking for a real lossless format, the camera's RAW is the only direction you can go, from which you then can create whatever file you desire.

poke
  • 309
  • 5
  • 11
  • Lossy conversion to the RGB colourspace? How so? What do you exactly loose while converting Bayer-sensor-data (additive data) to one form of the RGB-versions? (Btw: PNG does offer ICC-profiles in principle too, FF plans to support it, I read.) – Leonidas May 05 '11 at 16:46
  • @Leonidas: There is no “the” RGB colorspace. The camera collects much more information than what is interpretable by any RGB colorspace (sRGB, Adobe RGB etc.). As such when the conversion is done to an RGB file, there is always some information/colors lost. The only way to preserve that is by saving the data the way the camera sees it, i.e. the RAW. – poke May 05 '11 at 16:50
  • @poke Can you explain how a typical RGGB-sensor produces data which can't be converted lossless in any RGB-format? (I'm aware that there are multiple, note "one form of the RGB-versions".) – Leonidas May 05 '11 at 17:02
  • @Leonidas: I can be wrong with it, and if you know better (or are tricking me to say something wrong here), please correct me, but given that the sensor doesn't separate the light it sees into 256 steps for each color, I don't think that any normal RGB file format or RGB colorspace is able to contain all that information. I'm aware that the sensor does capture the data as RGB information, so in theory there could be a RGB colorspace if there was one that could hold as much information as the image actually contains. – poke May 05 '11 at 17:27
  • @poke No trick here, I just seriously doubt that there won't be any RGB format offering the gamut of the sensor. Concerning the discrimination - I think that 16 bit/channel-formats offer enough room to receive it. For example in http://photo.stackexchange.com/questions/8707/raw-processing-software/10556#10556 jrista mentions a demosaicing called Bayer Drizzle that really seems to be engineered to keep any data available. – Leonidas May 05 '11 at 17:35
  • Given that TIFF is the basis for the various raw formats, I'm not sure that you can assert your last paragraph. – Joanne C May 06 '11 at 02:13
4

Shoot RAW, develop to a PNG file (if the software allows).

http://www.luminous-landscape.com/tutorials/understanding-series/u-raw-files.shtml

Nick Bedford
  • 9,762
  • 3
  • 29
  • 40
2

Both formats have their Pros and Cons.

But the real reason why JPEG is more prevalent than PNG is that the people behind JPEG do aggressive licensing, which PNG lacks. (www.libpng.org/pub/png/)

This is very similar to MP3 vs. OGG vs. FLAC. MP3 Creators licensed aggressively in the beginning... leading to the popularity. Due to this, now, manufacturers approach MP3 to get licenses!

MyPreciousss
  • 121
  • 3
  • MP3 no longer requires a license, the patents expired a while ago. I think Fraunhofer shut down their licensing operation. Of course I should have noticed that you wrote this answer before any of that was true. – Mark Ransom Feb 08 '24 at 00:29
  • @MarkRansom, you're right... now! But doesn't matter as this is far from the best/most-upvoted answer here anyway :) Thanks for checking out my answer! – MyPreciousss Feb 20 '24 at 07:57
0

IMO you should always shoot in RAW, if you are not worried about memory costs RAW is the way to go. This gives you the best opportunity to correct images in post processing.

Below is a quote from: http://www.hackerfactor.com/blog/index.php?/archives/252-PNG-and-Cameras.html

PNG is absolutely wonderful for storing true 24-bit color images. Processing PNG files is very simple and requires no application-specific fields. However, it is computationally expensive, lacks the ability to store multiple images, and does not have many standardized text fields for managing meta data.

JPEG is a wasteful file format filled with specialized fields. It is also a poor choice for true color representation. However, it is computationally inexpensive, supports multiple image storage, and scaling images is trivial. And sadly, it widely accepted as the de facto standard.