Calculate the file size of an image file and a sound file, using information given

Data Storage, Compression & Related Topics – IGCSE Computer Science (0478)

Learning Objective

Calculate the file size of an image or a sound file from the data given, explain how compression changes the size, and relate these calculations to data representation, transmission, security and emerging technologies.

Syllabus Coverage Overview

Syllabus Unit What is Covered Here Further Detail (Other Note Sets)
1.1 – Binary, hexadecimal, two’s‑complement, shifts, overflow Full sub‑section with conversion steps, shift examples and overflow discussion. None
1.2 – Text, sound & images (character sets, pixel colour models, sampling) Text (ASCII/Unicode), image (pixels, colour depth, RGB/CMYK), sound (sampling rate, bit depth, channels). None
1.3 – Data storage, file size, compression Formulas, worked examples, compression ratios, practical tips. None
1.4 – Data transmission (bandwidth, latency, transmission time) New sub‑section with bandwidth‑time calculations and an example. None
1.5 – The Internet & cyber‑security Brief overview of URLs, HTTP/HTTPS, common threats and simple mitigations. Separate “Internet & Security” note set for deeper coverage.
1.6 – Emerging technologies (cloud, AI, IoT, robotics) Concise description and a real‑world scenario linking back to storage & transmission. Separate “Emerging Technologies” note set for extended study.
7–10 – Algorithms, programming & logic Reference to how file‑size calculations are implemented in programs. Dedicated “Algorithms & Programming” notes.

Key Concepts (Quick Reference)

  • Bit – smallest unit of data (0 or 1).
  • Byte – 8 bits. 1 KB = 1024 bytes, 1 MB = 1024 KB, 1 GB = 1024 MB.
  • Binary, hexadecimal & two’s‑complement – numeric representations used by computers.
  • Colour depth – bits per pixel (1, 2, 4, 8, 16, 24, 32).
  • Resolution – horizontal × vertical pixels.
  • Sampling rate – audio samples per second (Hz).
  • Audio bit depth – bits per audio sample (8, 16, 24).
  • Channels – 1 = mono, 2 = stereo.
  • Compression – lossless (e.g., PNG, FLAC) or lossy (e.g., JPEG, MP3).
  • Bandwidth – amount of data that can be transferred per second (bits / s).
  • Latency – delay before transfer starts (seconds).

1. Data Representation

1.1 Binary, Hexadecimal & Two’s‑Complement

All numbers are stored in binary. Hexadecimal groups four binary digits for easier reading.

DecimalBinary (8‑bit)Hexadecimal
00000 000000
100000 10100A
150000 11110F
2551111 1111FF
-5 (8‑bit two’s‑complement)1111 1011FB

Conversion steps:

  1. Decimal → binary: repeatedly divide by 2, record remainders.
  2. Binary → hex: group bits in fours from the right, replace each group with its hex digit.
  3. Negative numbers: invert all bits, add 1 (two’s‑complement).

1.2 Logical Shifts & Overflow

  • Left shift (<<) – moves bits toward the high‑order side, multiplying by 2ⁿ (e.g., 0001 0100 ₂ << 2 = 0101 0000 ₂ = 80₁₀).
  • Right shift (>>) – divides by 2ⁿ, discarding low‑order bits (e.g., 1010 0000 ₂ >> 3 = 0001 0100 ₂ = 20₁₀).
  • Overflow occurs when a calculation exceeds the maximum value a word can hold. In an 8‑bit unsigned word the max is 255 (11111111₂). Adding 1 wraps to 0.

1.3 Text Representation

Characters are stored as numeric codes.

  • ASCII – 7‑bit code (0‑127) covering English letters, digits and common symbols.
  • Unicode (UTF‑8) – variable‑length code that can represent over 100 000 characters from many languages.

Example: The word “IGCSE” in ASCII

I → 73₁₀ → 01001001₂ → 49₁₆
G → 71₁₀ → 01000111₂ → 47₁₆
C → 67₁₀ → 01000011₂ → 43₁₆
S → 83₁₀ → 01010011₂ → 53₁₆
E → 69₁₀ → 01000101₂ → 45₁₆

2. Image & Sound Representation

2.1 Images

  • Resolution: width × height in pixels.
  • Colour depth: bits per pixel. Common depths:
    • 1‑bit – black & white
    • 8‑bit – 256 colours (indexed colour)
    • 24‑bit – true colour (≈16.7 million colours)
    • 32‑bit – true colour + 8‑bit alpha (transparency)
  • Colour models: RGB (additive) for screens, CMYK (subtractive) for printing.

