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?

  • 1
    possible duplicate of What is RAW, technically?
    – mattdm
    Oct 1 '13 at 2:04
  • 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
    – cmason
    Oct 1 '13 at 19:36
  • 1
    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.
    – Keavon
    Oct 2 '13 at 3:23

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. :)

  • PNG can quite happily carry EXIF data, although few implementations do as in the early days there were quite a few inconsistencies. Oct 1 '13 at 13:39
  • @JamesSnell - Sort of... Does PNG contain EXIF data like JPG?
    – Joanne C
    Oct 1 '13 at 17:39
  • 1
    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. Oct 2 '13 at 12:07
  • 1
    @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.
    – Joanne C
    Oct 2 '13 at 13:06

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!

  • 3
    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.
    – TWiStErRob
    Jul 27 '16 at 11:09
  • @TWiStErRob I think any artifacts are going to be insignificant at 100% quality.
    – JohannesD
    Jul 27 '16 at 20:11
  • 1
    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.
    – TWiStErRob
    Jul 27 '16 at 22:08
  • "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.
    – Navin
    Oct 7 at 16:32

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.)

  • 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.
    – Joanne C
    Oct 1 '13 at 2:25
  • 1
    Also, PNG in certain formats allows for more than 8 bits per channel.
    – Joanne C
    Oct 1 '13 at 2:35
  • 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.
    – AJ Henderson
    Oct 1 '13 at 4:51
  • 1
    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).
    – Matt Grum
    Oct 1 '13 at 8:26
  • 1
    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. Oct 1 '13 at 19:19

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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