Skip to content
IGCSE·Tuition
Computer Science · Lesson

Calculate an uncompressed image size with stated assumptions

A file-size question can feel like guesswork when the picture is described in words and the formula is nowhere in sight.

On this page
  1. Why does the answer need assumptions?
  2. How do you calculate it, step by step?
  3. Worked example
  4. The mistake to watch for
  5. Check yourself
  6. Where this leads next

To find the size of an uncompressed image, multiply the number of pixels by the number of bits each pixel uses: size in bits = width × height × colour depth. This appears whenever a question gives you a resolution and a colour depth and asks how much storage the picture needs.

It builds directly on bit depth from the previous module and is the first lesson in images, sound and storage.

Why does the answer need assumptions?

A bitmap image is a grid of pixels, and each pixel stores one colour as a binary number. The number of bits per pixel is the colour depth. More bits per pixel allow more colours, but the image needs more storage.

The formula gives the size of the pixel data only. A real file also stores the width, height and other details, and may be compressed. So write the assumptions you are making, for example “assuming no compression and ignoring file metadata”.

How do you calculate it, step by step?

  1. Find the pixel count: width × height.
  2. Find the bits per pixel. If you are given a number of colours, work out the smallest bit depth that can hold them (2bits ≥ colours).
  3. Multiply: pixels × bits per pixel gives the size in bits.
  4. Convert: divide by 8 for bytes, then use the stated convention for larger units (see converting storage units).
  5. State the assumption and give the unit.

The same method as Cambridge-style pseudocode:

INPUT Width, Height, Depth
Bits ← Width * Height * Depth
Bytes ← Bits / 8
OUTPUT Bytes

Trace with Width = 800, Height = 600, Depth = 8: Bits = 800 × 600 × 8 = 3 840 000, so Bytes = 480 000.

Worked example

A photo is 1 024 pixels wide and 768 pixels high with a 24-bit colour depth. Give the uncompressed size in bytes and in KiB (1 KiB = 1 024 bytes).

Step 1, pixels: 1 024 × 768 = 786 432.

Step 2, bits: 786 432 × 24 = 18 874 368 bits.

Step 3, bytes: 18 874 368 ÷ 8 = 2 359 296 bytes.

Step 4, KiB: 2 359 296 ÷ 1 024 = 2 304 KiB (which is 2.25 MiB).

Check by another route: 24 bits is 3 bytes, so 786 432 × 3 = 2 359 296 bytes. Both routes agree.

Assumption: no compression and no metadata, so the real file would be slightly larger or, if compressed, much smaller.

The mistake to watch for

A common slip is to use the number of colours as the bit depth.

Mistaken answer: An image is 640 × 480 with 256 colours. Size = 640 × 480 × 256 = 78 643 200 bits.

The student used 256 where the number of bits was needed.

The correction: 256 colours need 8 bits, because 28 = 256. So size = 640 × 480 × 8 = 2 457 600 bits = 307 200 bytes. The wrong answer was 32 times too large, which a quick reasonableness check would reveal.

Check yourself

Show every step, then open each answer.

1. An image is 100 pixels wide and 50 pixels high with a 4-bit colour depth. How many bytes does it need?

Show answer

Pixels = 100 × 50 = 5 000. Bits = 5 000 × 4 = 20 000. Bytes = 20 000 ÷ 8 = 2 500 bytes.

2. An image of 640 × 480 pixels uses 16 colours. Give its uncompressed size in KiB.

Show answer

16 colours need 4 bits (24 = 16). Pixels = 640 × 480 = 307 200. Bits = 307 200 × 4 = 1 228 800. Bytes = 153 600. KiB = 153 600 ÷ 1 024 = 150 KiB.

3. A black-and-white image is 8 × 8 pixels. How many bytes does it need, and what bit depth did you assume?

Show answer

Two colours need 1 bit per pixel. Bits = 8 × 8 × 1 = 64. Bytes = 64 ÷ 8 = 8 bytes, assuming 1-bit colour depth and no metadata.

Where this leads next

Sound is stored by the same kind of reasoning, so continue with calculating a sampled audio size. When you can do both without hesitation, test them in the practice set. The Python reasoning sandbox is a good place to turn the formula into code and check your arithmetic.

Some students follow every step here but lose marks because they forget to state the assumption or divide by 8. That is the kind of pattern our teachers look for in online one-to-one Computer Science tuition.

Questions people ask

What is the formula for uncompressed image size?

Image size in bits = width in pixels × height in pixels × colour depth in bits. Divide by 8 for bytes. The formula only works for an uncompressed bitmap, so say that assumption, and remember that a real file may also hold extra data such as the width and height.

If an image has 256 colours, is the colour depth 256 bits?

No. Colour depth is the number of bits per pixel. 256 colours need 8 bits because 2 to the power 8 is 256. Using 256 as the bit depth is a very common error, so always convert the number of colours to bits first.

Why do I need to state assumptions?

Real files include metadata, and compression changes the size. Writing 'assuming no compression and ignoring metadata' shows the examiner you know the answer is a theoretical minimum, and it protects you if the question wording is brief.

Updated:

Your next step

If image-size questions still go wrong when the wording changes, a one-to-one teacher can have you explain each assumption aloud and fix the exact step that slips.

Paid one-hour trial at your assigned teacher’s confirmed rate, starting from RM80.

Tuition is arranged with a parent or guardian. Send them this page on WhatsApp and they can enquire for you.

Parents: enquire here

  • 9,000+ students helped through our service
  • 9+ years helping IGCSE students