Skip to main content
Bethemesh
ReferenceConcepts and technologies

How Is a Digital Image Built?

Understand how pixels, color channels, bit depth, and transparency come together to form an image displayed on a screen.

Published 31 August 2026Reading : 15 minBy Bethemesh Team
Beginner
Magnified diagram of an image showing its pixel grid and red, green, blue, and alpha channels
Show contents
  1. A digital image is a representation, not the scene itself
  2. What exactly is a pixel?
  3. A color pixel contains several components
  4. Channels can be examined separately
  5. Bit depth determines the available precision
  6. The alpha channel adds opacity
  7. Why can a fully transparent pixel still have a color?
  8. Raster and vector images describe graphics differently
  9. Dimensions do not tell you the file size
  10. File size does not tell you the dimensions either
  11. File format is a container and encoding choice
  12. Lossless and lossy representations
  13. Why enlarging a raster image does not create original detail
  14. Why reducing dimensions can save so much data
  15. Resampling changes the pixel grid
  16. Aspect ratio describes shape, not resolution
  17. Cropping is different from resizing
  18. What happens when a browser displays an image?
  19. Compressed size and decoded memory are different
  20. Metadata lives alongside visual content
  21. Orientation demonstrates why metadata can affect appearance
  22. Color profiles affect interpretation
  23. A pixel is not the same thing as a screen subpixel
  24. CSS pixels add another layer
  25. Why “Retina” images are usually larger source images
  26. Images are ultimately data structures
  27. A practical example: preparing a photograph for a website
  28. Common misconceptions
  29. “A pixel is always a square of a fixed physical size”
  30. “More megapixels always means a better image”
  31. “A PNG is sharper than a JPEG because PNG has more pixels”
  32. “Transparency means white”
  33. “Changing the extension converts the image”
  34. “A 300 DPI image is automatically better on the Web”
  35. “A small compressed file uses little memory”
  36. “Metadata never affects rendering”
  37. A useful mental model
  38. What to remember
  39. Frequently asked questions
  40. What is a pixel?
  41. Is a pixel physically square?
  42. What does RGB mean?
  43. Why do RGB values often range from 0 to 255?
  44. What is an alpha channel?
  45. Is transparent the same as white?
  46. What is bit depth?
  47. Does higher bit depth always improve a Web image?
  48. What is a megapixel?
  49. Does a 12-megapixel image always look better than an 8-megapixel image?
  50. Why can two images with the same dimensions have different file sizes?
  51. Can I convert JPEG to PNG by renaming the extension?
  52. Why does a raster image become blurry when enlarged?
  53. What is the difference between resizing and cropping?
  54. Why can a transparent pixel still contain RGB values?
  55. What are image metadata?
  56. What is the difference between an image pixel and a CSS pixel?
  57. What should I learn next?

A photograph displayed on a screen appears continuous: a sky forms a smooth gradient, a face contains subtle shades, and edges look clean. Yet a raster digital image contains no concept of a “sky,” a “face,” or an “edge.” At its core, it contains a grid of numerical values that a browser, display, or application turns into visible colors.

Understanding this anatomy is useful far beyond theory. It explains why an image becomes blurry when enlarged, why PNG can preserve transparency, why two images with identical dimensions can have very different file sizes, and why simply renaming .jpg to .png does not convert a file.

This structure is also the starting point for the entire Web image optimization workflow. Before choosing a suitable image resolution, a format such as PNG, JPEG, WebP, or AVIF, or a compression strategy, you need to understand what is actually being manipulated.

A digital image is a representation, not the scene itself

When a camera captures a scene, it does not literally store “a tree in front of a house.” Its sensor measures light. Those measurements are processed, interpreted, and recorded digitally.

For a raster image—also called a bitmap—the final result can be imagined as a table made of rows and columns. Each position contains information that determines how that part of the image should appear.

A 1,200 × 800 image contains:

