How do I invert screen colors by value?

The most common way to invert colors is to use RGB-negation. Unfortunately, it's not very beautiful: blue becomes yellow, green becomes magenta, etc.

What I want is to invert value, one of the components among hue and saturation. This way, dark colors will become light, light become dark, but blue remains blue-ish anyway.

Example output (created with GIMP, doesn't work on the whole screen):

orig => value-inverted

The goal is to have the entire screen "inverted", so you can read PDF-s, firefox, instant messaging -- all in dark colors.

2 Answers 2


There is a solution involving OpenGL-based compositors (compton, for example) and a custom made shader (*.glsl).

Here is the observation of the technique, along with the shader file: https://github.com/vn971/linux-color-inversion

  • // After ~3 years, I finally found a solution that works! Really happy. If you know the benefits of color inversion, I hope you like it, too. Feb 25, 2017 at 16:40

You can use ImageMagick tool with the color-matrix option:

This option permits saturation changes, hue rotation, luminance to alpha, and various other effects. Although variable-sized transformation matrices can be used, typically one uses a 5x5 matrix for an RGBA image and a 6x6 for CMYKA (or RGBA with offsets). The matrix is similar to those used by Adobe Flash except offsets are in column 6 rather than 5 (in support of CMYKA images) and offsets are normalized (divide Flash offset by 255).

As an example, to add contrast to an image with offsets, try this command:

convert kittens.jpg -color-matrix \
    " 1.5 0.0 0.0 0.0, 0.0, -0.157 \
     0.0 1.5 0.0 0.0, 0.0, -0.157 \
     0.0 0.0 1.5 0.0, 0.0, -0.157 \
     0.0 0.0 0.0 1.0, 0.0,  0.0 \
     0.0 0.0 0.0 0.0, 1.0,  0.0 \
     0.0 0.0 0.0 0.0, 0.0,  1.0" kittens.png
  • Unfortunately, it doesn't work for inverting the whole screen area.. It's just for images. Sep 8, 2014 at 16:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .