# Calculating File Size Generated from Scanned Documents in HTML

An A4 (i.e., 8.5 x 11 inches) document scanned at 300 ppi and 24-bit color depth will generate an image file size of 25.25 MB. This can be calculated by multiplying the area of the document in square inches by the number of pixels per square inch to get the total number of pixels in the image, multiplying by the number of bits per pixel to get the total number of bits, and then dividing by 8 to get the number of bytes, thus:

Document Image File Size = (( height width ) x p p I 2 x color depth

Using the formula for the above example gives:

File size = (( 8.5 x 11 ) x ( 300 x 300 ) x 24 ) = 25,245,000 bytes = 25,245,000 / 1000 = 25,245 KB = 25,245 / 1000 = 25.25 MB

An image captured with a digital camera with pixel dimensions of 640 x 480 px at 24-bit color depth produces a file size of 0.92 MB. This is calculated by multiplying the total number of pixels by the number of bits per pixel to get the total number of bits and then dividing by 8 to get the number of bytes, thus:

Document Image File Size = (( height x width ) x PPI 2 x color depth ) / 8 Image File Size = ( pixel dimensions x color depth ) / 8

Using the formula gives:

Image File Size = (( 640 x 480 ) x 24 ) / 8 = 921,600 bytes = 921,600 / 1000 = 921.60 KB = 921.60/ 1000 = 0.92 MB

Source: Sklar David (2016), HTML: A Gentle Introduction to the Web’s Most Popular Language, O’Reilly Media; 1st edition.