8
\$\begingroup\$

I know that many professional cameras shoot in RAW. PNG has lossless compression which would allow cameras to save more shots than RAW. This leads me to wonder if there's anything special about RAW that makes it save more data than PNG.

I am not familiar with the RAW format and I don't come from a photography background. I have asked several people with professional cameras that shot in RAW and they weren't too sure, but they seemed to to think that RAW saved more actual data than PNG. Is this true? What, if anything, makes RAW better than PNG, and if there's no difference, why don't cameras shoot in PNG instead of RAW?

\$\endgroup\$
3
  • 1
    \$\begingroup\$ possible duplicate of What is RAW, technically? \$\endgroup\$
    – mattdm
    Commented Oct 1, 2013 at 2:04
  • \$\begingroup\$ Do you mean DNG rather than PNG? PNG is an image file format, similar to JPG. DNG is a image data format, similar to RAW \$\endgroup\$
    – cmason
    Commented Oct 1, 2013 at 19:36
  • 1
    \$\begingroup\$ No, I mean PNG. The given answers have been helpful, as I wasn't aware in the fundamental difference between an image format, such as PNG or JPG, and RAW. I just thought RAW and PNG were both lossless image formats, and wasn't aware of the low-level differences. \$\endgroup\$
    – Keavon
    Commented Oct 2, 2013 at 3:23

5 Answers 5

13
\$\begingroup\$

The RAW formats store, well, the raw sensor data from the camera with information on how to decode that for image processors such as Adobe Camera Raw or similar. In that sense, the RAW format is not an image, you have to apply demosaicing algorithms to interpret the sensor data into a coherent image for display. Beyond the Adobe attempt to convince everyone to use DNG (Digital Negative) as their format, there is no standard for the storage of RAW image data and most camera makers have their own. However, what is standard in all RAW formats is the EXIF data which provides a lot of information about the state of the camera settings at the time of the shot.

PNG, on the other hand, was devised initially as an alternative to GIF without all of the patent pain that the latter carried, mostly as a result of the compression algorithm. It's since grown up quite a bit, from original intention, but it wasn't really devised for photography as such. The biggest gap, for example, is the lack of EXIF data, a requirement for camera equipment. The other big issue is that it would be the end result of the interpretation of the sensor data, so you would lose the signal information of the sensor at that point and can no longer re-interpret the information with better or alternative algorithms. Effectively, you become stuck with the interpretation of the developer who wrote the algorithm. That's not alway desired.

So, it really boils down to: different purposes. :)

\$\endgroup\$
4
  • \$\begingroup\$ PNG can quite happily carry EXIF data, although few implementations do as in the early days there were quite a few inconsistencies. \$\endgroup\$ Commented Oct 1, 2013 at 13:39
  • \$\begingroup\$ @JamesSnell - Sort of... Does PNG contain EXIF data like JPG? \$\endgroup\$
    – Joanne C
    Commented Oct 1, 2013 at 17:39
  • 1
    \$\begingroup\$ That answer is wrong Joanne - I'm not sure it's worth correcting given it's age and the number of upvotes though. The 'chunk' or block storage method is how all the graphics formats hold data, including jpeg and tiff and even MP4. PNG treats all metadata equally and an exif chunk would be no problem as a zTXT for example. \$\endgroup\$ Commented Oct 2, 2013 at 12:07
  • 1
    \$\begingroup\$ @JamesSnell - That's why I said sort of. The standard does not explicitly call for EXIF, even if it can support it with arbitrary text, and that is a requirement for camera makers. \$\endgroup\$
    – Joanne C
    Commented Oct 2, 2013 at 13:06
3
\$\begingroup\$

In addition to what the other have said, PNGs are horribly inefficient at storing photos. Their compression scheme is designed to perform well when there are relatively few colors, large areas of the same color and/or exactly repeating patterns.

A quick test with a random 18 MP photo yielded these results:

  • Original RAW: 22 MB
  • JPEG with 100% quality: 14 MB
  • PNG converted from the JPEG: 28 MB

So, despite the the PNG storing much less information than the RAW, it ended up quite a bit larger!

