Learn
1.3.2 | CALCULATING IMAGE AND SOUND FILE SIZE
01 | WHAT ARE WE CALCULATING?
Why can a short sound recording use more storage than a photograph? The answer depends on how much data is recorded and how many bits represent each piece.
In this lesson, calculate uncompressed pixel data or uncompressed sampled sound data. These simple models exclude file headers, metadata, palettes, padding and other overhead. Actual compressed file sizes cannot be found from these formulas alone.
Both methods give bits first. Convert the answer into the unit the question requests.
02 | IMAGE SIZE: COUNT THE PIXELS
A bitmap is a rectangular grid. Multiply width by height to find the number of pixels, then multiply by colour depth to count the bits.
Image data in bits = width in pixels × height in pixels × colour depth in bits per pixel
| Factor | What it counts |
|---|---|
| Width × height | Total number of pixels |
| Colour depth | Bits used to represent each pixel |
| Their product | Bits used for all pixel values |
Use bits per pixel, not the number of possible colours. An 8-bit image can represent 256 colour values, but the formula uses 8, not 256.
03 | WORKED IMAGE EXAMPLE
A bitmap is 640 pixels wide and 480 pixels high, with a colour depth of 8 bits per pixel. Calculate its uncompressed pixel data size in KiB.
Pixels: 640 × 480 = 307200 Bits: 307200 × 8 = 2457600 bits Bytes: 2457600 ÷ 8 = 307200 bytes KiB: 307200 ÷ 1024 = 300 KiB
The two appearances of 8 have different jobs: colour depth tells us bits per pixel; dividing by 8 converts bits to bytes. They cancel in this example because each pixel uses exactly one byte.
04 | A HIGHER COLOUR DEPTH
Keep the same 640 × 480 resolution but use 24 bits per pixel instead.
640 × 480 × 24 = 7372800 bits 7372800 ÷ 8 = 921600 bytes 921600 ÷ 1024 = 900 KiB
The colour depth tripled from 8 to 24, so the raw size tripled from 300 to 900 KiB. The image still has the same number of pixels.
Doubling width alone doubles size. Doubling both width and height multiplies size by four. Doubling colour depth doubles size, with everything else fixed.
05 | SOUND SIZE: COUNT THE SAMPLES
Sample rate is the number of samples recorded each second. Multiply it by duration in seconds to count the samples. Sample resolution, also called bit depth, tells us how many bits represent each sample.
Mono sound data in bits = sample rate in Hz × duration in seconds × sample resolution in bits
| Factor | Meaning |
|---|---|
| Sample rate × duration | Total samples in one channel |
| Sample resolution / bit depth | Bits per sample |
| Product | Total bits for mono sound |
A rate of 8 kHz is 8000 Hz. The kilo in kHz means 1000, even though storage conversions in this syllabus use 1024. Frequency and storage prefixes are different things.
06 | WORKED MONO SOUND EXAMPLE
A 10-second mono recording uses a sample rate of 8000 Hz and a sample resolution of 16 bits. Calculate its raw size in KiB.
Samples: 8000 × 10 = 80000 Bits: 80000 × 16 = 1280000 bits Bytes: 1280000 ÷ 8 = 160000 bytes KiB: 160000 ÷ 1024 = 156.25 KiB
Keep full precision as you work. A fractional number of KiB is valid.
07 | MINUTES MUST BECOME SECONDS
A 2-minute mono recording uses 32768 Hz and 16 bits per sample. Calculate the size in MiB.
Duration: 2 × 60 = 120 seconds Bits: 32768 × 120 × 16 = 62914560 bits Bytes: 62914560 ÷ 8 = 7864320 bytes KiB: 7864320 ÷ 1024 = 7680 KiB MiB: 7680 ÷ 1024 = 7.5 MiB
Using 2 instead of 120 would make the answer 60 times too small. Write the converted duration before substituting into the formula.
08 | CHANNELS AND CHANGING SETTINGS
The core formula above assumes mono: one channel. If a question specifies several equally sampled channels, multiply by the number of channels. Stereo has two channels, so it uses twice the mono data at the same rate, depth and duration.
Sound bits = rate × seconds × bits per sample × channels
This is an extension to the mono model. Do not add a factor of two unless stereo or two channels is specified.
| Change, with other settings fixed | Effect on raw data |
|---|---|
| Double sample rate | Double the size |
| Double sample resolution | Double the size |
| Double duration | Double the size |
| Double rate and resolution | Four times the size |
Higher settings can represent sound more accurately, but increasing them does not recover detail missing from a poor original recording.
09 | TRY THE FILE SIZE CALCULATORS
Predict the result, then use the calculators to check. They calculate raw data only, using 1024 for storage units.
Decimal display is rounded to 12 significant digits where necessary. Fractions of bytes can arise from raw bit counts; actual files use whole bytes and may include padding.
10 | AVOID THE COMMON TRAPS
Use the right depth: colour depth for an image, sample resolution for sound. Use seconds: convert minutes first. Convert bits: divide by 8 before converting bytes to KiB. Use 1024: for each binary storage step. State the unit: it is part of the answer.
Do not multiply by compression settings unless the question gives enough information to calculate a compressed size. A JPEG or MP3 file usually differs from the raw size because its representation uses compression.