1,200 × 800 = 960,000 pixels.

A 4,000 × 3,000 image contains 12 million pixels. That is the origin of the term “12 megapixels”: one megapixel is approximately one million pixels.

More pixels, however, do not automatically mean a better image. Pixel count mainly describes how many samples are available. Final sharpness also depends on capture quality, optics, focus, noise, compression, resizing, and the size at which the image is displayed.

You can inspect dimensions and other file properties with the image metadata reader.

What exactly is a pixel?

The word pixel comes from picture element. It is commonly represented as a tiny square, especially when an image editor is zoomed in.

That representation is useful, but slightly misleading.

Inside a file, a pixel is not literally a physical square. It is better understood as a sample at a given position in a grid, associated with one or more numerical values.

When you zoom a photograph to 800% and see large colored blocks, the software is not revealing hidden squares. It is enlarging the display area assigned to each sample so that the grid becomes visible.

This leads to an essential point: a pixel has no universal physical size.

The same 1,200-pixel-wide file can be displayed at 300 CSS pixels on one page, 600 CSS pixels elsewhere, printed across several centimeters, or shown at native size in an editor.

The relationship between file dimensions and display size is explored in What Image Resolution Should You Choose?.

A color pixel contains several components

In a typical color image intended for the Web, one value is usually not enough to describe a pixel. Color is separated into channels.

The most familiar screen model is RGB:

  • R for red;
  • G for green;
  • B for blue.

Each channel describes the intensity of one component. The browser combines the three values to produce the visible color.

With 8 bits per channel, each component has 256 possible values, usually represented from 0 to 255.

Examples:

  • R=0, G=0, B=0 produces black;
  • R=255, G=255, B=255 produces white;
  • R=255, G=0, B=0 produces maximum red;
  • R=255, G=255, B=0 combines red and green to produce yellow.

Three 8-bit channels provide 24 bits of color per pixel:

256 × 256 × 256 = 16,777,216 combinations.

That is where the familiar expression “16.7 million colors” comes from.

To understand how these colors are written in Web development, see RGB, HEX, or HSL: Which Notation Should You Use?. The color converter can then convert between common representations.

Channels can be examined separately

An RGB photograph can be viewed as three intensity images superimposed: one red, one green, and one blue.

A bright area in the red channel means that red contributes strongly there. A dark area means that it contributes little.

This separation is fundamental to image processing. Many operations work on channels before recombining them: color correction, white balance, color extraction, filters, contrast detection, or conversions between color spaces.

The image color extractor works on decoded image data. The browser first converts the file into usable pixels, then the tool analyzes their colors.

This distinction matters: once a JPEG, PNG, or WebP file has been decoded, pixel colors can be analyzed through a common representation.

Bit depth determines the available precision

Saying that a channel uses 8 bits means that eight binary digits are available to represent its value.

With 8 bits:

2⁸ = 256 levels.

With 16 bits:

2¹⁶ = 65,536 levels.

Greater bit depth therefore allows more intermediate values. This can be valuable during substantial editing, particularly in gradients, shadows, and exposure corrections.

Imagine a gradient from dark blue to light blue. If too few levels are available, transitions can become visible as distinct bands. This artifact is known as banding.

Higher precision can reduce that risk during editing, but it also increases the amount of data being handled. A working file may therefore preserve more information than its final Web-optimized derivative.

Do not confuse:

  • bit depth, which determines how many values can be represented;
  • color space, which determines what real colors those values refer to;
  • file format, which determines how data is organized and compressed.

They interact, but they describe different properties.

The alpha channel adds opacity

RGB describes color. RGBA adds a fourth channel: alpha.

Alpha is not a fourth color. It represents pixel opacity.

In an 8-bit representation:

  • alpha 0 means fully transparent;
  • alpha 255 means fully opaque;
  • intermediate values create partial transparency.

This is why transparent does not mean white.