\$\endgroup\$
4
  • 3
    \$\begingroup\$ I agree with the overall conclusion you made, but you skewed the result of the PNG compression, because it has to deal with JPEG artifacts. Try compressing the same RAW directly as PNG. \$\endgroup\$
    – TWiStErRob
    Commented Jul 27, 2016 at 11:09
  • \$\begingroup\$ @TWiStErRob I think any artifacts are going to be insignificant at 100% quality. \$\endgroup\$
    – JohannesD
    Commented Jul 27, 2016 at 20:11
  • 1
    \$\begingroup\$ I'm not saying you would get a better result, but JPEGs DCT and storage mechanisms may have skewed your results. It's even possible the original RAW compressed as PNG would be larger than 28MB. I'm curious, if you still have this image. \$\endgroup\$
    – TWiStErRob
    Commented Jul 27, 2016 at 22:08
  • \$\begingroup\$ "100% quality"? WTF. Why not compare PNG to Lossless JPEG instead of this drivel? Everyone knows that adding a bunch of blocking/aliasing artefacts and then trying to losslessly compress the result will always increases file size. That's why nobody converts from a lossy format to a lossless one. \$\endgroup\$
    – Navin
    Commented Oct 7, 2021 at 16:32
1
\$\begingroup\$

RAW is greater than 8 bits and stores the actual sensor data rather than processed image data. RAW is actually generally losslessly compressed, or even sometimes lossy compressed. PNGs would actually be larger if uncompressed because they only hold the image data after processing, which means each pixel has 3 colors rather than 1, and is generally only 8 bits per color channel, 24 bits per pixel (though the file format can support more) rather than 12 to 14 bits per photosite (which is basically a pixel).

I'm not sure why the PNGs were coming out smaller, but it may be due to using color compression that isn't available to RAW, since RAW is not yet demosaiced and is effectively an ultra-high precision B&W image until color is added based on the filter pattern and image processing. Since the color information isn't present, it would make the data far harder to compress due to the large changes between pixels (where as image data tends to have large, similar areas of color.)

\$\endgroup\$
7
  • \$\begingroup\$ RAW can be compressed lossy, Nikon offers that option along with lossless. It's a data storage format, so there's no inherent reason that the information can't be stored with a lossy compression algorithm, it's up to the camera maker. I chose the lossless option myself, D800 images are insanely large otherwise. \$\endgroup\$
    – Joanne C
    Commented Oct 1, 2013 at 2:25
  • 1
    \$\begingroup\$ Also, PNG in certain formats allows for more than 8 bits per channel. \$\endgroup\$
    – Joanne C
    Commented Oct 1, 2013 at 2:35
  • \$\begingroup\$ JoanneC: hence why I said generally 8 bit. :) Though I will update to point out that Nikon has a lossy format. I always forget about that since I'm a Canon guy. \$\endgroup\$
    – AJ Henderson
    Commented Oct 1, 2013 at 4:51
  • 1
    \$\begingroup\$ PNGs are generally 24 bits per pixel (8 bits per colour channel), so they wont be smaller than a 12 or 14 bit RAW files (at full resolution). \$\endgroup\$
    – Matt Grum
    Commented Oct 1, 2013 at 8:26
  • 1
    \$\begingroup\$ no, it is mandatory for a PNG decompressor to support 16bit images. it is the prefreed 16bit foprmat in the open source world. this is why I added PNG 16bit with exif support in image view plus more. Actually I thought lightrom supported it (for "Edit in") but then I found I had to add tiff 16 bit with exif support, too, haha. \$\endgroup\$ Commented Oct 1, 2013 at 19:19
1
\$\begingroup\$

They're really different formats to do very different jobs.

PNG is intended to be a non patent-encumbered format for network use - it was not designed for photography and there are aspects of the design where this shows.

  • Alpha Channel an extra colour channel for variable opacity

  • ADAM7 interlacing for a quick preview or for the whole image not to be downloaded if not required

  • RGB Only and no other colour spaces, with a limited selection on bit-depths

  • Poor compression courtesy of only supporting Zip/Deflate compression it does a poor job with image data which has a natural variance. More appropriate schemes like Wavelets or DPCM are covered by patents.

  • Metadata including custom types can be stored, but application support is patchy to the point where it's become an urban myth that PNG's can't store metadata.

By contrast RAW is more a class of formats where each one is optimised for the features of one camera model/manufacturer. It's a bit like having a choice between a hammer and an optimized precision tool.

\$\endgroup\$
0
\$\begingroup\$

RAW was, and is designed to enable post shot editing of all the digital information the camera stores. It is only visible in editing software that supports the files from a particular make and model of camera, hence all the major software companies regularly update their wares to support the latest iterations. PNG/DNG/JPEG are images compressed to one degree or another for viewing or printing as this reduces the file size by losing (lossy) layers which are only needed to edit things like exposure and white balance Most photographers will save a lossy copy for printing or sharing and retain a RAW file for future editing So really RAW and PNG are different animals for different purposes

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.