2.2 Sound

  • Sampling rate: how many times per second the analogue waveform is measured (e.g., 44.1 kHz = 44 100 samples / s).
  • Bit depth: precision of each sample (higher depth → larger dynamic range).
  • Channels: mono = 1 stream, stereo = 2 independent streams.
  • Waveform illustration (textual):
    ____/‾‾‾\____/‾‾‾\____ – each peak or trough is a sample.

3. Formulas for Uncompressed File Size

3.1 Image Files

\[ \text{File size (bits)} = \text{Width} \times \text{Height} \times \text{Colour depth} \] \[ \text{File size (bytes)} = \frac{\text{bits}}{8} \]

3.2 Sound Files

\[ \text{File size (bits)} = \text{Duration (s)} \times \text{Sampling rate (Hz)} \times \text{Bit depth} \times \text{Channels} \] \[ \text{File size (bytes)} = \frac{\text{bits}}{8} \]

3.3 Data Transmission (Optional but linked)

\[ \text{Transmission time (s)} = \frac{\text{File size (bits)}}{\text{Bandwidth (bits / s)}} + \text{Latency} \]

4. Typical Parameter Values (Common in Exams)

ParameterUsual ValuesNotes
Colour depth (image)1, 2, 4, 8, 16, 24, 32 bits24‑bit = true colour.
Sampling rate (audio)8 kHz, 22.05 kHz, 44.1 kHz, 48 kHz44.1 kHz = CD quality.
Audio bit depth8, 16, 24 bitsHigher depth → greater dynamic range.
Channels1 (mono), 2 (stereo)Stereo doubles the data rate.
Bandwidth (typical links)56 kbps (dial‑up), 1 Mbps (fast Ethernet), 100 Mbps (Gigabit Ethernet)Used in transmission‑time calculations.

5. Worked Examples

5.1 Image File Size (Uncompressed)

Given

  • Resolution: 1024 × 768 pixels
  • Colour depth: 24 bits

Calculation

\[ \text{Bits} = 1024 \times 768 \times 24 = 18\,874\,368\ \text{bits} \] \[ \text{Bytes} = \frac{18\,874\,368}{8} = 2\,359\,296\ \text{bytes} \] \[ \text{KB} = \frac{2\,359\,296}{1024} \approx 2\,304\ \text{KB} \] \[ \text{MB} = \frac{2\,304}{1024} \approx 2.25\ \text{MB} \]

5.2 Sound File Size (Uncompressed)

Given

  • Duration: 3 min 30 s = 210 s
  • Sampling rate: 44.1 kHz
  • Bit depth: 16 bits
  • Channels: 2 (stereo)

Calculation

\[ \text{Bits} = 210 \times 44\,100 \times 16 \times 2 = 296\,352\,000\ \text{bits} \] \[ \text{Bytes} = \frac{296\,352\,000}{8} = 37\,044\,000\ \text{bytes} \] \[ \text{MB} = \frac{37\,044\,000}{1\,048\,576} \approx 35.34\ \text{MB} \]

5.3 Applying Compression

Compression ratio = original : compressed. Compressed size = Original ÷ Ratio.

  • Lossless PNG, ratio 5:1 → 2 359 296 ÷ 5 ≈ 471 860 bytes ≈ 461 KB.
  • Lossy JPEG, ratio 10:1 → 2 359 296 ÷ 10 ≈ 235 930 bytes ≈ 230 KB.
  • FLAC audio, typical ratio 2:1 → 37 044 000 ÷ 2 ≈ 18 522 000 bytes ≈ 17.7 MB.
  • MP3 audio, typical ratio 12:1 → 37 044 000 ÷ 12 ≈ 3 087 000 bytes ≈ 2.9 MB.

5.4 Transmission Time Example

Scenario: Transfer the uncompressed 35.34 MB audio file over a 1 Mbps (1 000 000 bits / s) link with a latency of 0.2 s.

\[ \text{File size (bits)} = 35.34\ \text{MB} \times 1\,048\,576\ \frac{\text{bytes}}{\text{MB}} \times 8 = 296\,352\,000\ \text{bits} \] \[ \text{Transfer time} = \frac{296\,352\,000}{1\,000\,000} + 0.2 \approx 296.35\ \text{s} \;(≈4\ \text{min }56\ \text{s}) \]

6. Compression – How Size Changes

Two main types:

  • Lossless – data can be perfectly reconstructed (e.g., PNG, FLAC).
  • Lossy – some information is permanently discarded for greater reduction (e.g., JPEG, MP3).

