CS03-04 Computer Science Watch
Working out image and sound file sizes
In this lesson
In this video you'll learn about working out image and sound file sizes for GCSE Computer Science.
By the end: Calculate the file size of a bitmap image from its width, height and colour depth, and of a sound file from its sample rate, duration and sample resolution, convert the result into sensible units for your own board, work out the storage needed for a set of such files, and show the working that carries most of the marks.
What it covers
- 1:03 The text-file method has four steps
- 4:32 A storage question can ask about a set of files
Key words
About this video
Working out image and sound file sizes | GCSE Computer Science
How to work out image and sound file sizes from pixels, colour depth, sample rate and sample resolution, in bytes and kilobytes.
AQA 8525, Edexcel 1CP2 and OCR J277 GCSE. Images and sound 4 of 7.
Full Images and sound playlist: https://www.youtube.com/playlist?list=PLAonf4a5MXts
More at https://scholafly.com
Watch first: Working out the size of a text file - https://youtu.be/3QQuoX_vSSQ, How an image is stored: pixels, resolution and colour depth - https://youtu.be/HKb8YHkv23c, How sound is stored: sampling rate and bit depth explained - https://youtu.be/LOCcQaN-_fI
Video code: CS03-04 (search "ScholaFly CS03-04")
Videos in this chapter:
CS03-00 Images, sound and compression - Intro: https://youtu.be/5_VNvpWBbVU
CS03-01 How an image is stored: https://youtu.be/HKb8YHkv23c
CS03-02 From binary to bitmap and back: https://youtu.be/D7AjvZoKT_M
CS03-03 How sound is stored: https://youtu.be/LOCcQaN-_fI
CS03-04 Working out image and sound file sizes: https://youtu.be/_CcijC_0L1U
CS03-05 Why we compress data: https://youtu.be/ylXSh7OO4dI
CS03-06 Huffman coding: https://youtu.be/ig0uHFLoc9U
CS03-07 Run length encoding
#GCSEComputerScience #ImagesAndSound #ImageAndSoundFileSizes
For teachers
This GCSE Computer Science lesson teaches working out image and sound file sizes. By the end, students should be able to calculate the file size of a bitmap image from its width, height and colour depth, and of a sound file from its sample rate, duration and sample resolution, convert the result into sensible units for your own board, work out the storage needed for a set of such files, and show the working that carries most of the marks. It works through four worked examples and the mistakes examiners report, and suits Foundation and Higher tier students.
Exam board specification references:
AQA GCSE Computer Science (8525)
- 3.3.6 Representing images
- 3.3.7 Representing sound
Pearson Edexcel Level 1/Level 2 GCSE (9-1) in Computer Science
- 2.3.1 Data storage and compression
Cambridge OCR Level 1/Level 2 GCSE (9-1) in Computer Science
- 1.2.3 Units
Read the transcript
Picture a thirty-second sound clip, sampled forty-four thousand one hundred times a second at sixteen bits a sample. Now picture one photo, six hundred and forty pixels by four hundred and eighty, with a colour depth of twenty-four bits. One of those files takes nearly three times the room of the other, and a guess is no way to tell which. Two short multiplications settle it, and by the end of this video you will have done both. The method is not new. The video Working out the size of a text file built it, and only its first step changes here.
Video four of seven in Images, sound and compression, and it needs colour depth at every turn. If that feels unsteady, How an image is stored is the one to watch first.
The text-file method has four steps. How many characters, times the bits for each one, divide by eight to get bytes, then the unit step to kilobytes or megabytes. For an image, only the first two steps change. How many pixels, which is width times height, times the bits for each pixel, which is the colour depth. The divide by eight and the unit step stay as they were. So the image formula is this. File size in bits equals width times height times colour depth. Width and height are in pixels, and colour depth is in bits per pixel. For the unit step, use the prefixes your own course uses. This example uses decimal prefixes, so one kilobyte is one thousand bytes; the binary version comes at the end of the video. Take an image six hundred and forty pixels wide and four hundred and eighty high, with a colour depth of twenty-four bits per pixel. First, the pixels. Width times height is six hundred and forty times four hundred and eighty, which is three hundred and seven thousand, two hundred pixels. Next, the bits. Three hundred and seven thousand, two hundred pixels, times twenty-four bits per pixel, is seven million, three hundred and seventy-two thousand, eight hundred bits. Here are the last steps from three students. The first divides by eight, then by one thousand. The second divides by one thousand only. The third divides by eight only, and calls the answer kilobytes. Which of the three students gets the kilobytes right? The first. Divide by eight to get nine hundred and twenty-one thousand, six hundred bytes, then by one thousand to get nine hundred and twenty-one point six kilobytes. The second student skipped bits to bytes, and the third skipped the prefix. They are two separate divisions, never one, so each gets its own line with its own unit. One examiner's report records the start of the sum going well. Most candidates scored at least one mark for multiplying the width, three hundred and fifteen, by the height, nine hundred and twenty-three, and many went on to give fully correct responses. The multiplying is the part most students manage. The habit that carries the rest is three labelled lines after it: bits, then bytes, then kilobytes. Unless a question says otherwise, the sum uses only the pixels and the colour depth. One course allows an extra amount for metadata, and when it wants that, the question says so.
A storage question can ask about a set of files. The rule is to size one file first, and multiply by how many files there are as the very last step. Twelve copies of that same image need to be stored, and one copy is nine hundred and twenty-one point six kilobytes. Work out the space for all twelve copies, in megabytes, before I show you. About eleven point nought six megabytes, to two decimal places. Nine hundred and twenty-one point six times twelve is eleven thousand and fifty-nine point two kilobytes. Divide by one thousand and that is eleven point nought five nine two megabytes. One examiner's report names the step that gets left off. A common missed element was giving the file size of one image instead of multiplying it by ten to give the file size of the ten images. The fix: underline the count in the question before you start, and leave a final line that says times how many. A blank last line then looks wrong.
Now sound, and the method still does not change. Only the first two steps swap again: how many samples, times the bits for each sample. The bits for each sample have two names, sample resolution or bit depth, and they are the same number. How many samples is the sampling rate times the duration in seconds. So the sound formula is this. File size in bits equals sampling rate times duration in seconds times bits per sample. Take a clip sampled at forty-four thousand one hundred hertz for thirty seconds, with a sample resolution of sixteen bits. First, the samples. Forty-four thousand one hundred hertz means forty-four thousand one hundred samples every second. Times thirty seconds, that is one million, three hundred and twenty-three thousand samples. Next, the bits: one million, three hundred and twenty-three thousand times sixteen is twenty-one million, one hundred and sixty-eight thousand bits. Take those bits to megabytes yourself, in two divisions, before I show you. Two point six four six megabytes, which is about two point six five. First, divide by eight. Twenty-one million, one hundred and sixty-eight thousand bits is two million, six hundred and forty-six thousand bytes. Next, divide those bytes by one thousand, which gives two thousand six hundred and forty-six kilobytes. Then divide by one thousand again, which gives two point six four six megabytes. That settles the puzzle from the start. The thirty-second sound clip takes about two point six five megabytes and the photo about nought point nine two, so the sound takes nearly three times the room. A different report describes answers with no working. These questions required calculations to be carried out and many students did not gain working marks because they did not show their working on the paper. The habit: write every line with its unit, for image and sound alike. Below the first two steps, nothing moved between the two formulas.
Some image questions give a number of colours instead of a colour depth. That needs a step before the formula, step zero: has the question given me bits, or colours? If it gives colours, climb the colour depth ladder from How an image is stored. Start at one bit and double each rung, and stop at the first rung where the colours fit. Take an image twelve pixels by twelve that uses six different colours. Before any multiplying, what colour depth do six colours need? Three bits. Two bits give four colours, which is too few, and three bits give eight, the first rung that holds six. One examiner's report names this step. The commonest mistake when calculating the file size of the ten pixel by ten pixel image was in calculating the colour depth, number of bits, required to allow the representation of five different colours. This was commonly given as five rather than three bits. Another report records a smaller slip, one rung too high. A common error in question twelve was to use a colour depth of three bits rather than two. Both answers went too high, one by using the number of colours itself, so the fix is the same: climb from the bottom, and stop at the first rung that is big enough. Now finish the sum and give the file size in bytes, before I show you. It comes to fifty-four bytes for the whole image. Twelve times twelve is one hundred and forty-four pixels. One hundred and forty-four times three is four hundred and thirty-two bits. Four hundred and thirty-two divided by eight is fifty-four bytes. A third report lists both of this video's slips together. Common errors included confusing the colour depth of seven with two to the power seven for the number of colours available and dividing by one thousand in an attempt to convert to kilobytes rather than dividing by eight to convert the total number of bits into bytes. The fix for both: label every quantity with what it is, bits per pixel and never colours, and keep the divide by eight on a line of its own.
One course can ask for an expression rather than a number, written in binary multiples instead of decimal prefixes. A kibibyte is one thousand and twenty-four bytes. So to reach kibibytes from bits, you divide by eight and then by one thousand and twenty-four. Now a quick check on the unit. How many bytes are in two kibibytes? Two thousand and forty-eight bytes, which is double the size of one. Take an image two hundred and fifty pixels wide and four hundred high, with a colour depth of five bits. Its size in kibibytes is two hundred and fifty times four hundred times five, all over eight times one thousand and twenty-four. Write it as one fraction. The whole multiplication goes on top and the whole divisor goes underneath, so the line does the grouping that brackets would do. Two students set it out. The first puts only the five over eight times one thousand and twenty-four. The second puts the whole of two hundred and fifty times four hundred times five over it. Which of those two expressions gives the size in kibibytes? Only the second expression works. In the first, the divisor touches only the five, so the width times the height is never divided at all. One examiner's report notes the layout problem. A number of responses did not set out the expression accurately, or show understanding the arithmetic process required. The fix is the fraction line: every multiplication above it, every division below it, and the divide by eight inside the same fraction rather than tacked on after. One image can have more than one correct answer shape. Decimal prefixes and binary multiples give two shapes of number, the expression is another way to write it, and your course decides which.
To finish, four questions. Do the working in your head or on paper, whichever is quicker. In words, what is the image file size formula in bits? Width times height times colour depth gives the file size in bits. Divide by eight for bytes, then do the unit step. Next, colours not bits. An image uses twenty colours: what colour depth goes in? Five bits. Four bits give sixteen colours, too few, and five bits give thirty-two. Now sound: ten seconds at eight thousand hertz, eight bits a sample. How many bytes? Eighty thousand bytes. Eighty thousand samples at eight bits each is six hundred and forty thousand bits, and dividing by eight gives eighty thousand bytes. One more, back to the sound clip and the photo. Which took more room? The thirty-second sound clip, at about two point six five megabytes against nought point nine two for the photo, so nearly three times the room.
If you could size a fresh image or sound file, line by line, with nobody prompting you, you've got this down, so the thumbs up belongs on this one. If a line still goes missing, keep it saved and write the working column out once more on paper; doing that once is usually what makes it stay.
Next in the chapter: Why we compress data.
For more, visit scholafly.com, or watch the next video.
Related terms
For: AQA GCSE 8525, Edexcel GCSE 1CP2, OCR GCSE J277
On the specification
For teachers
This GCSE Computer Science lesson teaches working out image and sound file sizes. By the end, students should be able to calculate the file size of a bitmap image from its width, height and colour depth, and of a sound file from its sample rate, duration and sample resolution, convert the result into sensible units for your own board, work out the storage needed for a set of such files, and show the working that carries most of the marks. It works through four worked examples and the mistakes examiners report, and suits Foundation and Higher tier students.