Pixel to Megabyte Calculator
What pixel dimensions cost in bytes uncompressed, as a file in each format, and in browser memory once decoded, which is the number that crashes phones.
Pixels 6,000 × 4,000
total 24,000,000
megapixels 24.00
Bit depth 24-bit colour, 3 bytes a pixel
Uncompressed
bytes 72,000,000
in MB, 1,000,000 bytes 72.00 MB
in MiB, 1,048,576 bytes 68.66 MiB
the difference 4.9%, which is why a 500 GB disk shows as 465 GB
In memory, once decoded 91.55 MiB
why a browser holds four bytes a pixel whatever the file size
so a small file still costs this much to display
Roughly, as a file
PNG, lossless 36.00 MB, about 1 in 2
JPEG at quality 85 4.50 MB, about 1 in 16
WebP at quality 80 3.00 MB, about 1 in 24
AVIF at quality 60 1.80 MB, about 1 in 40
What fits
in 1 MB, uncompressed 0.33 megapixels
images in 1 GB, uncompressed 13.9
images in 1 GB, as JPEG 222
The uncompressed size is arithmetic: 24,000,000 pixels at 24 bits each
is 72,000,000 bytes. That is what the pixels cost in memory in an
editor, and it has nothing to do with what the file on disk weighs.
A megabyte is 1,000,000 bytes and a mebibyte is 1,048,576. The figures
are given in both because the two are used interchangeably and differ by
4.9 percent: storage is sold in the first and displayed by most
operating systems in the second, which is the whole "my new disk is
smaller than advertised" phenomenon.
In a browser the number that matters is the decoded one: 91.55 MiB for
this image, because a decoded bitmap is four bytes a pixel regardless of
how small the file was. A page with a dozen large photographs can hold
hundreds of megabytes of bitmap while the network tab shows two, which
is what runs a phone out of memory.
The compressed figures are rough and image-dependent. A photograph with
a lot of detail compresses far worse than a picture of a sky, and a
screenshot of text compresses better in PNG than in JPEG despite PNG
being lossless. Use them as an order of magnitude and measure the real
thing.
Resize before you compress. Serving a 6000-pixel-wide image into a
1200-pixel slot wastes both bandwidth and memory, and no amount of
compression quality fixes it: the decode cost is set by the pixel count,
not the file size.
PNG is the wrong format for a photograph and the right one for a
screenshot or anything with flat colour and sharp edges. JPEG is the
reverse. AVIF and WebP are smaller than both and cost more to encode,
which matters for a site that generates images on the fly.
Bit depth above 8 bits a channel is for editing, not delivery. A 16-bit
file holds the headroom that survives heavy adjustment; browsers and
screens almost all work in 8, so exporting at 16 doubles the size for
nothing.
Output is valid and updates as you type.
Fix the highlighted fields to update the output.
A 24-megapixel photograph is 72 MB uncompressed, about 4.5 MB as a JPEG, and 91.55 MiB in your browser’s memory once it is on screen.
That last number is the one nobody reports and the one that crashes phones. A decoded bitmap is four bytes a pixel whatever the file weighed, so a 2 MB JPEG at 6000 × 4000 occupies 91 MiB of memory to display. A page with a dozen of those holds a gigabyte of bitmap while the network tab shows twenty-four megabytes.
The other thing to be explicit about is the unit. A megabyte is 1,000,000 bytes and a mebibyte is 1,048,576, a difference of 4.9 percent, which is why a “500 GB” disk shows up as 465 GB.
How to use
- Put in the pixel dimensions.
- Pick the bit depth. 24 is ordinary colour; 32 adds alpha, and is what a browser holds regardless.
- Set a frame count for video or an animation.
Example
Pixels 6,000 × 4,000
megapixels 24.00
Uncompressed
bytes 72,000,000
in MB, 1,000,000 bytes 72.00 MB
in MiB, 1,048,576 bytes 68.66 MiB
the difference 4.9%, which is why a 500 GB disk shows as 465 GB
In memory, once decoded 91.55 MiB
why a browser holds four bytes a pixel whatever the file size
Roughly, as a file
PNG, lossless 36.00 MB, about 1 in 2
JPEG at quality 85 4.50 MB, about 1 in 16
WebP at quality 80 3.00 MB, about 1 in 24
AVIF at quality 60 1.80 MB, about 1 in 40
What fits
images in 1 GB, uncompressed 13.9
images in 1 GB, as JPEG 222
Pitfalls
The decoded size does not depend on the file size. Compressing harder makes the download smaller and the memory identical. The only way to reduce the memory is fewer pixels.
Serve the size you display. A 6000-pixel image in a 1200-pixel slot costs 25 times the memory of the
one you needed, and no compression setting fixes it. srcset and sizes exist for this.
MB and MiB are not the same and both are called “MB”. Storage is sold in decimal, most operating systems display binary, and RAM is always binary. The 4.9 percent gap grows to 7.4 percent at the gigabyte and 10 at the terabyte.
The compressed figures are rough. A detailed photograph compresses far worse than a picture of a sky, and a screenshot of text compresses better as a lossless PNG than as a JPEG despite PNG being larger for photographs. Use these as an order of magnitude and measure the real file.
PNG is wrong for photographs and right for screenshots. Flat colour and sharp edges compress well losslessly and badly with JPEG, which puts visible artefacts around text. The choice is about the image, not about quality settings.
Bit depth above 8 bits a channel is for editing, not delivery. A 16-bit file holds the headroom that survives heavy adjustment. Screens and browsers almost all work in 8, so exporting at 16 doubles the size for nothing.
Video is not frames times this. Interframe compression means a video is far smaller than its frames added up, because most frames are stored as differences. The frame count here gives you the uncompressed volume, which is what a capture or an editing timeline needs.
Compatibility
Arithmetic in the browser: nothing is uploaded and nothing is stored, and no image is read.
The uncompressed figure is width × height × bits ÷ 8, exactly. The decoded figure is four bytes a pixel, which is what browsers use for a bitmap regardless of the source format, so it is the same whether the file was an 8-bit PNG or a 16-bit TIFF.
The per-format estimates are bits per pixel at a sensible quality for a photographic image: 12 for PNG, 1.5 for JPEG at quality 85, 1 for WebP at 80, 0.6 for AVIF at 60. They are illustrative and image dependent.
Both unit families are shown side by side rather than one being chosen, because the ambiguity is the problem and picking one silently continues it.