Dictionary

What Is Background Color?

Background color is a default color for the space behind an image. PNG, GIF, and animated WebP files can store it as a short row of numbers.

background-color

Background color is a color that an image file suggests for the area behind the picture. A viewer can use it to fill the empty space around the image and the transparent parts of the image. The color is only a suggestion, and a program does not have to use it.

Which files carry it

A background color can appear in 3 common image formats:

  • PNG files store the background color in an optional part of the file called the bKGD chunk.
  • GIF files store the background color in the logical screen descriptor, a header that every GIF file must have.
  • Animated WebP files store the background color in the ANIM chunk.

Less common formats, such as MNG animations, have the field too. Because the GIF header is required, every GIF file has a background color value, even when nothing uses it.

What the value looks like

In a metadata report, the background color is a short row of numbers. How many numbers you see depends on the format and the type of image:

  • A GIF file shows one number: a position in the file's color table, also called the palette.
  • A PNG file with a palette also shows one number: a position in that palette.
  • A grayscale PNG file shows one number: a gray level, where 0 is black.
  • A color PNG file shows 3 numbers: red, green, and blue, in that order.
  • An animated WebP file shows 4 numbers: blue, green, red, and alpha, in that order. Alpha says how solid the color is, from 0 for fully transparent to 255 for fully opaque.

For grayscale and color PNG files, the range depends on the image's bit depth. In an 8-bit image, each number runs from 0 to 255. In a 16-bit image, the highest value is 65535.

How the numbers become a color

An RGB triplet is a set of 3 numbers for red, green, and blue light. Each number says how much of that light is in the mix. For example, the values 83 57 124 in an 8-bit color PNG file describe a dark purple.

Web pages and graphics programs can write the same color as a hexadecimal code. In an 8-bit image, each of the 3 numbers becomes a pair of characters from 00 to FF, which stands for 0 to 255. So 83 57 124 becomes #53397C.

A 16-bit color PNG file needs one more step. Each value has to be scaled down to the range 0 to 255 first.

A single number in a GIF file or a palette PNG is not a color by itself. The number points to an entry in the palette, and that entry holds the red, green, and blue values.

Where the value comes from

In a PNG file, the program that saves the image decides whether to write a background color. GIF and animated WebP files always have the field, so the program only chooses the value.

GIMP, for example, offers a "Save background color" option when you export a PNG file. GIMP then stores the background color that is selected in its toolbox.

Why it matters

The stored color often has no visible effect. The PNG specification tells viewers to ignore the background color when they have a better background. The web page around an image in a browser is one example.

In animations, the field can matter more. Both GIF and WebP let a frame restore its area to the background color after the frame has been shown.

The field holds only a color. It contains no personal information and says nothing about a camera or a place.