Skip to content

Bands, alpha, and transparency

Copy page

An alpha channel is an extra band that describes coverage, but a four-band image does not automatically prove that the fourth band is alpha. You also need the image interpretation, format, and metadata.

Translucent purple rings, coloured dots, and a white check mark on a transparent background
Input: SVG720 × 480, transparent background
The ring graphic resized with its translucent edges and transparent background preserved
Alpha preserved: PNG240 × 160, 4 bands, 35,763 bytes
The transparent ring graphic flattened onto a pale violet background
Flattened: WebP240 × 160, 3 bands, background #f0e6f2

The checkerboard only visualizes transparency and is not part of the image pixels.

In a typical 8-bit RGBA image, alpha 0 is fully transparent and 255 is fully opaque. Floating-point images and other bit depths can use different ranges, so a general pipeline should not hard-code 0..255.

A transparent pixel still carries colour values. An invisible pixel can be “transparent black” or “transparent white,” and those hidden values can affect edges during resize, blur, or compositing.

Premultiplied alpha scales colour bands by alpha first. Some convolution and interpolation operations behave more reliably in this representation, but the image usually needs to be returned to the representation expected by the output saver.

A robust sequence is often:

  1. Confirm that the image really has alpha.
  2. Premultiply before operations that need it.
  3. Resize, blur, or composite.
  4. Unpremultiply.
  5. Preserve alpha or flatten onto a background according to the output format.

This page’s govips example calls Resize. In the pinned v2.19.0 source, that method runs PremultiplyAlpha before resizing and UnpremultiplyAlpha afterwards. This is verified, version-specific binding behavior—not a default guarantee for every operation or binding.