The size of a picture: resolution, colour depth and bytes, and why doubling the width makes the file four times bigger; and text as numbers, from ASCII to Hebrew letters in UTF-8.
Step 1 of 6 · Resolution
Step 1 of 6
Resolution
A digital picture is a grid of pixels. Its resolution is how many pixels it has across and down; here the picture keeps a 4 : 3 shape, so its height is three quarters of its width. The more pixels, the smoother the edges, and the bigger the file.
The picture is now 32 pixels across, and the board shows the number of pixels and the size. Predict, and then Pixels across will double.
Step 2 of 6
The file size
The size of an uncompressed picture is a simple sum:
where is the size in bytes, the number of pixels and the bits per channel: three channels per pixel, and dividing by turns bits into bytes. Real files, like JPEG and PNG, compress these numbers, but the screen always shows the full picture.
Step 3 of 6
Resolution against colour
The same file size can be reached two ways: more pixels with fewer bits each, or fewer pixels in rich colour. Small icons and the pictures in old games gave up colours to save space.
Step 4 of 6
Letters as numbers
Text is numbers too. An encoding is a table that gives every character a number, and the computer stores only the numbers. The old encoding, ASCII, from the 1960s, numbers every Latin letter, digit and punctuation mark: A is , a is , the digit 0 is and the space . It has characters, seven bits, so each character fits in one byte.
Step 5 of 6
A word
A word is just a run of characters, and each one is stored separately, in order. Spaces and punctuation marks are characters too, and take room like a letter.
Step 6 of 6
Every language
ASCII has no room for Hebrew, Arabic, Chinese or emoji. Unicode gives a number to every character in every script in the world, more than a hundred and fifty thousand of them. The UTF-8 encoding stores them in one to four bytes: ASCII characters stay at one byte, so old text works as before, and other characters take more.
Loading the interactive version…
Loading the interactive version…
Each step sets up the Scene for you, and a control marked “fixed” stays put for that step.
Practice · Predict, then look
The picture is 32 pixels across. When Pixels across doubles to 64, how many times bigger will the uncompressed file be?
Practice · Predict, then look
The picture is 32 pixels across. When Pixels across doubles to 64, how many times bigger will the uncompressed file be?
Practice · Calculate
The picture is pixels, at 8 bits per channel, and the board rounds its size to kilobytes. Exactly how many bytes does it take uncompressed?
Practice · Calculate
The picture is pixels, at 8 bits per channel, and the board rounds its size to kilobytes. Exactly how many bytes does it take uncompressed?
Practice · Reach the target
You need a small icon that takes exactly 576 bytes, at 2 bits per channel. Change Pixels across and Bits per channel until it does, and press Check.
Practice · Reach the target
You need a small icon that takes exactly 576 bytes, at 2 bits per channel. Change Pixels across and Bits per channel until it does, and press Check.
Practice · Calculate
In ASCII each character is a number, and the capital letters come in order: A is , B is . Which number stores the letter D?
Practice · Calculate
In ASCII each character is a number, and the capital letters come in order: A is , B is . Which number stores the letter D?
Practice · Choose
How many bytes does the word HELLO take in ASCII?
Practice · Choose
How many bytes does the word HELLO take in ASCII?
Practice · Choose
In UTF-8, the encoding of most of the web, how many bytes does the Hebrew word שלום (four letters) take?
Practice · Choose
In UTF-8, the encoding of most of the web, how many bytes does the Hebrew word שלום (four letters) take?
Lesson complete. Every practice question here is done.