[Script] Reference Color Extractor (Frequency, Diversity, K-Means)

Reference Color Extractor is a Lua script designed to generate optimized color palettes from external reference images. Unlike the built-in palette generation, this tool provides control over the extraction logic via three distinct algorithms.

Features

  • External File Support: Analyze PNG, JPG, or BMP files without importing them into your project.

  • Three Extraction Methods:

    • Frequency: Selects the most dominant colors by pixel count.

    • Diversity (Median Cut): Prioritizes a wide range of tones, preserving accents and highlights.

    • Balanced (K-Means): Uses iterative clustering to find mathematical color centers for natural transitions.

  • UI Integration: Preview extracted colors before applying them.

  • Palette Management: Option to replace the current palette or append colors with a spacer.

Installation

  1. Copy the .lua file to your Aseprite scripts folder (File > Scripts > Open Scripts Folder).

  2. Rescan or restart Aseprite.

  3. Access via File > Scripts > Reference Color Extractor.

Download


Developed for personal workflow efficiency, now available for public use.

Update: Version 2.0 is now live!

After using the script in my own workflow, I realized that simply extracting colors isn’t enough—organization is just as important. Version 2.0 focuses on making the extracted palettes actually usable without manual cleanup.

What’s New:

  • Smart Sorting: You can now sort colors by Hue, Luminance, or Saturation before applying them.

  • Stepped Hue Algorithm: Improved logic that groups dark tones together, ensuring clean visual flow and logical gradients.

  • Enhanced Append Mode: If you choose to add colors to an existing palette instead of replacing it, the script now automatically inserts a 4-slot black spacer to keep your workspace organized.

  • Optimization: Refined Frequency extraction to better filter out technical noise and duplicates.

The goal was to move from “raw data” to a “ready-to-use palette” with zero manual effort.

Download the update on itch.io