How to invert image colors, and when it goes wrong

September 27, 20267 min readBy the FreeImageTools teamMeasured and sourced
An astronaut portrait split down the middle, normal on the left and colour inverted on the right, with colour swatches showing each colour and its opposite

Inverting an image is the simplest edit there is. Every red, green and blue value is subtracted from 255, and that is the whole operation. Yet it does three things people rarely expect: it swaps every colour for its exact opposite, it changes contrast in ways that matter for dark mode designs, and a JPEG that is inverted and inverted back never quite returns to the original. We measured all three.

THE SHORT ANSWER
How do I invert an image?
Drop it into Invert Colors, check the preview and download. It runs in your browser, nothing is uploaded.
Can I undo an inversion?
Invert again. On PNG pixels the result is identical. Through JPEG saves it lands within 51 to 54 dB, which you cannot see.
What happens to the colours?
Every hue turns by exactly 180 degrees, saturation stays the same and lightness is mirrored. Red becomes cyan, orange becomes blue.
Why is my scanned negative blue?
Colour negative film has an orange base. Inverting turns that orange into blue, so it has to be removed first.
INVERSION BY THE NUMBERS
0
difference after inverting a PNG twice. The operation is exactly reversible on lossless pixels
52.7 dB
fidelity after inverting a JPEG and back at quality 92, averaged over 12 photos
4.48 → 5.92
contrast ratio of grey #777777 text on white before and after inverting both colours
180°
the exact hue shift inversion gives every colour, while saturation stays the same

What inverting does to each pixel

A pixel stores three numbers from 0 to 255. Inverting replaces each one with 255 minus itself, so 0 becomes 255, 255 becomes 0, and 100 becomes 155. Black and white swap places, and every colour lands on the value that sits the same distance from the other end of the scale.

ColourRGBInverted RGBInverted colour
White255, 255, 2550, 0, 0Black
Red #dc2626220, 38, 3835, 217, 217Cyan #23d9d9
Amber #f59e0b245, 158, 1110, 97, 244Blue #0a61f4
Blue #2563eb37, 99, 235218, 156, 20Gold #da9c14
Green #16a34a22, 163, 74233, 92, 181Pink #e95cb5
Skin tone #e0ac8b224, 172, 13931, 83, 116Dark blue #1f5374

The last row is why inverted portraits look alien. Warm skin tones become deep blues, and pale skin becomes dark, because the lightness flips along with the hue.

Hue turns 180 degrees, saturation stays put

Converting the results above to hue, saturation and lightness shows a clean rule. Inversion rotates the hue by exactly half a turn, leaves saturation untouched, and mirrors lightness around the middle.

ColourBefore: hue, saturation, lightnessAfter inverting
Amber #f59e0b37.7°, 92.1%, 50.2%217.7°, 92.1%, 49.8%
Blue #2563eb221.2°, 83.2%, 53.3%41.2°, 83.2%, 46.7%
Red #dc26260°, 72.2%, 50.6%180°, 72.2%, 49.4%
Green #16a34a142.1°, 76.2%, 36.3%322.1°, 76.2%, 63.7%
Skin #e0ac8b23.3°, 57.8%, 71.2%203.3°, 57.8%, 28.8%

That is why inverting a coloured logo never gives you a dark mode version of it. Every brand colour is replaced by its complement. Only black and white artwork inverts into something you would actually use.

Inverting a JPEG is almost, but not exactly, reversible

In theory inverting twice gets you back where you started, and on raw pixels it does: we inverted 12 photos twice as PNG and found zero difference in any pixel. In practice most images are JPEGs, and a JPEG is compressed again every time it is saved. So we inverted each photo, saved it as a JPEG, inverted that back and saved it again, all at the same quality.

JPEG qualityFidelity after two inversionsLargest single change
9551.59 dB4 to 30 levels
9252.71 dB3 to 30 levels
8553.56 dB3 to 31 levels
8054.33 dB3 to 32 levels
PNG (lossless)Identical0

Everything above 50 dB is invisible, so for viewing purposes the round trip is fine. But the file is not the same file, a handful of pixels moved by up to 32 steps out of 255, and the effect adds up if you repeat it. If you need a perfect undo, keep the original or work in PNG until the last step.

The table also has a small surprise: lower quality settings drifted less. A JPEG saved at quality 80 is already rounded coarsely, and saving it again at quality 80 mostly lands on the same rounded values, so each extra pass changes less. File size barely moved either. The inverted JPEGs came out at 99.96 percent of the size of the originals, because inverting shuffles values without adding or removing detail.

Inverting changes contrast, which matters for dark mode

A tempting shortcut for a dark theme is to invert a light design. The trouble is that contrast, the thing that makes text readable, does not survive the trip unchanged. The WCAG contrast ratio is based on how bright colours look to the eye, which is not a straight line from 0 to 255, so flipping the values changes the ratios.

Text on backgroundContrast beforeInverted text on blackContrast after
Grey #777777 on white4.48#8888885.92
Grey #595959 on white7.00#a6a6a68.63
Grey #999999 on white2.85#6666663.66
Blue #2563eb on white5.17#da9c148.75
Red #dc2626 on white4.83#23d9d912.00
Amber #f59e0b on white2.15#0a61f44.03
Black on white21.00#ffffff21.00

