File size and compression
About this lesson: File size and compression
In short
8 bits make a byte. After that, each unit is 1024 times bigger: kibibyte (KiB), mebibyte (MiB), gibibyte (GiB), tebibyte (TiB). Slide up the ladder and see what each holds.

What you'll explore
- Storage units: From bits to tebibytes
- 8 bits make a byte. After that, each unit is 1024 times bigger: kibibyte (KiB), mebibyte (MiB), gibibyte (GiB), tebibyte (TiB).
- Image file size: Width × height × colour depth
- An uncompressed image needs one colour code per pixel. Multiply the pixels by the bits per pixel, divide by 8 for bytes, then by 1024 twice for MiB.
- Lossless compression: Run-length encoding
- Lossless compression makes a file smaller and gives back the exact original. Run-length encoding replaces runs of the same value with a count.
- Lossy compression: Throw away what you won't notice
- Lossy compression removes detail that people hardly see or hear, so files shrink a lot. The detail can never be recovered.
- Check yourself: Work out a file size
- An image is 100 pixels wide and 50 pixels high, with a colour depth of 8 bits.
Also in this lesson
- Step by step
- Watch out for these
- Choosing a compression type
- Photo storage
- More than the lesson
- Stretch your brain
- Squash it
Words to know
- kibibyte (KiB)
- 1024 bytes.
- mebibyte (MiB)
- 1024 KiB.
- gibibyte (GiB)
- 1024 MiB.
- tebibyte (TiB)
- 1024 GiB.
- file size
- How much storage a file needs.
- compression
- Making a file smaller.
- lossless compression
- Compression where the original can be rebuilt exactly.
- lossy compression
- Compression that permanently removes some data.
- run-length encoding (RLE)
- Replacing runs of repeated values with a count and the value.
- bandwidth
- How much data a connection can carry each second.
Sources
- BBC Bitesize, GCSE Computer Science: Compression
- International Electrotechnical Commission (IEC): binary prefixes kibi, mebi, gibi
- Joint Photographic Experts Group: JPEG overview
- Isaac Computer Science: Data compression
← Text, images and sound as numbers · From a problem to an algorithm →