Unpremultiply RGBA Alpha
Undo premultiplied alpha for one pixel: red 0.125, green 0.25 and blue 0.375 at alpha 0.5 come back as 0.25, 0.5 and 0.75, with alpha unchanged. Zero alpha and colors above alpha are refused. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- Red
- 0.125
- Green
- 0.25
- Blue
- 0.375
- Alpha
- 0.5
- Red
- 0.25
- Green
- 0.5
- Blue
- 0.75
- Rgba
- 0.25, 0.5, 0.75, 0.5
The RGBA alpha unpremultiplier recovers straight red, green, and blue channels from a normalized premultiplied pixel. Supply four numeric channels between 0 and 1, and the calculator divides each color component by alpha while preserving the original alpha value. It also validates that every premultiplied color is no greater than alpha and rejects zero alpha, where the original color cannot be recovered. The deterministic response provides both named channels and an ordered RGBA array for direct use in graphics tools, tests, converters, and image-processing pipelines.
Understand premultiplied and straight alpha
RGBA data can represent transparency in two common ways. Straight-alpha data stores the original red, green, and blue values independently of opacity. Premultiplied data stores each of those color values after multiplying it by alpha.
For example, a straight red value of 0.8 at an alpha of 0.5 is stored as a premultiplied red value of 0.4. Premultiplication is useful in compositing because it makes several blending operations simpler and avoids some color artifacts around transparent edges, but the stored channels no longer describe the original color directly. This capability reverses that arithmetic for one normalized pixel.
It divides the supplied red, green, and blue values by the supplied alpha and returns alpha unchanged. Inputs use the normalized range from 0 through 1, rather than byte values from 0 through 255, so the relationship is explicit and consistent across fractional data. The response names every recovered channel and also includes an RGBA array in red, green, blue, alpha order for consumers that prefer positional values.
Know why zero alpha is an error
Unpremultiplication is only defined when alpha is greater than zero. If alpha is zero, every correctly premultiplied color channel is also zero, regardless of the straight color that existed before multiplication. A transparent premultiplied pixel containing red 0, green 0, blue 0, and alpha 0 could have originated from any straight RGB color, so division by zero cannot recover a unique answer.
Returning black, retaining the zero channels, or inventing another fallback would look deterministic while silently claiming information that the input does not contain.
Use deterministic channel recovery in a workflow
Send one pixel as named red, green, blue, and alpha numbers. A premultiplied value such as red 0.125, green 0.25, blue 0.375, and alpha 0.5 returns straight channels 0.25, 0.5, and 0.75 with alpha 0.5. No rounding policy, color-space conversion, gamma correction, clamping, byte quantization, random source, clock, or locale-sensitive formatting is involved.
Always confirm that the source really is premultiplied; applying this operation to straight-alpha data will brighten channels incorrectly.
What you can do with it
Normalize asset pipeline records
Transform individual RGBA records into a consistent straight-alpha representation before serialization, inspection, or downstream conversion.
FAQ
What channel range does this capability accept?
All four channels must be finite normalized numbers from 0 through 1, and alpha must be greater than zero.
Why can a premultiplied color channel not exceed alpha?
For normalized source colors, multiplying a value no greater than 1 by alpha cannot produce a value greater than alpha. Such input is inconsistent with normalized premultiplication.
Does this convert between color spaces or apply gamma correction?
No. It performs only the arithmetic unpremultiplication of the supplied numeric channels. Interpret and convert the color space separately.
Does the result round or clamp recovered channels?
No. Valid inputs already guarantee results in the normalized range, and each color result is the direct division of its premultiplied value by alpha.
What is the difference between straight and premultiplied alpha?
Straight alpha keeps the original color apart from opacity, while premultiplied alpha stores each color already multiplied by alpha. A straight red of 0.8 at alpha 0.5 is stored premultiplied as 0.4.
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/color/unpremultiply \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"red":0.125,"green":0.25,"blue":0.375,"alpha":0.5}'const res = await fetch("https://api.kit.forhosting.com/color/unpremultiply", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"red": 0.125,
"green": 0.25,
"blue": 0.375,
"alpha": 0.5
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/color/unpremultiply",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"red": 0.125,
"green": 0.25,
"blue": 0.375,
"alpha": 0.5
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/color/unpremultiply", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"red":0.125,"green":0.25,"blue":0.375,"alpha":0.5}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"red":0.125,"green":0.25,"blue":0.375,"alpha":0.5}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/color/unpremultiply", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"red": 0.125,
"green": 0.25,
"blue": 0.375,
"alpha": 0.5
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "color.unpremultiply",
"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.
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
Know why zero alpha is an error
This calculator therefore rejects zero alpha with an `invalid_input` error. It also rejects non-finite numbers, channels outside the normalized range, and any premultiplied red, green, or blue value greater than alpha. That last check enforces the expected invariant for normalized premultiplied data and prevents a division result above 1. These strict guards make data problems visible at the boundary, before an invalid pixel can enter a renderer, shader input, asset conversion, or automated comparison.
Use deterministic channel recovery in a workflow
Use this operation when an image library, graphics API, canvas export, texture pipeline, or serialized asset provides premultiplied normalized channels but the next system expects straight alpha. The calculation is direct division under ECMAScript numeric rules, so identical valid JSON input produces the same JSON result through the browser and API paths. The API costs $0.002 per request and is suitable for repeatable validation or integration jobs. For bulk image processing, call the underlying operation as part of a bounded pixel pipeline rather than treating the single-item endpoint as a complete image decoder.
Integration use cases
Convert graphics API output
Recover straight normalized color channels before passing premultiplied pixel data to an API that expects independent RGB and alpha values.
Verify compositing calculations
Check known premultiplied samples in unit tests and compare the named recovered channels with expected straight-alpha values.
Technical questions
What happens when alpha is zero?
The request fails with `invalid_input` because fully transparent premultiplied data does not retain enough information to recover a unique straight color.