A red logo on a transparent background lets whatever lies behind the image remain visible. Replacing transparent areas with white might look correct on a white page but immediately create a white rectangle on a dark background.

Transparency allows the image to be composited with different backgrounds.

Classic JPEG does not provide an alpha channel, while PNG, WebP, and AVIF can support transparency. See PNG, JPEG, WebP, or AVIF: Which Image Format Should You Choose?.

Why can a fully transparent pixel still have a color?

A pixel may store RGB values even when its alpha makes it invisible.

For example:

  • red: 255;
  • green: 0;
  • blue: 0;
  • alpha: 0.

Visually it is transparent, yet its underlying color is red.

Those hidden values can matter when software resizes an image or interpolates edges. Poor handling can create light or dark halos around a cut-out object.

Alpha handling is therefore subtler than a simple “transparency” switch.

You may also encounter premultiplied alpha and straight alpha. With premultiplied alpha, color components are already multiplied by opacity; with straight alpha, color and alpha remain independent. Rendering engines can convert between these representations internally.

For most Web authors, the important practical rule is simpler: when a graphic needs transparency, preserve it through every stage of the workflow and inspect the final result against the backgrounds on which it will appear.

Raster and vector images describe graphics differently

Everything above primarily concerns raster images.

A raster image stores a finite grid of samples. A vector image instead describes shapes mathematically: paths, points, curves, fills, and strokes.

That is why an SVG logo can remain sharp when enlarged while a small PNG eventually reveals its pixel structure.

Neither approach is universally better.

Raster is naturally suited to photographs and complex continuous imagery. Vector graphics are excellent for many logos, icons, diagrams, and illustrations.

The choice of representation should follow the content.

Dimensions do not tell you the file size

Two images can both be 1,920 × 1,080 pixels and still have radically different file sizes.

Why?

Because file size depends on much more than dimensions:

  • format;
  • compression method;
  • compression level;
  • image complexity;
  • bit depth;
  • alpha;
  • metadata;
  • color profile.

A flat graphic can compress very differently from a detailed photograph even at the same dimensions.

This is why “1,920 × 1,080” describes pixel dimensions, not storage weight.

File size does not tell you the dimensions either

The inverse is equally important.

A 500 KB image could be:

  • a large, heavily compressed photograph;
  • a smaller lossless image;
  • a complex PNG with transparency;
  • another format with different encoding choices.

Do not infer dimensions from megabytes alone.

Inspect the file.

File format is a container and encoding choice

JPEG, PNG, WebP, and AVIF do not change the basic fact that a raster image eventually becomes pixels for display.

They differ in how they represent and compress information and in the features they support.

A browser may:

read compressed file
→ decode image
→ obtain pixel data
→ composite it
→ display it

This explains why changing the filename extension cannot perform a conversion. The internal representation must actually be decoded and encoded in the target format.

Use the image converter when a genuine format conversion is required.

Lossless and lossy representations

Compression can preserve all decoded information or deliberately discard some information to reduce file size.

Lossless compression allows the original represented data to be reconstructed exactly.

Lossy compression accepts controlled changes to obtain a smaller file.

For photographs, lossy compression can often produce major savings with little visible difference at normal viewing sizes.

For graphics containing sharp text, line art, or transparency, a different strategy may be preferable.

The detailed trade-offs are covered in How to Compress an Image Without Unnecessary Quality Loss.

Why enlarging a raster image does not create original detail

Suppose you have a 400 × 300 image and enlarge it to 1,600 × 1,200.

The software must create new samples between existing ones.

It can interpolate intelligently, but it cannot recover details that were never present in the source.

This is why resizing upward may make an image smoother than nearest-neighbor enlargement while still not restoring genuine captured information.

AI upscaling can infer plausible detail, but inferred content is not the same as recovering the original scene.

For ordinary Web production, the safest strategy is to keep a sufficiently large master and generate smaller derivatives from it.