Typical ratios (exam‑friendly):

  • PNG: 4 : 1 to 6 : 1
  • JPEG: 8 : 1 to 12 : 1
  • FLAC: ≈2 : 1
  • MP3: 12 : 1 to 15 : 1

7. The Internet & Cyber‑Security (Brief Overview)

  • URL – Uniform Resource Locator, the address of a web resource.
  • HTTP / HTTPS – protocols for transferring web pages; HTTPS adds encryption.
  • Cookies – small pieces of data stored by browsers, used for sessions.
  • Common threats:
    • Malware (viruses, ransomware)
    • Phishing – deceptive emails/websites to steal credentials.
    • Brute‑force attacks – trying many passwords.
  • Basic mitigations:
    • Strong, unique passwords (use a manager).
    • Regular software updates & antivirus.
    • Firewalls and safe browsing habits.

8. Emerging Technologies (Contextual Links)

  • Cloud storage – files kept on remote servers; size calculations help estimate storage costs.
  • Artificial Intelligence (AI) – large data sets (images, audio) are required for training; understanding file size informs dataset management.
  • Internet of Things (IoT) – sensors generate streams of data (often audio or image); bandwidth and storage planning rely on the formulas above.
  • Robotics – robots may capture video/audio; compression reduces transmission load to control centres.

9. Steps to Solve a File‑Size Question

  1. Read the question carefully; list every given value (resolution, colour depth, duration, sampling rate, bit depth, channels, compression ratio, bandwidth, latency).
  2. Convert units:
    • Time → seconds.
    • kHz → Hz (multiply by 1 000).
    • KB/MB/GB → use 1024 as the divisor.
  3. Choose the appropriate formula (image or sound). For transmission problems, also use the transmission‑time formula.
  4. Calculate total bits.
  5. Convert bits → bytes (÷ 8), then bytes → KB/MB/GB (÷ 1024 repeatedly).
  6. If a compression ratio is given, divide the uncompressed size by that ratio.
  7. State the final answer with the correct unit and, where required, comment on storage limits or transmission feasibility.

10. Practice Questions

  1. Image: 800 × 600 pixels, 8‑bit colour depth.
    • Calculate the uncompressed size in kilobytes.
    • If saved as a PNG with a 5:1 compression ratio, what is the approximate size?
  2. Audio: Mono recording, 2 min 15 s, 22.05 kHz sampling, 8‑bit depth.
    • Find the uncompressed size in megabytes.
    • Assuming MP3 compression of 12:1, what is the resulting size?
  3. Video frame: 1280 × 720 pixels, 24‑bit colour. 30 frames per second.
    • Determine the uncompressed data generated per second (in megabytes).
  4. Transmission: Transfer the uncompressed audio file from question 2 over a 2 Mbps link with a latency of 0.1 s. How long will the transfer take?

11. Common Mistakes to Avoid

  • Forgetting to convert minutes + seconds to total seconds before using the audio formula.
  • Dividing by 1000 instead of 1024 when converting bytes → KB/MB/GB.
  • Using colour depth in **bytes** rather than **bits** (24 bits ≠ 24 bytes).
  • Omitting the number of channels for stereo audio – this doubles the data.
  • Ignoring overflow limits when a question mentions a specific address size (e.g., 16‑bit address space → 65 536 bytes ≈ 64 KB).
  • Mixing up bandwidth (bits / s) with file size (bytes) – always convert to the same unit before dividing.

12. Summary

Accurate file‑size calculations are the quantitative bridge between data representation, storage capacity, transmission requirements and security considerations. Master the two core formulas, remember the 1024‑based conversions, and always check whether lossless or lossy compression applies. These skills are directly relevant to hardware limits, network planning, and the programming tasks that manipulate files in the later parts of the IGCSE Computer Science syllabus.

13. Link‑Back to the Wider Syllabus

Understanding file sizes informs several other syllabus areas:

  • Topic 1.3 – quantitative basis for storage & compression.
  • Topic 1.4 – helps evaluate whether a storage device (e.g., 2 GB SD card) can hold a set of media files.
  • Topic 1.2 – bandwidth calculations use the same size figures to estimate transmission times.
  • Topics 7–10 – programs that read/write or compress data rely on these calculations.
Suggested flowchart: “Given data” → “Select formula (image / sound / transmission)” → “Calculate bits” → “÷ 8 → bytes” → “÷ 1024 → KB/MB/GB” → “Apply compression (if any)” → “Final size”.

Create an account or Login to take a Quiz

56 views
0 improvement suggestions

Log in to suggest improvements to this note.