JSPM

  • Created
  • Published
  • Downloads 178657
  • Score
    100M100P100Q184707F
  • License MIT

A simple library that calculates the average color of images, videos and canvas in browser environment.

Package Exports

  • fast-average-color
  • fast-average-color/dist/index.esm.js
  • fast-average-color/dist/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 (fast-average-color) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

🍏🍊🍅 Fast Average Color

NPM version NPM Downloads install size Coveralls

Demo

A simple library that calculates average or dominant color of any images or videos in browser environment.

Features

  • Bet on speed
  • Some algorithms: simple, sqrt (default) and dominant
  • Small bundle size, tree shaking
  • Average color can be obtained from:
    • image
    • string (url of image or base64)
    • video
    • canvas or OffscreenCanvas
    • ImageBitmap
    • VideoFrame
    • array of numbers, Uint8Array or Uint8ClampedArray
  • Average color can be obtained from specific part of resource
  • Support for transparency (PNG, SVG and other formats)
  • Support for web workers
  • Support for Node.js

Table of contents

Unhandled Rejection (SecurityError): The operation is insecure.

The crossOrigin attribute allows images that are loaded from external origins to be used in canvas like the one they were being loaded from the current origin. Using images without CORS approval taints the canvas. Once a canvas has been tainted, you can no longer pull data back out of the canvas. By loading the canvas from cross origin domain, you are tainting the canvas.

You can prevent this by setting crossorigin="anonymous".

More examples

See code

License

MIT License

Similar projects

Friends