Why reducing dimensions can save so much data

A 4,000 × 3,000 image contains 12 million pixels.

A 1,000 × 750 version contains 750,000.

That is sixteen times fewer pixels.

Compressed file size will not necessarily fall by exactly the same factor, but the amount of visual data to encode has changed dramatically.

This is why resizing oversized photographs before aggressive compression is often one of the most effective Web optimizations.

Use the image resizer while preserving the intended aspect ratio.

Resampling changes the pixel grid

When dimensions change, software must calculate a new grid.

This process is called resampling.

Downsampling combines information from multiple source pixels. Upsampling estimates additional samples.

Different interpolation filters can produce different results around:

  • fine details;
  • text;
  • sharp edges;
  • high-frequency patterns.

For most Web workflows, the practical priority is to start from a good source and avoid repeated resampling.

Generate each final size from the master rather than repeatedly resizing an already resized derivative.

Aspect ratio describes shape, not resolution

An image can be:

1600 × 900

and another:

800 × 450

Both have a 16:9 aspect ratio.

The second contains fewer pixels, but their shape is identical.

Aspect ratio matters when resizing because changing width and height independently can distort the content.

Use the aspect ratio calculator when one dimension is known and the other must preserve the original proportions.

Cropping is different from resizing

Resizing changes the number of pixels representing the same overall composition.

Cropping removes part of the image.

A 1,600 × 900 photograph can be resized to 800 × 450 without changing its framing.

Cropping it to a square changes what is included in the frame.

This distinction becomes important for responsive art direction, where mobile and desktop may intentionally use different crops rather than simply different resolutions.

What happens when a browser displays an image?

A simplified rendering path looks like this:

file downloaded
→ file decoded
→ pixel representation obtained
→ color/transparency interpreted
→ image scaled if necessary
→ image composited with page
→ pixels sent to display pipeline

The exact browser and GPU pipeline is more sophisticated, but this model is useful.

It shows that transfer size, decoded dimensions, and displayed dimensions are related yet distinct.

A highly compressed 5,000 × 5,000 image may be relatively small on the network while still requiring substantial memory once decoded.

Compressed size and decoded memory are different

Imagine an RGBA image of 4,000 × 3,000 pixels.

That is 12 million pixels.

A simple 8-bit RGBA representation uses four bytes per pixel:

12,000,000 × 4 ≈ 48 MB.

The source file might be only a few megabytes—or less—because compression reduces storage and transfer size.

But the decoded image can still occupy much more memory.

This is another reason not to serve unnecessarily huge dimensions.

Metadata lives alongside visual content

An image file can contain information that is not directly visible in the pixels:

  • camera model;
  • capture date;
  • GPS location;
  • orientation;
  • copyright;
  • software information;
  • color profiles.

These are broadly referred to as metadata.

They can be useful, unnecessary, or sensitive depending on context.

The image metadata reader lets you inspect such information. The dedicated guide Image Metadata: Read It, Keep It, or Remove It? explains how to decide what belongs in a public derivative.

Orientation demonstrates why metadata can affect appearance

Some photographs store pixel data in one orientation and include metadata telling software how to rotate it for display.

If that information is removed incorrectly, the image may appear sideways.

This illustrates an important rule: not every byte outside the visible pixel array is automatically useless.

Optimization should be informed rather than destructive.

Color profiles affect interpretation

Numerical RGB values only become fully meaningful when their color interpretation is known.

Color profiles can help applications understand how values map to actual colors.

For ordinary Web work, sRGB remains a common reference, while modern CSS and displays can support wider gamuts in appropriate contexts.

The key idea is that the numbers 255, 0, 0 describe coordinates within a color model; the exact displayed color also depends on how that model and color space are interpreted.

A pixel is not the same thing as a screen subpixel

Displays often produce a pixel using several physical light-emitting components or subpixels.

The arrangement varies by display technology.

