Palette Entry Permutation Tool
Permute palette entries using output-to-input ordering and report the inverse remapping for existing indexed pixels.
Description
Permute palette entries using output-to-input ordering and report the inverse remapping for existing indexed pixels.
Reordering palette entries changes the meaning of index references unless an inverse map is carried along.
When to use this tool
Permute palette entries using output-to-input ordering and report the inverse remapping for existing indexed pixels.
- Prepare the supplied paletteJson, permutation fields for this operation.
- Compare the complete example with the representation used by your own input before carrying the result into another step.
How to use the tool and how it works
- Enter paletteJson, permutation. Use the exact text syntax, units and index conventions explained below.
- Run the tool. If input validation fails, correct the supplied fields before interpreting any result.
- Read result.palette, result.oldToNew. Interpret false, null and empty lists using the distinctions below; they can be valid outputs.
Validate a same-length permutation of every source palette index. Return entries in that source-index order and oldToNew mapping each original index to its new position.1
| Input field | Meaning and representation | Accepted input |
|---|---|---|
| paletteJson | JSON text, entered as one text field. The decoded structure is illustrated below; it is not a separate file. | Text |
| permutation | permutation. | List of finite numbers; at most 128 entries |
For the JSON text fields, the following decoded structures show the example records before they are serialized into input strings. Keep field names, list nesting and value types as shown.
[
{
"field": "paletteJson",
"decoded": [
{
"id": "a",
"name": "Red",
"rgba": [
255,
0,
0,
255
]
},
{
"id": "b",
"name": "red",
"rgba": [
255,
0,
0,
0
]
}
]
}
] | Output field | Interpretation |
|---|---|
| result | Object containing the named outputs below. |
| result.palette | The palette list in the ordering and representation described above. |
| result.oldToNew | For each old palette index, its zero-based position in the reordered palette. |
{
"input": {
"paletteJson": "[{\"id\":\"a\",\"name\":\"Red\",\"rgba\":[255,0,0,255]},{\"id\":\"b\",\"name\":\"red\",\"rgba\":[255,0,0,0]}]",
"permutation": [
1,
0
]
},
"output": {
"result": {
"palette": [
{
"id": "b",
"name": "red",
"rgba": [
255,
0,
0,
0
]
},
{
"id": "a",
"name": "Red",
"rgba": [
255,
0,
0,
255
]
}
],
"oldToNew": [
1,
0
]
}
}
} Limitations and assumptions
- The operation does not rewrite an external indexed image. IDs and channel values are preserved without deduplication.
- Palette records contain string id/name and exactly four RGBA bytes from zero through 255; at most 128 records are accepted. Duplicate IDs or names remain allowed unless this operation explicitly audits or rejects them.
- Every declared top-level field is required and unexpected fields are rejected. Numeric inputs must be finite; ordinary text fields are bounded to 8,192 UTF-16 code units, with tighter operation-specific limits where stated.
- Lists are limited to 128 entries. JSON text must meet bounded size and depth checks, and numeric outputs beyond the safe finite magnitude are rejected. Exact large integers use decimal strings.
- Indexes are zero-based and spans have an exclusive end unless explicitly stated otherwise. A valid false, null or empty-list result is distinct from malformed input.
Alternative or Complementary methods
Use actual rendering or a color-managed workflow when comparing perceived color and transparency. Index changes need corresponding updates to their consumers; name and role checks do not establish visual accessibility.
References
Similar or alternative tools
- Palette Used Entry Compactor
Compact a palette to explicitly used entries in original palette order and remap all indexes, retaining old-index provenance.
- Palette Adjacent Repeat Audit
Audit adjacent exact RGBA palette repeats, excluding RGB-only matches whose alpha differs; caller ordering is preserved.