Palette Color Usage Counter

Count explicit palette-index usage including unused entries; rejects unknown indexes rather than guessing nearest colors.

Description

Count explicit palette-index usage including unused entries; rejects unknown indexes rather than guessing nearest colors.

Palette usage is counted by entry position, even when colors or IDs repeat.

When to use this tool

Count explicit palette-index usage including unused entries; rejects unknown indexes rather than guessing nearest colors.

  • Prepare the supplied paletteJson, indexes 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

  1. Enter paletteJson, indexes. Use the exact text syntax, units and index conventions explained below.
  2. Run the tool. If input validation fails, correct the supplied fields before interpreting any result.
  3. Read result.usage. Interpret false, null and empty lists using the distinctions below; they can be valid outputs.

Parse palette records, require all indexes in range and return each entry ID with the number of references to its position, including zero counts.1

Input fieldMeaning and representationAccepted input
paletteJsonJSON text, entered as one text field. The decoded structure is illustrated below; it is not a separate file.Text
indexesindexes.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.

json
[
  {
    "field": "paletteJson",
    "decoded": [
      {
        "id": "a",
        "name": "Red",
        "rgba": [
          255,
          0,
          0,
          255
        ]
      },
      {
        "id": "b",
        "name": "red",
        "rgba": [
          255,
          0,
          0,
          0
        ]
      }
    ]
  }
]
Output fieldInterpretation
resultObject containing the named outputs below.
result.usageThe usage list in the ordering and representation described above.
json
{
  "input": {
    "paletteJson": "[{\"id\":\"a\",\"name\":\"Red\",\"rgba\":[255,0,0,255]},{\"id\":\"b\",\"name\":\"red\",\"rgba\":[255,0,0,0]}]",
    "indexes": [
      1,
      1,
      0
    ]
  },
  "output": {
    "result": {
      "usage": [
        {
          "id": "a",
          "count": 1
        },
        {
          "id": "b",
          "count": 2
        }
      ]
    }
  }
}

Limitations and assumptions

  • No image file is read and duplicate IDs are not merged. Counts refer only to the supplied index list.
  • 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

  1. Tool behavior and example: Palette Color Usage Counter — tool.io

Similar or alternative tools

Don't forget to set a bookmark for tool.io!
Privacy | Imprint | Cookies