Image file size vers image resolution

This topic is saved here for the record – basically because it comes up regularly and I need a place to have this explained for clients:

How image file size in Megabytes relates to image resolution in Megapixels:

Lets look at a picture created with 12 Megapixel that has 12 million pixels.

In RGB color space we need 3x 8Bit for each pixel to get 24Bit color resolved. 8 Bit equals 1 Byte. 24 Bit equals 3 Bytes than. 12 million pixels therefore gives 3 Bytes x 12 million pixels = 36 million Bytes. As one Megabyte equals 1048576 Bytes the file size is theoretical  34,3 Megabytes or 36000000 Bytes. Some operating systems show the file size with 36 megabytes (thats not entirely correct though – this is about mebi and mega).   If you ordered an image with 12 Megapixel the file size on your hard disc is 3x 12 million Bytes when you receive an image in an uncompressed format (uncompressed TIF f.e.). If the same image is downloaded from the online gallery its usually provided with practically lossless JPEG compression. The same photo is only 5-8Megabytes in size because it is provided for convenience as a JPEG file. This is mainly due to the compressed nature of the JPEG format. The size of the file (the success of the compression) very much depends on the micro contrast of the photograph and therefore the file size is not fixed.

Although the uncompressed file is the best quality, there is basically no relevant difference between “lossless” compressed JPEGs and TIFFs when you examine the image quality on a pixel by pixel level. Its hardly detectable because “lossless” means the compression factor is very low.

RAW Files:

If you look at the file size of the RAW file format of the photograph (the original Nikon NEF format e.g. as the camera has captured it) you will be surprised to detect that this file is smaller than the TIFF file. The reason is that the RAW image file holds for each pixel location only red or green or blue and NOT all colors. This is due to the color capture method of the Bayer sensor pattern installed in CE cameras.  The missing colors are added later when we create a JPEG or a TIFF file. The process is called demosaicing.

### ok

So the short version: your file is so small because it is a lossless compressed JPEG. You can get the uncompressed TIFF but the gains in terms of image quality are neglectable.