@thi.ng/pixel-analysis
TypeScript icon, indicating that this package has built-in type declarations

2.0.6 • Public • Published

@thi.ng/pixel-analysis

npm version npm downloads Mastodon Follow

[!NOTE] This is one of 210 standalone projects, maintained as part of the @thi.ng/umbrella monorepo and anti-framework.

🚀 Please help me to work full-time on these projects by sponsoring me on GitHub. Thank you! ❤️

About

Image color & feature analysis utilities. This is a support package for @thi.ng/pixel.

Color analysis

  • Dominant colors in different color modes/formats:
    • CSS (hex)
    • sRGB
    • HSV
    • Oklch (perceptual)
  • Normalized areas of dominant color clusters
  • Min/max HSV hue range of dominant colors (considering angular wrap-around)
  • Min/max HSV saturation range of dominant colors
  • Min/max luminance range of dominant colors (obtained from SRGB)
  • Min/max luminance range of entire grayscale image (obtained from SRGB)
  • Average values for hue (circular mean), saturation, luminance
  • Area-weighted average saturation of dominant colors
  • Area-weighted average luminance of dominant colors
  • Standard deviation for hue, saturation, luminance
  • Normalized color temperature, incl. area-weighted indicator of "cold" vs "warm" hues present
  • Luminance contrast of dominant colors
  • Luminance contrast of entire grayscale image
  • Max. normalized WCAG color contrast of dominant colors

Status

BETA - possibly breaking changes forthcoming

Search or submit any issues for this package

Installation

yarn add @thi.ng/pixel-analysis

ESM import:

import * as pa from "@thi.ng/pixel-analysis";

Browser ESM import:

<script type="module" src="https://esm.run/@thi.ng/pixel-analysis"></script>

JSDelivr documentation

For Node.js REPL:

const pa = await import("@thi.ng/pixel-analysis");

Package sizes (brotli'd, pre-treeshake): ESM: 1.87 KB

Dependencies

Note: @thi.ng/api is in most cases a type-only import (not used at runtime)

API

Generated API docs

TODO

Authors

If this project contributes to an academic publication, please cite it as:

@misc{thing-pixel-analysis,
  title = "@thi.ng/pixel-analysis",
  author = "Karsten Schmidt",
  note = "https://thi.ng/pixel-analysis",
  year = 2024
}

License

© 2024 - 2025 Karsten Schmidt // Apache License 2.0

Package Sidebar

Install

npm i @thi.ng/pixel-analysis

Weekly Downloads

245

Version

2.0.6

License

Apache-2.0

Unpacked Size

45.3 kB

Total Files

14

Last publish

Collaborators

  • thi.ng