Skip to content

Brightness, saturation, and hue adjustment

Copy page

These operations all change pixel appearance, but they are not interchangeable: brightness changes lightness, saturation changes colour intensity, and hue rotates a colour around the wheel. Each section covers one variant and pairs its image with the corresponding code.

Gate of the Orient night photograph used for colour adjustments
Input: JPEG1938 × 1292, a maintainer-owned photograph with embedded sRGB ICC

Reference outputs were generated with govips v2.19.0 / libvips 8.17.3. Each binding has a corresponding output; pyvips and CLI saturation/hue files are currently unmodified placeholders marked not-supported.

govips.Modulate(1.25, 1, 0) raises brightness in LCh; sharp uses HSL semantics. The pyvips and CLI snippets use RGB linear multiplication as an approximation, not a pixel-equivalent implementation.

Gate of the Orient night photograph used for colour adjustments
Original · JPEG
Gate of the Orient night photograph with increased brightness
Brightness adjustment · WEBP1938 × 1292, 490,880 bytes, 3 bands

Generated with govips v2.19.0 / libvips 8.17.3.

image, err := vips.NewImageFromFile("input.jpg")
if err != nil { return err }
defer image.Close()
if err := image.Modulate(1.25, 1, 0); err != nil { return err }
data, _, err := image.ExportWebp(vips.NewWebpExportParams())
if err != nil { return err }
return os.WriteFile("brightness.webp", data, 0o644)

govips and sharp expose a direct modulation entry point. The current pyvips and CLI paths preserve the input and mark the result not-supported: they run, but do not claim to have performed a saturation transform.

Gate of the Orient night photograph used for colour adjustments
Original · JPEG
Gate of the Orient night photograph with reduced saturation
Saturation adjustment · WEBP1938 × 1292, 374,512 bytes, 3 bands

Generated with govips v2.19.0 / libvips 8.17.3.

if err := image.Modulate(1, 0.35, 0); err != nil { return err }

Hue is an angular offset; 60 means a 60-degree rotation. govips performs Modulate in LCh, while sharp uses HSL, so equal numbers do not guarantee equal pixels.

Gate of the Orient night photograph used for colour adjustments
Original · JPEG
Gate of the Orient night photograph with rotated hue
Hue adjustment · WEBP1938 × 1292, 393,624 bytes, 3 bands

Generated with govips v2.19.0 / libvips 8.17.3.

if err := image.Modulate(1, 1, 60); err != nil { return err }