DIGITAL QUANTITY WORKSHEETS

Comparing raw pixel depths without predicting compressed size

A raw pixel layout fixes the number of bits for every pixel, so its size follows from arithmetic. A compressed file does not, and this worksheet keeps the two apart.

What a raw size counts

The Uncompressed Image Size Calculator multiplies width, height and bits per pixel, divides by 8, and rounds up to whole bytes for each frame. The result is the size of a pixel buffer with no header, no padding and no compression: every pixel takes the same number of bits, and nothing is saved when neighboring pixels are alike. That quantity describes memory for an image held as plain pixel data. A file saved in a compressed format such as PNG or JPEG may be far smaller, or occasionally larger, and its size depends on the image content, which this arithmetic cannot see.

24 and 32 bits on a 100 by 100 image

A 100 by 100 image has 10,000 pixels. At 24 bits per pixel, that is 240,000 bits, or 30,000 bytes. At 32 bits per pixel it is 320,000 bits, or 40,000 bytes. The difference of 10,000 bytes comes from the 8 extra bits given to every one of the 10,000 pixels, which is 80,000 bits. The two layouts are common: 24 bits often stores red, green and blue at 8 bits each, and 32 bits often adds an 8-bit channel such as transparency, or padding that aligns each pixel to a 4-byte boundary.

Scaling up to a screen-sized image

The same arithmetic applies to larger images. A 1,920 by 1,080 image has 2,073,600 pixels. At 24 bits it needs 6,220,800 bytes, and at 32 bits 8,294,400 bytes, about 6.22 and 8.29 decimal megabytes. A 3,840 by 2,160 image has four times as many pixels, 8,294,400, and takes 24,883,200 bytes at 24 bits. Multiply the pixel count by the bytes per pixel and the answer is immediate. Such figures are what a program needs to hold the decoded image in memory, regardless of how small the file on disk is.

Other depths in common use

Depths other than 24 and 32 appear often. An 8-bit grayscale image of 100 by 100 pixels takes 10,000 bytes. A 16-bit grayscale or a 16-bit color layout takes 20,000 bytes. A 48-bit layout, which gives 16 bits to each of three channels, takes 60,000 bytes. A 3,840 by 2,160 image with 10 bits per channel and three channels uses 30 bits per pixel and 31,104,000 bytes. Depth in the formula is the total per pixel, so a three-channel format at 10 bits per channel is entered as 30. The calculator does not know about channels. Higher depths are common in scientific and professional imaging, where 12 or 16 bits per channel preserve more tonal steps: 65,536 levels at 16 bits against 256 at 8 bits. Raw files from cameras often hold 12 to 14 bits per photosite, and the page can estimate a plain packed size for them, subject to the format's own packing rules.

Why the file on disk can differ

Compression changes the picture. Lossless methods find repeated patterns and store them compactly, so an image with large flat areas can shrink dramatically, while noisy photographs shrink less. Lossy methods discard detail the viewer is unlikely to notice and can reach much smaller sizes. Headers and metadata add a small fixed amount. Because all of this depends on the content and the settings used, a single multiplication cannot predict a compressed size. The raw number is an upper reference point for plain pixel storage, and a real file may be anywhere relative to it.

Memory buffers can differ too

Even for raw data, the buffer a program uses may not equal the figure here. Some systems pad each row of pixels to a multiple of 4 bytes or more. Some store a full 32 bits per pixel even for a 24-bit image, to keep pixels aligned. Graphics hardware may add alignment or store mipmaps. When the exact allocation matters, read the specification of the API or format for the stride and padding rules. The page computes a tight packing under the stated depth, which is a baseline for comparison. A 100 by 100 image at 24 bits has 3 bytes per pixel and rows of 300 bytes, a multiple of 4, so padding adds nothing there. A 101-pixel-wide row of 303 bytes would be padded to 304 under a 4-byte row rule, and the buffer grows accordingly.

Comparing two layouts in a decision

The two-depth comparison is useful when choosing a layout. Moving from 24 to 32 bits increases a raw buffer by one third, since 32 / 24 = 1.3333, and moving from 8 to 24 bits triples it. Those ratios hold for any image size because the pixel count cancels. If an application stores many frames, the ratio multiplies the total. Running both depths through the calculator for your resolution gives absolute figures to set against available memory or bandwidth. The percentage increase shows what you are paying for the extra channel. For a 1,920 by 1,080 image the step from 24 to 32 bits adds 2,073,600 bytes, from 6,220,800 to 8,294,400. For a 240-frame sequence the addition is 240 times that, about 498 decimal megabytes, which is a lot of memory for a channel that some applications never read. Whether the alignment benefit of 32-bit pixels is worth that cost is a design decision for the application.

Hold the dimensions fixed

The worksheet changes one thing at a time. Both runs use 100 by 100 pixels and one frame, so the only difference is the depth. That makes the cause of the size difference clear. When comparing real cases, be careful to change only what you mean to. Resizing the image and changing its depth in the same step mixes two effects. Compare like with like: first the same dimensions at two depths, then the same depth at two dimensions, and only then a combination.

Scope of the claim

The calculation counts supplied bits per pixel and rounds each frame to whole bytes. It does not infer which bits mean red, green, blue or alpha, and it does not know about color spaces, headers, row strides or compression. Treat the output as the size of a plain pixel buffer under the stated assumptions, and check the format documentation before using it as a memory or disk allocation. If the goal is the size of a particular file, measure the file itself. If the goal is memory for a decoded image, add the allowances the platform documents, and if the goal is a transfer estimate, use the real file size and not the raw figure. Each purpose points to a different number, and this page supplies only the first of them.

Reproduce the checks

Twenty-four-bit layout

Open the Uncompressed Image Size Calculator and enter:

Width
100
Height
100
Bits per pixel
24
Frames
1

Expected output:

Uncompressed size

30000

The calculation uses the stated raw depth.

Thirty-two-bit layout

Open the Uncompressed Image Size Calculator and enter:

Width
100
Height
100
Bits per pixel
32
Frames
1

Expected output:

Uncompressed size

40000

Extra allocated bits increase the raw count.

References and implementation scope

The examples describe the behavior of the linked Computandum tools. A successful local check does not establish that another application accepts the same format or applies the same limits.

Sources

Related tasks