This hardware detail should not be confused with the logical pixel samples in an image file.

A file pixel is data. A display pixel is part of physical rendering hardware. CSS pixels are a layout abstraction.

They interact, but they are not interchangeable concepts.

CSS pixels add another layer

A browser lays out pages using CSS pixels.

An image might contain 1,200 source pixels while being displayed at 600 CSS pixels.

On a high-density display, those 600 CSS pixels may correspond to more than 600 physical display pixels.

That is why image resolution for the Web cannot be understood only by looking at the file.

The next article, What Image Resolution Should You Choose?, develops this relationship in detail.

Why “Retina” images are usually larger source images

A common pattern is to provide an image with twice the source dimensions for a display slot.

For example:

display width: 400 CSS px
source width: 800 px

This can provide additional detail on a high-density screen.

But serving the 800-pixel file to every possible 200-pixel slot is not always efficient.

Responsive image techniques let browsers choose among several candidates.

See Responsive Images: Understanding srcset and sizes.

Images are ultimately data structures

Thinking about images as data helps connect many apparently separate Web topics.

A color picker reads numerical channels.

A palette extractor groups pixel values.

A resizer creates a new sample grid.

A compressor changes how information is encoded.

A metadata reader inspects auxiliary fields.

A responsive image system chooses among multiple encoded representations.

These tools operate at different layers of the same object.

A practical example: preparing a photograph for a website

Suppose your camera produces:

4032 × 3024 JPEG
5.8 MB

The image will appear in an article column no wider than 800 CSS pixels.

A sensible workflow might be:

  1. keep the original as a master;
  2. inspect dimensions and metadata;
  3. determine the largest useful source dimensions;
  4. create smaller variants;
  5. choose an appropriate format;
  6. compress to a visually acceptable level;
  7. remove unnecessary public metadata if appropriate;
  8. declare responsive candidates in HTML.

Every step becomes easier to reason about once you distinguish pixels, dimensions, format, compression, and metadata.

Common misconceptions

“A pixel is always a square of a fixed physical size”

No. A file pixel is a sample. Its physical display size depends on the rendering context.

“More megapixels always means a better image”

No. More samples can provide more detail, but capture quality and intended display size matter.

“A PNG is sharper than a JPEG because PNG has more pixels”

Not necessarily. Format and dimensions are different properties.

“Transparency means white”

No. Transparency allows the background to show through.

“Changing the extension converts the image”

No. The file must be decoded and re-encoded.

“A 300 DPI image is automatically better on the Web”

No. For Web display, actual pixel dimensions and display context matter far more than a DPI metadata value.

“A small compressed file uses little memory”

Not necessarily. A large-dimension image can expand substantially when decoded.

“Metadata never affects rendering”

False. Orientation and color-related information are examples where auxiliary data can matter.

A useful mental model

When you encounter an image, separate these questions:

What does it contain?
→ pixels / vector shapes

How much pixel information?
→ dimensions and bit depth

How are colors represented?
→ channels and color space

Can it be transparent?
→ alpha / format capabilities

How is it stored?
→ file format and compression

What else travels with it?
→ metadata

How large is it displayed?
→ CSS layout

How many source pixels are useful?
→ resolution strategy

This model prevents many common optimization mistakes.

What to remember

A raster digital image is fundamentally a grid of numerical samples.

Each pixel can contain several channels, usually red, green, and blue, with alpha added when transparency is needed. Bit depth determines how many values each channel can represent.

Pixel dimensions describe how many samples the image contains. They do not directly describe physical size, file size, or visual quality.

The file format determines how the information is stored and compressed. Metadata can add context beyond the visible image. The browser eventually decodes all of this into something it can render.

Once these layers are separated, the rest of Web image work becomes much clearer.

The natural next step is What Image Resolution Should You Choose?: how many of those pixels do you actually need?

Frequently asked questions

What is a pixel?

A pixel is an image sample located at a position in a raster grid and associated with values describing its appearance.