Every pair except pure black and white gained contrast when inverted, sometimes a lot. That sounds like good news, and for readability it often is, but it means an inverted design is a different design. Text that passed the 4.5 to 1 minimum for normal text in the light theme may now be far louder than intended, and the grey #777777 that failed at 4.48 on white quietly passes at 5.92 on black. Check contrast in both themes instead of assuming one follows from the other.

Why your scanned film negative turns blue

Black and white negatives are simple: dark where the scene was bright. Invert them and you get the photo back, which is why scanning old family negatives and inverting them works so well.

Colour negative film adds an orange mask, a tint built into the film to correct colour defects in the dyes. When you invert a scan, that orange becomes its opposite, a strong blue. As an example, an orange base of 255, 165, 90 inverts to 0, 90, 165, and that blue sits on top of every colour in the picture.

  1. Scan the negative including a little of the clear film between frames, which shows the mask on its own.
  2. Use your editor's levels or curves tool to set that clear area to white for each colour channel, which cancels the orange.
  3. Invert the image, then fine tune the white balance on something that should be neutral grey.

Dedicated scanning software does these steps for you, and our Invert Colors tool handles black and white negatives in one click.

Smart Invert and Classic Invert on a phone

Phones offer inversion as an accessibility setting for people who find dark backgrounds easier to read. On an iPhone, Apple describes Classic Invert as reversing all colours on the display, and Smart Invert as reversing them except for images, media and some apps that already use dark colour styles. These settings only change how the screen looks. Your photos and files are not modified.

How to invert an image

  • In your browser: drop the image into Invert Colors, use the blend slider if you want a partial effect, and download a PNG.
  • In Photoshop: Image, Adjustments, Invert, or Ctrl+I (Cmd+I on a Mac).
  • In GIMP: Colors, Invert.
  • In CSS: filter: invert(1) inverts an element on screen without changing the file. invert(0.5) turns everything flat grey, because every value meets its opposite in the middle at 127.5.

Invert an image now

Free, no upload and no watermark. The blend slider lets you stop anywhere between the original and the full negative, and the result downloads as a lossless PNG.

Open Invert ColorsGrayscaleAdjust Image

The bottom line

Inverting is exact arithmetic: 255 minus each value, hue turned half a circle, saturation unchanged, lightness mirrored. It undoes itself perfectly on lossless pixels and nearly perfectly through JPEG saves. What it does not do is produce a usable dark mode, a correctly coloured film scan or a logo in its brand colours. For those, the inversion is only the first step.

Frequently asked questions

How do I invert the colors of an image?+
Open it in an image inverter such as our Invert Colors tool, check the preview and download. Each colour value is replaced by 255 minus that value, so black becomes white and every hue turns to its opposite.
Is inverting an image reversible?+
Yes on lossless pixels: inverting a PNG twice gave zero difference in our test. Through JPEG saves it is nearly reversible, landing between 51 and 54 dB, which is invisible, with a few pixels off by up to 32 levels.
What is the opposite color of orange?+
Blue. Inversion turns every hue by 180 degrees, so amber #f59e0b becomes #0a61f4, red becomes cyan and green becomes pink.
Why does my scanned color negative look blue after inverting?+
Colour negative film has an orange mask built into the base. Inverting turns that orange into blue. Cancel the mask with levels or curves using the clear film between frames, then invert.
Why does my image turn grey at 50 percent invert?+
Each value moves halfway toward its opposite, and halfway between any value and its opposite is always 127.5. So every pixel becomes the same mid grey.
Can I make a dark mode by inverting my design?+
Not reliably. Inversion changes every brand colour to its complement and raises the contrast of most text pairs, so an inverted design reads and looks different. Check contrast in both themes.
Does inverting an image change its file size?+
Barely. In our test, inverted JPEGs saved at the same quality came out at 99.96 percent of the original size.

Sources and method

Test set: 12 public domain NASA photographs at 1,200 pixels wide. For the round trip test each photo was saved as a JPEG, inverted, saved as JPEG, inverted back and saved again at the same quality (95, 92, 85 and 80), then compared with the first JPEG; fidelity is pooled PSNR across all 12 photos. Colour conversions use standard HSL formulas. Contrast ratios follow the WCAG definition of relative luminance.

  1. W3C Filter Effects Module Level 1, the invert() function
  2. W3C WCAG 2.2, contrast minimum and relative luminance
  3. Apple Support, display and text size preferences (Smart Invert and Classic Invert)
  4. Negative (photography), Wikipedia
  5. NASA Image and Video Library, source of the test photographs
CITE THIS ARTICLE

Inverting a PNG twice returned identical pixels, while inverting a JPEG and back at quality 92 landed at 52.7 dB, and inverting a grey #777777 text colour on white raised its contrast ratio from 4.48 to 5.92. FreeImageTools, "How to Invert Image Colors (and When It Goes Wrong)", September 27, 2026, https://freeimagetools.org/blog/invert-image-colors-explained

Keep reading