Invert image colors
Get the exact complementary color of each RGB pixel: every channel becomes 255 minus its value, so black turns white, red turns cyan and 12, 34, 56 becomes 243, 221, 199. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
The image color inverter accepts a sequence of RGB pixel samples and calculates the exact complementary color for every sample. Each red, green, and blue channel is replaced with 255 minus its original value, so black becomes white, red becomes cyan, and every intermediate value is transformed predictably. The tool validates every channel before processing and rejects values outside the standard 0–255 RGB range, making it suitable for quick checks, teaching, tests, and deterministic data pipelines.
Understand the inversion calculation
Color inversion is performed independently for all three channels using the same equation: the output value is 255 minus the input value. A pixel of red 255, green 0, and blue 0 therefore becomes red 0, green 255, and blue 255, which is cyan. Black, represented by 0, 0, 0, becomes white at 255, 255, 255.
Midpoint values stay near the midpoint, while darker channels become lighter and lighter channels become darker. No color profile conversion, gamma adjustment, rounding, blending, or image compression is applied. This capability works directly on the supplied numeric samples, so the calculation is transparent and reproducible.
It also preserves valid fractional channel values rather than forcing them to integers; for example, 10.5 becomes 244.5. That makes the result appropriate for pipelines that use floating-point RGB samples before a later rasterization or quantization step. Because every output depends only on its corresponding input, repeated calls with the same samples always produce exactly the same result.
Use the result in image and testing workflows
The returned object contains a pixels list with the inverted RGB records in their original order. The capability deliberately operates on samples rather than accepting an encoded PNG or JPEG file: decoding and re-encoding formats can introduce metadata, compression, alpha-channel, and color-profile decisions that are outside a simple RGB inversion. Keeping the contract focused makes it easy to audit the mathematics and compare results across environments.
It is especially helpful when you need canonical expected values for a graphics test, want to demonstrate complementary colors in a lesson, or need to invert colors already extracted by another tool.
What you can do with it
Teach complementary colors
Show exactly how black, white, primary colors, and intermediate RGB values change under channel-by-channel inversion.
Prepare pixel data for rendering
Transform RGB samples already decoded by a canvas, raster parser, or graphics pipeline before sending them to the next processing step.
FAQ
What does the operation cost?
The same deterministic calculation can also run in the browser on this page.
Are fractional RGB values supported?
Yes. Any finite numeric value from 0 through 255 is accepted, and its exact inverse is returned without forced rounding.
Does this tool accept PNG or JPEG files?
No. It accepts decoded RGB pixel samples. File decoding, metadata, compression, alpha channels, and color profiles are intentionally outside this focused calculation.
Is the order of pixels preserved?
Yes. Each output record occupies the same list position as its matching input record.
How many samples can one request contain?
A request may contain from one through 100,000 RGB samples.
Related tools
For developers — API access
Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.
API endpoint
Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.
Call it from your stack
curl -X POST https://api.kit.forhosting.com/image/invert-colors \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"pixels":[{"r":255,"g":128,"b":0},{"r":12,"g":34,"b":56}]}'const res = await fetch("https://api.kit.forhosting.com/image/invert-colors", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"pixels": [
{
"r": 255,
"g": 128,
"b": 0
},
{
"r": 12,
"g": 34,
"b": 56
}
]
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/image/invert-colors",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"pixels": [
{
"r": 255,
"g": 128,
"b": 0
},
{
"r": 12,
"g": 34,
"b": 56
}
]
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/image/invert-colors", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"pixels":[{"r":255,"g":128,"b":0},{"r":12,"g":34,"b":56}]}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"pixels":[{"r":255,"g":128,"b":0},{"r":12,"g":34,"b":56}]}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/image/invert-colors", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"pixels": [
{
"r": 255,
"g": 128,
"b": 0
},
{
"r": 12,
"g": 34,
"b": 56
}
]
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "image.invert_colors",
"status": "queued",
"_links": {
"result": "/tasks/tsk_…/result"
}
}The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.
Pricing
Published price — no tokens, no invented credits. A failed task is never charged.
Limits
max_items | 100000 |
Errors
| HTTP | Code | Meaning |
|---|---|---|
401 | unauthorized | Missing or invalid API key. |
402 | insufficient_balance | Your balance doesn't cover the task price. |
404 | unknown_type | That task type doesn't exist. |
429 | rate_limited | Too many requests. Use the webhook instead of polling. |
Technical notes
Provide RGB samples in a clear, structured form
Enter one or more pixels, with a numeric r, g, and b channel for each pixel. The order of the samples is preserved, which means the first inverted result corresponds to the first input sample, the second result corresponds to the second sample, and so on. Every value must be finite and must remain inside the inclusive 0–255 range used by standard RGB samples. Values may include endpoints such as 0 and 255 as well as intermediate numbers. If a channel is missing, is not numeric, is infinite, or falls outside that range, the request stops with an input error instead of returning a partially transformed list. A single request can contain up to 100,000 samples, providing a practical boundary for browser use and API automation while keeping memory and execution predictable.
Use the result in image and testing workflows
The browser version runs the same pure calculation as the API. Interactive checks can therefore be made locally on the page, while recurring jobs and larger integrations can call the API at $0.002 per request without changing the transformation rules.
Integration use cases
Build graphics test fixtures
Generate deterministic complementary RGB samples for unit tests without duplicating inversion arithmetic in fixture preparation.
Technical questions
What happens when a channel is outside 0–255?
The request fails with an invalid input error that identifies the pixel and channel. No partial result is returned.