Is a pixel physically square?

Not in the file. Editors often display pixels as squares for convenience, while physical display technology and rendering context are separate issues.

What does RGB mean?

RGB stands for red, green, and blue. These channels are combined to represent colors on screens.

Why do RGB values often range from 0 to 255?

Because 8 bits provide 256 possible values per channel: 0 through 255.

What is an alpha channel?

It is a channel that represents opacity. It allows pixels to be fully opaque, fully transparent, or partially transparent.

Is transparent the same as white?

No. A transparent pixel lets the background show through; a white pixel is opaque white unless its alpha says otherwise.

What is bit depth?

Bit depth describes how many bits are available to represent values in a channel. Greater depth provides more possible levels.

Does higher bit depth always improve a Web image?

Not necessarily. It is valuable in some editing and color workflows, but final Web delivery must balance precision, format support, and file size.

What is a megapixel?

Approximately one million pixels. A 4,000 × 3,000 image contains 12 million pixels, or about 12 megapixels.

Does a 12-megapixel image always look better than an 8-megapixel image?

No. Lens quality, sensor quality, focus, noise, processing, compression, and display size all matter.

Why can two images with the same dimensions have different file sizes?

Because format, compression, content complexity, bit depth, transparency, metadata, and other factors affect storage.

Can I convert JPEG to PNG by renaming the extension?

No. A real conversion requires decoding the source and encoding it in the target format.

Why does a raster image become blurry when enlarged?

Because enlargement must estimate new samples between the original pixels; it cannot recreate detail that was never captured.

What is the difference between resizing and cropping?

Resizing changes the pixel grid representing the image. Cropping removes part of the composition.

Why can a transparent pixel still contain RGB values?

Color and opacity can be stored separately. The RGB value may remain even when alpha makes the pixel invisible.

What are image metadata?

They are auxiliary information such as capture date, camera model, GPS data, orientation, rights information, or color profiles.

What is the difference between an image pixel and a CSS pixel?

An image pixel belongs to the source raster. A CSS pixel is a browser layout unit. One source pixel does not necessarily map to one CSS pixel.

What should I learn next?

Continue with What Image Resolution Should You Choose?, then compare image formats and compression strategies.

Related tools

Images & graphics

Image metadata reader

Inspect image dimensions, format, size and browser-readable metadata.

100% local
Use this tool
Images & graphics

Image color extractor

Extract a dominant color palette from an image without uploading it to a server.

100% local
Use this tool

Sources and references

  1. 1.W3C — Portable Network Graphics (PNG) Specification, Third Edition
  2. 2.MDN Web Docs — Pixel manipulation with canvas
  3. 3.MDN Web Docs — ImageData

Collection

Images for the Web

  1. 01How Is a Digital Image Built?
  2. 02What Image Resolution Should You Choose?
  3. 03RGB, HEX, or HSL: Which Color Notation Should You Use?
  4. 04How to Create a Color Palette From an Image
  5. 05WCAG Contrast: How to Make Colors Accessible
  6. 06PNG, JPEG, WebP, or AVIF: Which Image Format Should You Choose?
  7. 07How to Compress an Image Without Unnecessary Quality Loss
  8. 08SVG: Understanding the Vector Format
  9. 09How to Optimize an SVG Without Changing Its Appearance
  10. 10Optimize images for the Web without losing quality
  11. 11Responsive Images: Understanding srcset and sizes
  12. 12WebP, AVIF, JPEG XL: which image formats should you choose in 2026?
  13. 13Image Metadata: Read It, Keep It, or Remove It?
  14. 14How to Optimize Images for Web Performance
GuideConcepts and technologiesBeginner

What Image Resolution Should You Choose?

Distinguish pixel dimensions, pixel density, and DPI so you can resize images for the Web or print without unnecessary loss of sharpness.

31 August 202616 minRead

Was this article useful?