JSPM

thumbhash-node

0.1.3
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 149
  • Score
    100M100P100Q81274F
  • License MIT

thumbhash binding for Node.js

Package Exports

  • thumbhash-node
  • thumbhash-node/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (thumbhash-node) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

thumbhash-node

https://github.com/amehashi/thumbhash-node/actions

thumbhash binding for Node.js.

Install this package

yarn add thumbhash-node
pnpm add thumbhash-node
npm install thumbhash-node

Support matrix

Operating Systems

node14 node16 node18
Windows x64
Windows x32
Windows arm64
macOS x64
macOS arm64
Linux x64 gnu
Linux x64 musl
Linux arm gnu
Linux arm64 gnu
Linux arm64 musl
Android arm64
Android armv7
FreeBSD x64

API

/** Encodes an RGBA image to a ThumbHash. RGB should not be premultiplied by A. */
export function rgbaToThumbHash(w: number, h: number, rgba: Uint8Array): Uint8Array
/**
 * Extracts the approximate aspect ratio of the original image.
 * An error will be returned if the input is too short.
 */
export function thumbHashToApproximateAspectRatio(hash: Uint8Array): number
export interface Rgba {
  r: number
  g: number
  b: number
  a: number
}
/**
 * Extracts the average color from a ThumbHash.
 * Returns the RGBA values where each value ranges from 0 to 1.
 * RGB is not be premultiplied by A.
 * An error will be returned if the input is too short.
 */
export function thumbHashToAverageRGBA(hash: Uint8Array): Rgba
export interface Image {
  width: number
  height: number
  rgba: Uint8Array
}
/**
 * Decodes a ThumbHash to an RGBA image.
 * RGB is not be premultiplied by A.
 * Returns the width, height, and pixels of the rendered placeholder image.
 * An error will be returned if the input is too short.
 */
export function thumbHashToRGBA(hash: Uint8Array): Image