How to calculate image file size

The uncompressed size is exact arithmetic. The compressed size can only be estimated — but bits per pixel makes the estimate a good one.

The formulas

Uncompressed bytes
width × height × channels × (bit depth ÷ 8)
Typical RGB photo
width × height × 3 bytes
With alpha (RGBA)
width × height × 4 bytes
Bits per pixel (bpp)
file bytes × 8 ÷ (width × height). The useful comparison metric.
JPEG quality 80
Roughly 0.5–1.5 bpp for photographs.
PNG, photographic
Roughly 12–20 bpp. Barely compressed.
WebP quality 75
Roughly 0.4–1.0 bpp.

Working it out

Uncompressed size is exact

Every pixel stores one value per channel, and each value occupies the bit depth. So:

bytes = width × height × channels × (bit depth ÷ 8)

For a standard 8-bit RGB image that simplifies to width × height × 3.

4000 × 3000 RGB, 8-bit
4000 × 3000 × 3 = 36,000,000 bytes ≈ 34 MB
1920 × 1080 RGB, 8-bit
1920 × 1080 × 3 = 6,220,800 bytes ≈ 5.9 MB
1920 × 1080 RGBA, 8-bit
× 4 instead of × 3 ≈ 7.9 MB
4000 × 3000 RGB, 16-bit
× 6 ≈ 69 MB

This is the number a browser actually holds in memory while processing an image, which is why large batches exhaust a tab long before the files on disk look large.

Compressed size can only be estimated

There is no formula, because the answer depends on the content. Two images with identical dimensions and settings can differ threefold: a portrait against a plain wall compresses beautifully, a photograph of gravel does not.

What you can do is estimate from typical ratios, then measure the real result. For a photograph at quality 80, JPEG usually lands somewhere between a tenth and a twentieth of the uncompressed size.

Bits per pixel is the metric that travels

Comparing raw file sizes across different dimensions tells you little. Bits per pixel normalises it:

bpp = file size in bytes × 8 ÷ (width × height)

A 200 KB file at 1600 × 1200 is 204,800 × 8 ÷ 1,920,000 ≈ 0.85 bpp — comfortably in the normal range for a good web JPEG.

Under 0.3 bpp
Aggressive. Expect visible artefacts on most content.
0.5–1.5 bpp
The normal range for web photographs. Where you want to be.
2–4 bpp
High quality, or a detailed image that genuinely needs it.
Above 8 bpp
Either lossless, or something is wrong — usually a photograph in PNG.

This is how to tell whether a file is bloated without knowing anything about the subject: work out its bpp and see where it falls.

Estimating the other way round

To find the dimensions that will fit a target size, rearrange it. At a target of 100 KB and an assumed 0.8 bpp:

pixels = 102,400 × 8 ÷ 0.8 = 1,024,000 pixels — roughly 1170 × 875 at 4:3.

That is an estimate, not a guarantee, and it is exactly the calculation target-size mode removes the need for: give it a limit and it searches for the highest quality that fits, then reports what it actually achieved.

Why PNG resists estimation entirely

PNG's size depends on how repetitive the image is, which no formula captures. A screenshot of a text document at 1920 × 1080 might be 150 KB — around 0.6 bpp. A photograph at the same dimensions might be 4 MB, around 16 bpp.

Same format, same dimensions, a 26-fold difference, decided entirely by content. For PNG, measure rather than estimate.

Try it yourself

Everything below runs in your browser, so you can test any of this on your own files without uploading them.

  • Resize image

    By pixels or percentage, aspect ratio locked, across a whole batch.

    Open the tool
  • Compress JPEG

    Shrink JPG and JPEG photographs with a quality slider or an exact target size.

    Open the tool

Questions

Frequently asked questions

Every answer below is present in the page source, expanded, so it can be read without opening anything.

How do I calculate the size of an uncompressed image?

Multiply width × height × channels × (bit depth ÷ 8). For a standard 8-bit RGB photograph that is simply width × height × 3 bytes, so a 4000 × 3000 image is about 34 MB of raw pixels.

Can I calculate the compressed file size?

Not exactly — it depends on the image's content, and two photographs at identical dimensions can differ threefold. You can estimate using bits per pixel: 0.5–1.5 bpp is the normal range for a web JPEG.

What is bits per pixel?

File size in bytes × 8 ÷ total pixels. It normalises file size against dimensions, so you can compare a thumbnail with a hero image and tell which is efficiently compressed.

How many pixels can I fit in 100KB?

At around 0.8 bpp, roughly a million pixels — about 1170 × 875. That is an estimate; detailed images need more bytes per pixel. Target-size mode removes the guesswork by searching for the answer directly.

Why is my file bigger than the calculation suggests?

Metadata, embedded thumbnails and colour profiles all add fixed overhead, which matters most on small files. And detailed content genuinely needs more bits per pixel than the averages assume.

Why do browsers run out of memory on large images?

Because processing requires the *uncompressed* size in memory, not the file size. A 3 MB JPEG at 4000 × 3000 occupies about 34 MB as raw pixels while being worked on — which is why a large batch can exhaust a tab on a phone.

From the blog

Related reading

Longer, more practical guides from the blog.

  • Image Compression

    JPEG Quality Settings Explained: What the Number Actually Means

    Quality 80 is not 80% of anything. It is an index into a quantisation table. Measured on one photograph: dropping from 100 to 90 removes 77% of the file and 4.2 dB of fidelity; dropping from 40 to 30 removes 17% and costs almost as much.

    8 min read

  • Practical Guides

    How to Compress Images for a Website Without Wrecking Them

    Resize before you compress. Measured on one photograph: half the width at quality 80 produced a 16.4 KB file, while full width at quality 40 produced 20.6 KB and looked far worse. The order of operations matters more than the settings.

    8 min read

  • Image Formats

    PNG vs JPEG: When to Use Each, With the File Sizes to Prove It

    PNG stored the same photograph in 1274.1 KB where JPEG needed 67.5 KB — nineteen times larger. On a flat graphic PNG won. On a smooth gradient PNG lost to JPEG by a factor of two, which surprises most people.

    9 min read